mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>
Cc: Daniel Rosenberg <drosen@google.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix wrong check on F2FS_IOC_FSSETXATTR
Date: Fri, 6 Mar 2020 09:39:03 +0800	[thread overview]
Message-ID: <1e8389fb-2416-d191-cdb3-cd4714ed7756@huawei.com> (raw)
In-Reply-To: <20200305234822.178708-1-jaegeuk@kernel.org>

On 2020/3/6 7:48, Jaegeuk Kim wrote:
> This fixes the incorrect failure when enabling project quota on casefold-enabled
> file.
> 
> Cc: Daniel Rosenberg <drosen@google.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/file.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index fb070816a8a5..8a41afac0346 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1789,12 +1789,15 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id)
>  static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
>  {
>  	struct f2fs_inode_info *fi = F2FS_I(inode);
> +	u32 masked_flags = fi->i_flags & mask;
> +
> +	f2fs_bug_on(F2FS_I_SB(inode), (iflags & ~mask));
>  
>  	/* Is it quota file? Do not allow user to mess with it */
>  	if (IS_NOQUOTA(inode))
>  		return -EPERM;
>  
> -	if ((iflags ^ fi->i_flags) & F2FS_CASEFOLD_FL) {
> +	if ((iflags ^ masked_flags) & F2FS_CASEFOLD_FL) {
>  		if (!f2fs_sb_has_casefold(F2FS_I_SB(inode)))
>  			return -EOPNOTSUPP;
>  		if (!f2fs_empty_dir(inode))
> @@ -1808,9 +1811,9 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
>  			return -EINVAL;
>  	}
>  
> -	if ((iflags ^ fi->i_flags) & F2FS_COMPR_FL) {
> +	if ((iflags ^ masked_flags) & F2FS_COMPR_FL) {
>  		if (S_ISREG(inode->i_mode) &&
> -			(fi->i_flags & F2FS_COMPR_FL || i_size_read(inode) ||
> +			(masked_flags & F2FS_COMPR_FL || i_size_read(inode) ||
>  						F2FS_HAS_BLOCKS(inode)))
>  			return -EINVAL;
>  		if (iflags & F2FS_NOCOMP_FL)
> @@ -1827,16 +1830,16 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
>  			set_compress_context(inode);
>  		}
>  	}
> -	if ((iflags ^ fi->i_flags) & F2FS_NOCOMP_FL) {
> -		if (fi->i_flags & F2FS_COMPR_FL)
> +	if ((iflags ^ masked_flags) & F2FS_NOCOMP_FL) {
> +		if (masked_flags & F2FS_COMPR_FL)
>  			return -EINVAL;
>  	}
>  
>  	fi->i_flags = iflags | (fi->i_flags & ~mask);
> -	f2fs_bug_on(F2FS_I_SB(inode), (fi->i_flags & F2FS_COMPR_FL) &&
> -					(fi->i_flags & F2FS_NOCOMP_FL));
> +	f2fs_bug_on(F2FS_I_SB(inode), (masked_flags & F2FS_COMPR_FL) &&
> +					(masked_flags & F2FS_NOCOMP_FL));

We don't need to change here due to we should check final status in fi->i_flags
rather than checking previous status in masked_flags?

>  
> -	if (fi->i_flags & F2FS_PROJINHERIT_FL)
> +	if (masked_flags & F2FS_PROJINHERIT_FL)

Ditto.

Thanks,

>  		set_inode_flag(inode, FI_PROJ_INHERIT);
>  	else
>  		clear_inode_flag(inode, FI_PROJ_INHERIT);
> 

  reply	other threads:[~2020-03-06  1:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 23:48 Jaegeuk Kim
2020-03-06  1:39 ` Chao Yu [this message]
2020-03-06  1:42 ` Daniel Rosenberg
2020-03-07  0:24 ` [PATCH v2] " Jaegeuk Kim
2020-03-09  8:24   ` [f2fs-dev] " Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1e8389fb-2416-d191-cdb3-cd4714ed7756@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=drosen@google.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®