2023-05-09 10:04:53

by 李扬韬

[permalink] [raw]
Subject: [PATCH 1/4] f2fs: convert to use sbi directly

F2FS_I_SB(inode) is redundant.

Signed-off-by: Yangtao Li <[email protected]>
---
fs/f2fs/file.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 0dbbcb406d3f..6f8936ec689c 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3466,7 +3466,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
int ret;
int writecount;

- if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
+ if (!f2fs_sb_has_compression(sbi))
return -EOPNOTSUPP;

if (!f2fs_compressed_file(inode))
@@ -3479,7 +3479,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
if (ret)
return ret;

- f2fs_balance_fs(F2FS_I_SB(inode), true);
+ f2fs_balance_fs(sbi, true);

inode_lock(inode);

@@ -3636,7 +3636,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
unsigned int reserved_blocks = 0;
int ret;

- if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
+ if (!f2fs_sb_has_compression(sbi))
return -EOPNOTSUPP;

if (!f2fs_compressed_file(inode))
@@ -3652,7 +3652,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
if (atomic_read(&F2FS_I(inode)->i_compr_blocks))
goto out;

- f2fs_balance_fs(F2FS_I_SB(inode), true);
+ f2fs_balance_fs(sbi, true);

inode_lock(inode);

@@ -4046,7 +4046,7 @@ static int f2fs_ioc_decompress_file(struct file *filp)
if (!f2fs_compressed_file(inode))
return -EINVAL;

- f2fs_balance_fs(F2FS_I_SB(inode), true);
+ f2fs_balance_fs(sbi, true);

file_start_write(filp);
inode_lock(inode);
@@ -4121,7 +4121,7 @@ static int f2fs_ioc_compress_file(struct file *filp)
if (!f2fs_compressed_file(inode))
return -EINVAL;

- f2fs_balance_fs(F2FS_I_SB(inode), true);
+ f2fs_balance_fs(sbi, true);

file_start_write(filp);
inode_lock(inode);
--
2.39.0


2023-05-09 10:06:24

by 李扬韬

[permalink] [raw]
Subject: [PATCH 3/4] f2fs: move the conditional statement to hold the inode lock in f2fs_release_compress_blocks()

For judging the inode flag state, the inode lock must be held.

Fixes: ef8d563f184e ("f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS")
Signed-off-by: Yangtao Li <[email protected]>
---
fs/f2fs/file.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index a6180d4d94cb..32dc9a250a36 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3469,9 +3469,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
if (!f2fs_sb_has_compression(sbi))
return -EOPNOTSUPP;

- if (!f2fs_compressed_file(inode))
- return -EINVAL;
-
if (f2fs_readonly(sbi->sb))
return -EROFS;

@@ -3483,6 +3480,11 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)

inode_lock(inode);

+ if (!f2fs_compressed_file(inode)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
writecount = atomic_read(&inode->i_writecount);
if ((filp->f_mode & FMODE_WRITE && writecount != 1) ||
(!(filp->f_mode & FMODE_WRITE) && writecount)) {
--
2.39.0

2023-06-22 07:36:09

by patchwork-bot+f2fs

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH 1/4] f2fs: convert to use sbi directly

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

On Tue, 9 May 2023 17:57:03 +0800 you wrote:
> F2FS_I_SB(inode) is redundant.
>
> Signed-off-by: Yangtao Li <[email protected]>
> ---
> fs/f2fs/file.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)

Here is the summary with links:
- [f2fs-dev,1/4] f2fs: convert to use sbi directly
https://git.kernel.org/jaegeuk/f2fs/c/08f83cb23a3e
- [f2fs-dev,2/4] f2fs: move the conditional statement to hold the inode lock in f2fs_ioc_decompress_file() and f2fs_ioc_compress_file()
(no matching commit)
- [f2fs-dev,3/4] f2fs: move the conditional statement to hold the inode lock in f2fs_release_compress_blocks()
(no matching commit)
- [f2fs-dev,4/4] f2fs: move the conditional statement to hold the inode lock in f2fs_reserve_compress_blocks()
(no matching commit)

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html