summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorXiuhong Wang <xiuhong.wang@unisoc.com>2024-03-06 06:47:45 +0300
committerSasha Levin <sashal@kernel.org>2024-03-27 01:17:26 +0300
commitbd164c8f4f842bdc7fcb5caaeef42f8f5e9f04a4 (patch)
treeef04d3007aa6362a749d1740afbf2d6ba65435af /fs/f2fs
parent4cad8b81ea56fb80278630d2a82529db26c598f3 (diff)
downloadlinux-bd164c8f4f842bdc7fcb5caaeef42f8f5e9f04a4.tar.xz
f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks
[ Upstream commit b7d797d241c154d73ec5523f87f3b06d4f299da1 ] 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: c75488fb4d82 ("f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS") Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/file.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index caab20648b95..3da9a298c50a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3684,9 +3684,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
if (ret)
return ret;
- if (atomic_read(&F2FS_I(inode)->i_compr_blocks))
- goto out;
-
f2fs_balance_fs(sbi, true);
inode_lock(inode);
@@ -3696,6 +3693,9 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
goto unlock_inode;
}
+ if (atomic_read(&F2FS_I(inode)->i_compr_blocks))
+ goto unlock_inode;
+
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(inode->i_mapping);
@@ -3742,7 +3742,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
}
unlock_inode:
inode_unlock(inode);
-out:
mnt_drop_write_file(filp);
if (ret >= 0) {