ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
PATCH 1/1 ext4: Replace opencoded i_writecount usage with inode_is_open_for_write
There is a function which clearly conveys the objective of checking i_writecount. Additionally the usage in ext4_mb_initialize_context was wrong, since a node would have wrongfully been reported as writable if i_writecount had a negative value (MMAP_DENY_WRITE).
--- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
fs/ext4/inode.c +1 -1
@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,* inode's preallocations. */ if ((ei->i_reserved_data_blocks ==0 ) && - (atomic_read (&inode->i_writecount) ==0 )) + !inode_is_open_for_write (inode))ext4_discard_preallocations (inode); }
fs/ext4/mballoc.c +3 -4
@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) isize = (i_size_read (ac->ac_inode) + ac->ac_sb->s_blocksize -1 ) >> bsbits; -if ((size == isize) && - !ext4_fs_is_busy (sbi) && - (atomic_read (&ac->ac_inode->i_writecount) ==0 )) { +if ((size == isize) && !ext4_fs_is_busy (sbi) && + !inode_is_open_for_write (ac->ac_inode)) { ac->ac_flags |=EXT4_MB_HINT_NOPREALLOC ;return ; }
@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, (unsigned ) ar->goal, ac->ac_flags, ac->ac_2order, (unsigned ) ar->lleft, (unsigned ) ar->pleft, (unsigned ) ar->lright, (unsigned ) ar->pright, - atomic_read(&ar->inode->i_writecount) ? "" : "non-"); + inode_is_open_for_write(ar->inode) ? "" : "non-");return 0 ; }
Signature · 1 line
2.17.1
Quoted 7 lines · Nikolay Borisov
There is a function which clearly conveys the objective of checking
i_writecount. Additionally the usage inext4_mb_initialize_contextwas wrong, since a node would have wrongfully been reported as writable ifi_writecounthad a negative value (MMAP_DENY_WRITE).Reviewed-by Jan Kara <[email protected]>Signed-off-by Nikolay Borisov <[email protected]>
Gentle ping
Quoted 44 lines
--- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)fs/ext4/inode.c +1
-1@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,* inode's preallocations. */ if ((ei->i_reserved_data_blocks ==0 ) && - (atomic_read (&inode->i_writecount) ==0 )) + !inode_is_open_for_write (inode))ext4_discard_preallocations (inode); }fs/ext4/mballoc.c +3
-4@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) isize = (i_size_read (ac->ac_inode) + ac->ac_sb->s_blocksize -1 ) >> bsbits; -if ((size == isize) && - !ext4_fs_is_busy (sbi) && - (atomic_read (&ac->ac_inode->i_writecount) ==0 )) { +if ((size == isize) && !ext4_fs_is_busy (sbi) && + !inode_is_open_for_write (ac->ac_inode)) { ac->ac_flags |=EXT4_MB_HINT_NOPREALLOC ;return ; }@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, (unsigned ) ar->goal, ac->ac_flags, ac->ac_2order, (unsigned ) ar->lleft, (unsigned ) ar->pleft, (unsigned ) ar->lright, (unsigned ) ar->pright, - atomic_read(&ar->inode->i_writecount) ? "" : "non-"); + inode_is_open_for_write(ar->inode) ? "" : "non-");return 0 ; }
Quoted 7 lines · Nikolay Borisov
There is a function which clearly conveys the objective of checking
i_writecount. Additionally the usage inext4_mb_initialize_contextwas wrong, since a node would have wrongfully been reported as writable ifi_writecounthad a negative value (MMAP_DENY_WRITE).Reviewed-by Jan Kara <[email protected]>Signed-off-by Nikolay Borisov <[email protected]>
Yet another ping, if something is wrong with the patch I'm happy to fix it and get it merged.
Quoted 44 lines
--- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)fs/ext4/inode.c +1
-1@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,* inode's preallocations. */ if ((ei->i_reserved_data_blocks ==0 ) && - (atomic_read (&inode->i_writecount) ==0 )) + !inode_is_open_for_write (inode))ext4_discard_preallocations (inode); }fs/ext4/mballoc.c +3
-4@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) isize = (i_size_read (ac->ac_inode) + ac->ac_sb->s_blocksize -1 ) >> bsbits; -if ((size == isize) && - !ext4_fs_is_busy (sbi) && - (atomic_read (&ac->ac_inode->i_writecount) ==0 )) { +if ((size == isize) && !ext4_fs_is_busy (sbi) && + !inode_is_open_for_write (ac->ac_inode)) { ac->ac_flags |=EXT4_MB_HINT_NOPREALLOC ;return ; }@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, (unsigned ) ar->goal, ac->ac_flags, ac->ac_2order, (unsigned ) ar->lleft, (unsigned ) ar->pleft, (unsigned ) ar->lright, (unsigned ) ar->pright, - atomic_read(&ar->inode->i_writecount) ? "" : "non-"); + inode_is_open_for_write(ar->inode) ? "" : "non-");return 0 ; }
Quoted 8 lines · Nikolay Borisov
There is a function which clearly conveys the objective of checking
i_writecount. Additionally the usage inext4_mb_initialize_contextwas wrong, since a node would have wrongfully been reported as writable ifi_writecounthad a negative value (MMAP_DENY_WRITE).Reviewed-by Jan Kara <[email protected]>Signed-off-by Nikolay Borisov <[email protected]>
Quoted 44 lines
---
fs/ext4/inode.c| 2 +-fs/ext4/mballoc.c| 7 +++----2 files changed, 4 insertions(+), 5 deletions(-)fs/ext4/inode.c +1
-1@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,* inode's preallocations. */ if ((ei->i_reserved_data_blocks ==0 ) && - (atomic_read (&inode->i_writecount) ==0 )) + !inode_is_open_for_write (inode))ext4_discard_preallocations (inode); }fs/ext4/mballoc.c +3
-5@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) isize = (i_size_read (ac->ac_inode) + ac->ac_sb->s_blocksize -1 ) >> bsbits; -if ((size == isize) && - !ext4_fs_is_busy (sbi) && - (atomic_read (&ac->ac_inode->i_writecount) ==0 )) { +if ((size == isize) && !ext4_fs_is_busy (sbi) && + !inode_is_open_for_write (ac->ac_inode)) { ac->ac_flags |=EXT4_MB_HINT_NOPREALLOC ;return ; }@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, (unsigned ) ar->goal, ac->ac_flags, ac->ac_2order, (unsigned ) ar->lleft, (unsigned ) ar->pleft, (unsigned ) ar->lright, (unsigned ) ar->pright, - atomic_read(&ar->inode->i_writecount) ? "" : "non-"); + inode_is_open_for_write(ar->inode) ? "" : "non-");return 0 ; } --
Quoted 2 lines
2.17.1
Cheers, Andreas
Quoted 7 lines · Nikolay Borisov
There is a function which clearly conveys the objective of checking
i_writecount. Additionally the usage inext4_mb_initialize_contextwas wrong, since a node would have wrongfully been reported as writable ifi_writecounthad a negative value (MMAP_DENY_WRITE).Reviewed-by Jan Kara <[email protected]>Signed-off-by Nikolay Borisov <[email protected]>
Yet another ping ?
Quoted 44 lines
--- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)fs/ext4/inode.c +1
-1@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,* inode's preallocations. */ if ((ei->i_reserved_data_blocks ==0 ) && - (atomic_read (&inode->i_writecount) ==0 )) + !inode_is_open_for_write (inode))ext4_discard_preallocations (inode); }fs/ext4/mballoc.c +3
-4@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) isize = (i_size_read (ac->ac_inode) + ac->ac_sb->s_blocksize -1 ) >> bsbits; -if ((size == isize) && - !ext4_fs_is_busy (sbi) && - (atomic_read (&ac->ac_inode->i_writecount) ==0 )) { +if ((size == isize) && !ext4_fs_is_busy (sbi) && + !inode_is_open_for_write (ac->ac_inode)) { ac->ac_flags |=EXT4_MB_HINT_NOPREALLOC ;return ; }@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, (unsigned ) ar->goal, ac->ac_flags, ac->ac_2order, (unsigned ) ar->lleft, (unsigned ) ar->pleft, (unsigned ) ar->lright, (unsigned ) ar->pright, - atomic_read(&ar->inode->i_writecount) ? "" : "non-"); + inode_is_open_for_write(ar->inode) ? "" : "non-");return 0 ; }
Quoted 7 lines · Nikolay Borisov
There is a function which clearly conveys the objective of checking
i_writecount. Additionally the usage inext4_mb_initialize_contextwas wrong, since a node would have wrongfully been reported as writable ifi_writecounthad a negative value (MMAP_DENY_WRITE).Reviewed-by Jan Kara <[email protected]>Signed-off-by Nikolay Borisov <[email protected]>
Thanks, applied.
- Ted