From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/3] f2fs: use generic checking function for FS_IOC_FSSETXATTR
Date: Sun, 7 Jul 2019 13:41:39 -0700 [thread overview]
Message-ID: <20190707204139.GJ1654093@magnolia> (raw)
In-Reply-To: <20190701202630.43776-3-ebiggers@kernel.org>
On Mon, Jul 01, 2019 at 01:26:29PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Make the f2fs implementation of FS_IOC_FSSETXATTR use the new VFS helper
> function vfs_ioc_fssetxattr_check(), and remove the project quota check
> since it's now done by the helper function.
>
> This is based on a patch from Darrick Wong, but reworked to apply after
> commit 360985573b55 ("f2fs: separate f2fs i_flags from fs_flags and ext4
> i_flags").
>
> Originally-from: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/f2fs/file.c | 45 ++++++++++++++-------------------------------
> 1 file changed, 14 insertions(+), 31 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index b5b941e6448657..ae1a54ecc9fccc 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2857,52 +2857,32 @@ static inline u32 f2fs_xflags_to_iflags(u32 xflags)
> return iflags;
> }
>
> -static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg)
> +static void f2fs_fill_fsxattr(struct inode *inode, struct fsxattr *fa)
> {
> - struct inode *inode = file_inode(filp);
> struct f2fs_inode_info *fi = F2FS_I(inode);
> - struct fsxattr fa;
>
> - memset(&fa, 0, sizeof(struct fsxattr));
> - fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags);
> + simple_fill_fsxattr(fa, f2fs_iflags_to_xflags(fi->i_flags));
>
> if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)))
> - fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
> - fi->i_projid);
> -
> - if (copy_to_user((struct fsxattr __user *)arg, &fa, sizeof(fa)))
> - return -EFAULT;
> - return 0;
> + fa->fsx_projid = from_kprojid(&init_user_ns, fi->i_projid);
> }
>
> -static int f2fs_ioctl_check_project(struct inode *inode, struct fsxattr *fa)
> +static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg)
> {
> - /*
> - * Project Quota ID state is only allowed to change from within the init
> - * namespace. Enforce that restriction only if we are trying to change
> - * the quota ID state. Everything else is allowed in user namespaces.
> - */
> - if (current_user_ns() == &init_user_ns)
> - return 0;
> -
> - if (__kprojid_val(F2FS_I(inode)->i_projid) != fa->fsx_projid)
> - return -EINVAL;
> + struct inode *inode = file_inode(filp);
> + struct fsxattr fa;
>
> - if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL) {
> - if (!(fa->fsx_xflags & FS_XFLAG_PROJINHERIT))
> - return -EINVAL;
> - } else {
> - if (fa->fsx_xflags & FS_XFLAG_PROJINHERIT)
> - return -EINVAL;
> - }
> + f2fs_fill_fsxattr(inode, &fa);
>
> + if (copy_to_user((struct fsxattr __user *)arg, &fa, sizeof(fa)))
> + return -EFAULT;
> return 0;
> }
>
> static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
> {
> struct inode *inode = file_inode(filp);
> - struct fsxattr fa;
> + struct fsxattr fa, old_fa;
> u32 iflags;
> int err;
>
> @@ -2925,9 +2905,12 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
> return err;
>
> inode_lock(inode);
> - err = f2fs_ioctl_check_project(inode, &fa);
> +
> + f2fs_fill_fsxattr(inode, &old_fa);
> + err = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
> if (err)
> goto out;
> +
> err = f2fs_setflags_common(inode, iflags,
> f2fs_xflags_to_iflags(F2FS_SUPPORTED_XFLAGS));
> if (err)
> --
> 2.22.0.410.gd8fdbe21b5-goog
>
next prev parent reply other threads:[~2019-07-07 20:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 20:26 [PATCH 0/3] f2fs: use generic helpers for FS_IOC_{SETFLAGS,FSSETXATTR} Eric Biggers
2019-07-01 20:26 ` [PATCH 1/3] f2fs: use generic checking and prep function for FS_IOC_SETFLAGS Eric Biggers
2019-07-03 1:58 ` Chao Yu
2019-07-07 20:41 ` Darrick J. Wong
2019-07-01 20:26 ` [PATCH 2/3] f2fs: use generic checking function for FS_IOC_FSSETXATTR Eric Biggers
2019-07-03 1:58 ` Chao Yu
2019-07-07 20:41 ` Darrick J. Wong [this message]
2019-07-01 20:26 ` [PATCH 3/3] f2fs: remove redundant check from f2fs_setflags_common() Eric Biggers
2019-07-03 1:58 ` Chao Yu
2019-07-07 20:42 ` Darrick J. Wong
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=20190707204139.GJ1654093@magnolia \
--to=darrick.wong@oracle.com \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).