Re: [PATCH v1 0/5] io_uring: add xattr support

Clay Harris
2021-12-01T07:46:28Z

On Tue, Nov 30 2021 at 22:07:47 -0800, Stefan Roesch quoth thus:

>
>
> On 11/29/21 5:08 PM, Clay Harris wrote:
> > On Mon, Nov 29 2021 at 14:12:52 -0800, Stefan Roesch quoth thus:
> >
> >> This adds the xattr support to io_uring. The intent is to have a more
> >> complete support for file operations in io_uring.
> >>
> >> This change adds support for the following functions to io_uring:
> >> - fgetxattr
> >> - fsetxattr
> >> - getxattr
> >> - setxattr
> >
> > You may wish to consider the following.
> >
> > Patching for these functions makes for an excellent opportunity
> > to provide a better interface. Rather than implement fXetattr
> > at all, you could enable io_uring to use functions like:
> >
> > int Xetxattr(int dfd, const char *path, const char *name,
> > [const] void *value, size_t size, int flags);
> >
> > Not only does this simplify the io_uring interface down to two
> > functions, but modernizes and fixes a deficit in usability.
> > In terms of io_uring, this is just changing internal interfaces.
> >
> > Although unnecessary for io_uring, it would be nice to at least
> > consider what parts of this code could be leveraged for future
> > Xetxattr2 syscalls.
>

I may have become a little over-excited when I saw someone was thinking
about new code associated with these interfaces. It's just that, to be
very kind, the existing interfaces have so much room for improvement.
I'm aware that changes in this area can be a non-trivial amount of
work, due to specific xattr keys being handled by different security
module hooks.

> Clay,
>
> while we can reduce the number of calls to 2, providing 4 calls will
> ease the adoption of the interface.

Well, there's removexattr(), but who's counting?
I believe people use the other *at() interfaces without ever looking
back at the old calls and that there is little point in io_uring reproducing
all of the old baggage.

> If you look at the userspace interface in liburing, you can see the
> following function signature:
>
> static inline void io_uring_prep_fgetxattr(struct io_uring_sqe *sqe,
> int fd,
> const char *name,
> const char *value,
> size_t len)
>
> This is very similar to what you proposed.

Even though these functions desperately need updating, and as super nice
as it would be, I don't expect you to implement getxattrat() and setxattrat().
If I were to name a single thing that would most increase the usability of
these functions, it would be:
Make the fXetxattr() functions (at least the io_uring versions)
work with an O_PATH descriptor.
That one thing would at least provide most of the desired functionality at
the cost of an extra openat() call.

>
> >
> >> Patch 1: fs: make user_path_at_empty() take a struct filename
> >> The user_path_at_empty filename parameter has been changed
> >> from a const char user pointer to a filename struct. io_uring
> >> operates on filenames.
> >> In addition also the functions that call user_path_at_empty
> >> in namei.c and stat.c have been modified for this change.
> >>
> >> Patch 2: fs: split off setxattr_setup function from setxattr
> >> Split off the setup part of the setxattr function
> >>
> >> Patch 3: fs: split off the vfs_getxattr from getxattr
> >> Split of the vfs_getxattr part from getxattr. This will
> >> allow to invoke it from io_uring.
> >>
> >> Patch 4: io_uring: add fsetxattr and setxattr support
> >> This adds new functions to support the fsetxattr and setxattr
> >> functions.
> >>
> >> Patch 5: io_uring: add fgetxattr and getxattr support
> >> This adds new functions to support the fgetxattr and getxattr
> >> functions.
> >>
> >>
> >> There are two additional patches:
> >> liburing: Add support for xattr api's.
> >> This also includes the tests for the new code.
> >> xfstests: Add support for io_uring xattr support.
> >>
> >>
> >> Stefan Roesch (5):
> >> fs: make user_path_at_empty() take a struct filename
> >> fs: split off setxattr_setup function from setxattr
> >> fs: split off the vfs_getxattr from getxattr
> >> io_uring: add fsetxattr and setxattr support
> >> io_uring: add fgetxattr and getxattr support
> >>
> >> fs/internal.h | 23 +++
> >> fs/io_uring.c | 325 ++++++++++++++++++++++++++++++++++
> >> fs/namei.c | 5 +-
> >> fs/stat.c | 7 +-
> >> fs/xattr.c | 114 +++++++-----
> >> include/linux/namei.h | 4 +-
> >> include/uapi/linux/io_uring.h | 8 +-
> >> 7 files changed, 439 insertions(+), 47 deletions(-)
> >>
> >>
> >> Signed-off-by: Stefan Roesch <shr@fb.com>
> >> base-commit: c2626d30f312afc341158e07bf088f5a23b4eeeb
> >> --
> >> 2.30.2