summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2019-02-10 23:04:16 -0500
committerTheodore Ts'o <tytso@mit.edu>2019-02-10 23:04:16 -0500
commit82dd124c40b8cda710878b88fb0182301c040ffe (patch)
treeef381c696fc85b6d9c3cf555ca5d6a236c6e39de
parent53cf978457325d8fb2cdecd7981b31a8229e446e (diff)
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: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/ext4/mballoc.c7
2 files changed, 4 insertions, 5 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 34d7e0703cc6..213d1857a7cf 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
391 * inode's preallocations. 391 * inode's preallocations.
392 */ 392 */
393 if ((ei->i_reserved_data_blocks == 0) && 393 if ((ei->i_reserved_data_blocks == 0) &&
394 (atomic_read(&inode->i_writecount) == 0)) 394 !inode_is_open_for_write(inode))
395 ext4_discard_preallocations(inode); 395 ext4_discard_preallocations(inode);
396} 396}
397 397
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index e2248083cdca..6fb76d408093 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4176,9 +4176,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
4176 isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1) 4176 isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1)
4177 >> bsbits; 4177 >> bsbits;
4178 4178
4179 if ((size == isize) && 4179 if ((size == isize) && !ext4_fs_is_busy(sbi) &&
4180 !ext4_fs_is_busy(sbi) && 4180 !inode_is_open_for_write(ac->ac_inode)) {
4181 (atomic_read(&ac->ac_inode->i_writecount) == 0)) {
4182 ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC; 4181 ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
4183 return; 4182 return;
4184 } 4183 }
@@ -4258,7 +4257,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
4258 (unsigned) ar->goal, ac->ac_flags, ac->ac_2order, 4257 (unsigned) ar->goal, ac->ac_flags, ac->ac_2order,
4259 (unsigned) ar->lleft, (unsigned) ar->pleft, 4258 (unsigned) ar->lleft, (unsigned) ar->pleft,
4260 (unsigned) ar->lright, (unsigned) ar->pright, 4259 (unsigned) ar->lright, (unsigned) ar->pright,
4261 atomic_read(&ar->inode->i_writecount) ? "" : "non-"); 4260 inode_is_open_for_write(ar->inode) ? "" : "non-");
4262 return 0; 4261 return 0;
4263 4262
4264} 4263}