Skip to content

Commit b7d797d

Browse files
wangxiuhong134Jaegeuk Kim
authored andcommitted
f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks
The following f2fs_io test will get a "0" result instead of -EINVAL, unisoc # ./f2fs_io compress file unisoc # ./f2fs_io reserve_cblocks file 0 it's not reasonable, so the judgement of atomic_read(&F2FS_I(inode)->i_compr_blocks) should be placed after the judgement of is_inode_flag_set(inode, FI_COMPRESS_RELEASED). Fixes: c75488f ("f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS") Signed-off-by: Xiuhong Wang <[email protected]> Signed-off-by: Zhiguo Niu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent f238eff commit b7d797d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/f2fs/file.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,9 +3720,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
37203720
if (ret)
37213721
return ret;
37223722

3723-
if (atomic_read(&F2FS_I(inode)->i_compr_blocks))
3724-
goto out;
3725-
37263723
f2fs_balance_fs(sbi, true);
37273724

37283725
inode_lock(inode);
@@ -3732,6 +3729,9 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
37323729
goto unlock_inode;
37333730
}
37343731

3732+
if (atomic_read(&F2FS_I(inode)->i_compr_blocks))
3733+
goto unlock_inode;
3734+
37353735
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
37363736
filemap_invalidate_lock(inode->i_mapping);
37373737

@@ -3778,7 +3778,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
37783778
}
37793779
unlock_inode:
37803780
inode_unlock(inode);
3781-
out:
37823781
mnt_drop_write_file(filp);
37833782

37843783
if (ret >= 0) {

0 commit comments

Comments
 (0)