From: Frank van der Linden <fllinden@amazon.com>
To: <bfields@fieldses.org>, <chuck.lever@oracle.com>,
Al Viro <viro@zeniv.linux.org.uk>
Cc: <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v3 01/10] xattr: break delegations in {set,remove}xattr
Date: Thu, 25 Jun 2020 20:39:54 +0000 [thread overview]
Message-ID: <20200625203954.GA10231@dev-dsk-fllinden-2c-c1893d73.us-west-2.amazon.com> (raw)
In-Reply-To: <20200623223927.31795-2-fllinden@amazon.com>
Hi Al,
Do you have any comments / concerns about this patch? It's part of nfs
server side user xattr support, full series here:
https://lore.kernel.org/linux-nfs/20200623223927.31795-1-fllinden@amazon.com/
I copied this one to linux-fsdevel and you, just giving you an extra
ping. Bruce/Chuck are OK with the rest of the series, so I just need
your ACK on this one, and the next one (will send the ping separately).
Thanks,
- Frank
On Tue, Jun 23, 2020 at 10:39:18PM +0000, Frank van der Linden wrote:
> set/removexattr on an exported filesystem should break NFS delegations.
> This is true in general, but also for the upcoming support for
> RFC 8726 (NFSv4 extended attribute support). Make sure that they do.
>
> Additonally, they need to grow a _locked variant, since callers might
> call this with i_rwsem held (like the NFS server code).
>
> Cc: stable@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Frank van der Linden <fllinden@amazon.com>
> ---
> fs/xattr.c | 84 +++++++++++++++++++++++++++++++++++++++----
> include/linux/xattr.h | 2 ++
> 2 files changed, 79 insertions(+), 7 deletions(-)
>
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 91608d9bfc6a..95f38f57347f 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -204,10 +204,22 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
> return error;
> }
>
> -
> +/**
> + * __vfs_setxattr_locked: set an extended attribute while holding the inode
> + * lock
> + *
> + * @dentry - object to perform setxattr on
> + * @name - xattr name to set
> + * @value - value to set @name to
> + * @size - size of @value
> + * @flags - flags to pass into filesystem operations
> + * @delegated_inode - on return, will contain an inode pointer that
> + * a delegation was broken on, NULL if none.
> + */
> int
> -vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
> - size_t size, int flags)
> +__vfs_setxattr_locked(struct dentry *dentry, const char *name,
> + const void *value, size_t size, int flags,
> + struct inode **delegated_inode)
> {
> struct inode *inode = dentry->d_inode;
> int error;
> @@ -216,15 +228,40 @@ vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
> if (error)
> return error;
>
> - inode_lock(inode);
> error = security_inode_setxattr(dentry, name, value, size, flags);
> if (error)
> goto out;
>
> + error = try_break_deleg(inode, delegated_inode);
> + if (error)
> + goto out;
> +
> error = __vfs_setxattr_noperm(dentry, name, value, size, flags);
>
> out:
> + return error;
> +}
> +EXPORT_SYMBOL_GPL(__vfs_setxattr_locked);
> +
> +int
> +vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
> + size_t size, int flags)
> +{
> + struct inode *inode = dentry->d_inode;
> + struct inode *delegated_inode = NULL;
> + int error;
> +
> +retry_deleg:
> + inode_lock(inode);
> + error = __vfs_setxattr_locked(dentry, name, value, size, flags,
> + &delegated_inode);
> inode_unlock(inode);
> +
> + if (delegated_inode) {
> + error = break_deleg_wait(&delegated_inode);
> + if (!error)
> + goto retry_deleg;
> + }
> return error;
> }
> EXPORT_SYMBOL_GPL(vfs_setxattr);
> @@ -378,8 +415,18 @@ __vfs_removexattr(struct dentry *dentry, const char *name)
> }
> EXPORT_SYMBOL(__vfs_removexattr);
>
> +/**
> + * __vfs_removexattr_locked: set an extended attribute while holding the inode
> + * lock
> + *
> + * @dentry - object to perform setxattr on
> + * @name - name of xattr to remove
> + * @delegated_inode - on return, will contain an inode pointer that
> + * a delegation was broken on, NULL if none.
> + */
> int
> -vfs_removexattr(struct dentry *dentry, const char *name)
> +__vfs_removexattr_locked(struct dentry *dentry, const char *name,
> + struct inode **delegated_inode)
> {
> struct inode *inode = dentry->d_inode;
> int error;
> @@ -388,11 +435,14 @@ vfs_removexattr(struct dentry *dentry, const char *name)
> if (error)
> return error;
>
> - inode_lock(inode);
> error = security_inode_removexattr(dentry, name);
> if (error)
> goto out;
>
> + error = try_break_deleg(inode, delegated_inode);
> + if (error)
> + goto out;
> +
> error = __vfs_removexattr(dentry, name);
>
> if (!error) {
> @@ -401,12 +451,32 @@ vfs_removexattr(struct dentry *dentry, const char *name)
> }
>
> out:
> + return error;
> +}
> +EXPORT_SYMBOL_GPL(__vfs_removexattr_locked);
> +
> +int
> +vfs_removexattr(struct dentry *dentry, const char *name)
> +{
> + struct inode *inode = dentry->d_inode;
> + struct inode *delegated_inode = NULL;
> + int error;
> +
> +retry_deleg:
> + inode_lock(inode);
> + error = __vfs_removexattr_locked(dentry, name, &delegated_inode);
> inode_unlock(inode);
> +
> + if (delegated_inode) {
> + error = break_deleg_wait(&delegated_inode);
> + if (!error)
> + goto retry_deleg;
> + }
> +
> return error;
> }
> EXPORT_SYMBOL_GPL(vfs_removexattr);
>
> -
> /*
> * Extended attribute SET operations
> */
> diff --git a/include/linux/xattr.h b/include/linux/xattr.h
> index 47eaa34f8761..a2f3cd02653c 100644
> --- a/include/linux/xattr.h
> +++ b/include/linux/xattr.h
> @@ -51,8 +51,10 @@ ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
> ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
> int __vfs_setxattr(struct dentry *, struct inode *, const char *, const void *, size_t, int);
> int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
> +int __vfs_setxattr_locked(struct dentry *, const char *, const void *, size_t, int, struct inode **);
> int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
> int __vfs_removexattr(struct dentry *, const char *);
> +int __vfs_removexattr_locked(struct dentry *, const char *, struct inode **);
> int vfs_removexattr(struct dentry *, const char *);
>
> ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
> --
> 2.17.2
>
next prev parent reply other threads:[~2020-06-25 20:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200623223927.31795-1-fllinden@amazon.com>
2020-06-23 22:39 ` [PATCH v3 01/10] xattr: break delegations in {set,remove}xattr Frank van der Linden
2020-06-25 20:39 ` Frank van der Linden [this message]
2020-07-14 17:11 ` Frank van der Linden
2020-07-01 19:33 ` Sasha Levin
2020-07-10 14:03 ` Sasha Levin
2020-07-10 14:08 ` Chuck Lever
2020-06-23 22:39 ` [PATCH v3 02/10] xattr: add a function to check if a namespace is supported Frank van der Linden
2020-06-25 20:41 ` Frank van der Linden
2020-07-14 17:13 ` Frank van der Linden
2020-07-14 18:46 ` Linus Torvalds
2020-07-28 14:17 ` Chuck Lever
2020-07-28 14:33 ` Al Viro
2020-07-29 12:23 ` Chuck Lever
2020-07-04 14:37 ` [PATCH v3 00/10] server side user xattr support (RFC 8276) Chuck Lever
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=20200625203954.GA10231@dev-dsk-fllinden-2c-c1893d73.us-west-2.amazon.com \
--to=fllinden@amazon.com \
--cc=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).