io_uring: add fremovexattr and flistxattr support
v2 cover io_uring: add fremovexattr and flistxattr support
This series completes io_uring's FD-based xattr operations by adding support for:
- IORING_OP_FREMOVEXATTR
- IORING_OP_FLISTXATTR
This allows asynchronous xattr removal and listing. Support is restricted to FD-based operations on registered files to avoid path lookup overhead.
Corresponding test suite modifications have been integrated into the official liburing test suite (test/xattr.c) and verified to pass successfully. A corresponding liburing patch implementing these prep helpers, sanitizers, and test cases is following this kernel series.
- Patch 1 makes the necessary VFS-layer list/remove helpers non-static and declares them in fs/internal.h.
- Patch 2 implements the io_uring operational support (opcodes, opdefs, preparation, and issue handlers) and invokes these exposed helpers.
Changes since v1:
- Omit path-based opcodes to prioritize optimal FD-based variants.
- Limit exported VFS helpers to only file_listxattr and file_removexattr.
- Rewrite standalone test program into a standard liburing testcase.
Aditya Prakash Srivastava (2):
fs: make file_listxattr and file_removexattr helpers non-static
io_uring: add fremovexattr and flistxattr support
fs/internal.h | 2 + fs/xattr.c | 10 ++-- include/uapi/linux/io_uring.h | 2 + io_uring/opdef.c | 18 +++++++ io_uring/xattr.c | 74 +++++++++++++++++++++++++++++ io_uring/xattr.h | 6 +++ tools/include/uapi/linux/io_uring.h | 13 +++++ 7 files changed, 119 insertions(+), 6 deletions(-)
Signature · 1 line
2.47.3
PATCH v2 1/2 fs: make file_listxattr and file_removexattr helpers non-static
In preparation for adding IORING_OP_FREMOVEXATTR and IORING_OP_FLISTXATTR support in io_uring, we need to invoke the VFS-layer helpers from within io_uring.
Make the following helpers non-static and declare them in fs/internal.h:
- file_listxattr()
- file_removexattr()
No functional change is introduced.
--- fs/internal.h | 2 ++ fs/xattr.c | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-)
fs/internal.h +2 -0
@@ -297,6 +297,8 @@ int filename_setxattr(int dfd, struct filename *filename, unsigned int lookup_flags, struct kernel_xattr_ctx *ctx);int setxattr_copy (const char __user *name,struct kernel_xattr_ctx *ctx);int import_xattr_name (struct xattr_name *kname,const char __user *name); +ssize_t file_listxattr (struct file *f,char __user *list,size_t size); +int file_removexattr (struct file *f,struct xattr_name *kname);int may_write_xattr (struct mnt_idmap *idmap,struct inode *inode);
fs/xattr.c +4 -6
@@ -953,17 +953,15 @@ listxattr(struct dentry *d, char __user *list, size_t size)return error; } -static ssize_t file_listxattr (struct file *f,char __user *list,size_t size) {audit_file (f);return listxattr (f->f_path.dentry, list, size); } -static -ssize_t filename_listxattr (int dfd,struct filename *filename, -unsigned int lookup_flags, -char __user *list,size_t size) +static ssize_t filename_listxattr (int dfd,struct filename *filename, +unsigned int lookup_flags, +char __user *list,size_t size) {struct path path;ssize_t error;
@@ -1036,7 +1034,7 @@ removexattr(struct mnt_idmap *idmap, struct dentry *d, const char *name)return vfs_removexattr (idmap, d, name); } -static int file_removexattr (struct file *f,struct xattr_name *kname) +int file_removexattr (struct file *f,struct xattr_name *kname) {int error =mnt_want_write_file (f);
Signature · 1 line
2.47.3
Re: [PATCH v2 1/2] fs: make file_listxattr and file_removexattr helpers non-static
fs/xattr.c listxattr(struct dentry *d, char __user *list, size_t size) · line 964
Quoted 7 lines · Aditya Prakash Srivastava
fs/xattr.c +3
-4-static -ssize_t filename_listxattr (int dfd,struct filename *filename, -unsigned int lookup_flags, -char __user *list,size_t size) +static ssize_t filename_listxattr (int dfd,struct filename *filename, +unsigned int lookup_flags, +char __user *list,size_t size)
Please ignore this patch series as it has some redundant changes on top of v1, sorry about the noise. Will send a v3 by removing the redundant change.
PATCH v2 2/2 io_uring: add fremovexattr and flistxattr support
In reply to Aditya Prakash SrivastavaAdd support for IORING_OP_FREMOVEXATTR and IORING_OP_FLISTXATTR. This enables xattr listing and removal operations to be executed in an asynchronous fashion.
--- include/uapi/linux/io_uring.h | 2 + io_uring/opdef.c | 18 +++++++ io_uring/xattr.c | 74 +++++++++++++++++++++++++++++ io_uring/xattr.h | 6 +++ tools/include/uapi/linux/io_uring.h | 13 +++++ 5 files changed, 113 insertions(+)
include/uapi/linux/io_uring.h +2 -0
@@ -318,6 +318,8 @@ enum io_uring_op {IORING_OP_PIPE ,IORING_OP_NOP128 ,IORING_OP_URING_CMD128 , +IORING_OP_FREMOVEXATTR , +IORING_OP_FLISTXATTR ,/* this goes last, obviously */ IORING_OP_LAST,
io_uring/opdef.c +18 -0
@@ -591,6 +591,16 @@ const struct io_issue_def io_issue_defs[] = { .prep = io_uring_cmd_prep, .issue = io_uring_cmd, }, + [IORING_OP_FREMOVEXATTR] = { + .needs_file = 1, + .prep = io_fremovexattr_prep, + .issue = io_fremovexattr, + }, + [IORING_OP_FLISTXATTR] = { + .needs_file = 1, + .prep = io_flistxattr_prep, + .issue = io_flistxattr, + }, };const struct io_cold_def io_cold_defs[] = {
@@ -849,6 +859,14 @@ const struct io_cold_def io_cold_defs[] = { .sqe_copy = io_uring_cmd_sqe_copy, .cleanup = io_uring_cmd_cleanup, }, + [IORING_OP_FREMOVEXATTR] = { + .name = "FREMOVEXATTR", + .cleanup = io_xattr_cleanup, + }, + [IORING_OP_FLISTXATTR] = { + .name = "FLISTXATTR", + .cleanup = io_xattr_cleanup, + }, };const char *io_uring_get_opcode (u8 opcode)
io_uring/xattr.c +74 -0
77 lines not on this page · raw message
io_uring/xattr.h +6 -0
@@ -13,3 +13,9 @@ int io_fgetxattr(struct io_kiocb *req, unsigned int issue_flags);int io_getxattr_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe);int io_getxattr (struct io_kiocb *req,unsigned int issue_flags); + +int io_fremovexattr_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe); +int io_fremovexattr (struct io_kiocb *req,unsigned int issue_flags); + +int io_flistxattr_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe); +int io_flistxattr (struct io_kiocb *req,unsigned int issue_flags);
tools/include/uapi/linux/io_uring.h +13 -0
@@ -253,6 +253,19 @@ enum io_uring_op {IORING_OP_FUTEX_WAIT ,IORING_OP_FUTEX_WAKE ,IORING_OP_FUTEX_WAITV , +IORING_OP_FIXED_FD_INSTALL , +IORING_OP_FTRUNCATE , +IORING_OP_BIND , +IORING_OP_LISTEN , +IORING_OP_RECV_ZC , +IORING_OP_EPOLL_WAIT , +IORING_OP_READV_FIXED , +IORING_OP_WRITEV_FIXED , +IORING_OP_PIPE , +IORING_OP_NOP128 , +IORING_OP_URING_CMD128 , +IORING_OP_FREMOVEXATTR , +IORING_OP_FLISTXATTR ,/* this goes last, obviously */ IORING_OP_LAST,
Signature · 1 line
2.47.3