f2fs: handle dqget error in f2fs_transfer_project_quota()

Message ID 20230221144550.46557-1-frank.li@vivo.com
State New
Headers
Series f2fs: handle dqget error in f2fs_transfer_project_quota() |

Commit Message

李扬韬 Feb. 21, 2023, 2:45 p.m. UTC
  We should set the error code when dqget() failed.

Fixes: 2c1d03056991 ("f2fs: support F2FS_IOC_FS{GET,SET}XATTR")
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/file.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
  

Comments

patchwork-bot+f2fs@kernel.org March 13, 2023, 8:20 p.m. UTC | #1
Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Tue, 21 Feb 2023 22:45:50 +0800 you wrote:
> We should set the error code when dqget() failed.
> 
> Fixes: 2c1d03056991 ("f2fs: support F2FS_IOC_FS{GET,SET}XATTR")
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  fs/f2fs/file.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)

Here is the summary with links:
  - [f2fs-dev] f2fs: handle dqget error in f2fs_transfer_project_quota()
    https://git.kernel.org/jaegeuk/f2fs/c/03ae2bf52a75

You are awesome, thank you!
  
Chao Yu March 23, 2023, 2:41 p.m. UTC | #2
+Shilong,

Hi, Shilong,

Could you please help to check this patch? in original patch, it tries to
ignore such error intentionally? or it is a bug?

On 2023/2/21 22:45, Yangtao Li wrote:
> We should set the error code when dqget() failed.
> 
> Fixes: 2c1d03056991 ("f2fs: support F2FS_IOC_FS{GET,SET}XATTR")
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/file.c | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ca1720fc1187..f25e58680984 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3009,15 +3009,16 @@ int f2fs_transfer_project_quota(struct inode *inode, kprojid_t kprojid)
>   	struct dquot *transfer_to[MAXQUOTAS] = {};
>   	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>   	struct super_block *sb = sbi->sb;
> -	int err = 0;
> +	int err;
>   
>   	transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
> -	if (!IS_ERR(transfer_to[PRJQUOTA])) {
> -		err = __dquot_transfer(inode, transfer_to);
> -		if (err)
> -			set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
> -		dqput(transfer_to[PRJQUOTA]);
> -	}
> +	if (IS_ERR(transfer_to[PRJQUOTA]))
> +		return PTR_ERR(transfer_to[PRJQUOTA]);
> +
> +	err = __dquot_transfer(inode, transfer_to);
> +	if (err)
> +		set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
> +	dqput(transfer_to[PRJQUOTA]);
>   	return err;
>   }
>
  

Patch

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ca1720fc1187..f25e58680984 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3009,15 +3009,16 @@  int f2fs_transfer_project_quota(struct inode *inode, kprojid_t kprojid)
 	struct dquot *transfer_to[MAXQUOTAS] = {};
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	struct super_block *sb = sbi->sb;
-	int err = 0;
+	int err;
 
 	transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
-	if (!IS_ERR(transfer_to[PRJQUOTA])) {
-		err = __dquot_transfer(inode, transfer_to);
-		if (err)
-			set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
-		dqput(transfer_to[PRJQUOTA]);
-	}
+	if (IS_ERR(transfer_to[PRJQUOTA]))
+		return PTR_ERR(transfer_to[PRJQUOTA]);
+
+	err = __dquot_transfer(inode, transfer_to);
+	if (err)
+		set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
+	dqput(transfer_to[PRJQUOTA]);
 	return err;
 }