Commit 82dd124c authored by Nikolay Borisov's avatar Nikolay Borisov Committed by Theodore Ts'o

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).
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent 53cf9784
...@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode, ...@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
* inode's preallocations. * inode's preallocations.
*/ */
if ((ei->i_reserved_data_blocks == 0) && if ((ei->i_reserved_data_blocks == 0) &&
(atomic_read(&inode->i_writecount) == 0)) !inode_is_open_for_write(inode))
ext4_discard_preallocations(inode); ext4_discard_preallocations(inode);
} }
......
...@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) ...@@ -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) isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1)
>> bsbits; >> bsbits;
if ((size == isize) && if ((size == isize) && !ext4_fs_is_busy(sbi) &&
!ext4_fs_is_busy(sbi) && !inode_is_open_for_write(ac->ac_inode)) {
(atomic_read(&ac->ac_inode->i_writecount) == 0)) {
ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC; ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
return; return;
} }
...@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, ...@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
(unsigned) ar->goal, ac->ac_flags, ac->ac_2order, (unsigned) ar->goal, ac->ac_flags, ac->ac_2order,
(unsigned) ar->lleft, (unsigned) ar->pleft, (unsigned) ar->lleft, (unsigned) ar->pleft,
(unsigned) ar->lright, (unsigned) ar->pright, (unsigned) ar->lright, (unsigned) ar->pright,
atomic_read(&ar->inode->i_writecount) ? "" : "non-"); inode_is_open_for_write(ar->inode) ? "" : "non-");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment