public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/2] f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks
@ 2024-03-06  3:47 Xiuhong Wang
  2024-03-06  3:47 ` [PATCH V2 2/2] f2fs: compress: fix reserve_cblocks counting error when out of space Xiuhong Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Xiuhong Wang @ 2024-03-06  3:47 UTC (permalink / raw)
  To: jaegeuk, chao, linux-f2fs-devel, linux-kernel
  Cc: hongyu.jin.cn, niuzhiguo84, ke.wang, xiuhong.wang.cn

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>
---
 fs/f2fs/file.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 4ca6c693b33a..74c5e48fce22 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3720,9 +3720,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);
@@ -3732,6 +3729,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);
 
@@ -3778,7 +3778,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) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-13  1:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06  3:47 [PATCH V2 1/2] f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks Xiuhong Wang
2024-03-06  3:47 ` [PATCH V2 2/2] f2fs: compress: fix reserve_cblocks counting error when out of space Xiuhong Wang
2024-03-06  6:01   ` Chao Yu
2024-03-06  6:01 ` [PATCH V2 1/2] f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks Chao Yu
2024-03-13  1:30 ` [f2fs-dev] " patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox