public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Joanne Koong <joannelkoong@gmail.com>
To: miklos@szeredi.hu, axboe@kernel.dk
Cc: bschubert@ddn.com, asml.silence@gmail.com,
	io-uring@vger.kernel.org, csander@purestorage.com,
	xiaobing.li@samsung.com, linux-fsdevel@vger.kernel.org
Subject: [PATCH v1 28/30] fuse: enforce op header for every payload reply
Date: Tue,  2 Dec 2025 16:35:23 -0800	[thread overview]
Message-ID: <20251203003526.2889477-29-joannelkoong@gmail.com> (raw)
In-Reply-To: <20251203003526.2889477-1-joannelkoong@gmail.com>

In order to support fuse io-uring zero-copy, the payload and the headers
for a request/reply must reside in separate buffers since any
zero-copied payload will be transparent to the daemon but the headers
need to be accessible.

Currently, a fuse reply can be either:
* arg[0] = op header, arg[1] = payload
* arg[0] = payload
* arg[0] = NULL

Fuse io-uring needs to differentiate between the first two for copying
to/from the ring.

Enforce that all fuse replies that have a payload also have an op
header. If there is is only a payload to send in the reply, then the
header will be a zero-size no-op header.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
 fs/fuse/dir.c     |  5 +++--
 fs/fuse/file.c    | 11 ++++++-----
 fs/fuse/fuse_i.h  |  6 ++++++
 fs/fuse/readdir.c |  2 +-
 fs/fuse/xattr.c   | 16 ++++++++++------
 5 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index b79be8bbbaf8..238fa1bab3c9 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1630,8 +1630,9 @@ static int fuse_readlink_folio(struct inode *inode, struct folio *folio)
 	ap.args.out_pages = true;
 	ap.args.out_argvar = true;
 	ap.args.page_zeroing = true;
-	ap.args.out_numargs = 1;
-	ap.args.out_args[0].size = desc.length;
+	ap.args.out_numargs = 2;
+	fuse_zero_out_arg0(&ap.args);
+	ap.args.out_args[1].size = desc.length;
 	res = fuse_simple_request(fm, &ap.args);
 
 	fuse_invalidate_atime(inode);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f1ef77a0be05..ff6c287bc4ed 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -581,8 +581,9 @@ void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
 	args->in_args[0].size = sizeof(ia->read.in);
 	args->in_args[0].value = &ia->read.in;
 	args->out_argvar = true;
-	args->out_numargs = 1;
-	args->out_args[0].size = count;
+	args->out_numargs = 2;
+	fuse_zero_out_arg0(args);
+	args->out_args[1].size = count;
 }
 
 static void fuse_release_user_pages(struct fuse_args_pages *ap, ssize_t nres,
@@ -711,7 +712,7 @@ static void fuse_aio_complete_req(struct fuse_mount *fm, struct fuse_args *args,
 				      ia->write.out.size;
 		}
 	} else {
-		u32 outsize = args->out_args[0].size;
+		u32 outsize = args->out_args[1].size;
 
 		nres = outsize;
 		if (ia->read.in.size != outsize)
@@ -870,7 +871,7 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args,
 	struct fuse_io_args *ia = container_of(args, typeof(*ia), ap.args);
 	struct fuse_args_pages *ap = &ia->ap;
 	size_t count = ia->read.in.size;
-	size_t num_read = args->out_args[0].size;
+	size_t num_read = args->out_args[1].size;
 	struct address_space *mapping;
 	struct inode *inode;
 
@@ -1506,7 +1507,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
 			if (write)
 				ap->args.in_args[1].value = user_addr;
 			else
-				ap->args.out_args[0].value = user_addr;
+				ap->args.out_args[1].value = user_addr;
 
 			iov_iter_advance(ii, frag_size);
 			*nbytesp = frag_size;
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 34541801d950..e45126d792a6 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1026,6 +1026,12 @@ static inline void fuse_zero_in_arg0(struct fuse_args *args)
 	args->in_args[0].value = NULL;
 }
 
+static inline void fuse_zero_out_arg0(struct fuse_args *args)
+{
+	args->out_args[0].size = sizeof(struct fuse_zero_header);
+	args->out_args[0].value = NULL;
+}
+
 static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb)
 {
 	return sb->s_fs_info;
diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c
index c2aae2eef086..d80cd2bedabe 100644
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -349,7 +349,7 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx)
 	if (!buf)
 		return -ENOMEM;
 
-	args->out_args[0].value = buf;
+	args->out_args[1].value = buf;
 
 	plus = fuse_use_readdirplus(inode, ctx);
 	if (plus) {
diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c
index aa0881162287..4011a99abd52 100644
--- a/fs/fuse/xattr.c
+++ b/fs/fuse/xattr.c
@@ -70,12 +70,14 @@ ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
 	args.in_args[1].size = strlen(name) + 1;
 	args.in_args[1].value = name;
 	/* This is really two different operations rolled into one */
-	args.out_numargs = 1;
 	if (size) {
 		args.out_argvar = true;
-		args.out_args[0].size = size;
-		args.out_args[0].value = value;
+		args.out_numargs = 2;
+		fuse_zero_out_arg0(&args);
+		args.out_args[1].size = size;
+		args.out_args[1].value = value;
 	} else {
+		args.out_numargs = 1;
 		args.out_args[0].size = sizeof(outarg);
 		args.out_args[0].value = &outarg;
 	}
@@ -132,12 +134,14 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
 	args.in_args[0].size = sizeof(inarg);
 	args.in_args[0].value = &inarg;
 	/* This is really two different operations rolled into one */
-	args.out_numargs = 1;
 	if (size) {
 		args.out_argvar = true;
-		args.out_args[0].size = size;
-		args.out_args[0].value = list;
+		args.out_numargs = 2;
+		fuse_zero_out_arg0(&args);
+		args.out_args[1].size = size;
+		args.out_args[1].value = list;
 	} else {
+		args.out_numargs = 1;
 		args.out_args[0].size = sizeof(outarg);
 		args.out_args[0].value = &outarg;
 	}
-- 
2.47.3


  parent reply	other threads:[~2025-12-03  0:37 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03  0:34 [PATCH v1 00/30] fuse/io-uring: add kernel-managed buffer rings and zero-copy Joanne Koong
2025-12-03  0:34 ` [PATCH v1 01/30] io_uring/kbuf: refactor io_buf_pbuf_register() logic into generic helpers Joanne Koong
2025-12-03  0:34 ` [PATCH v1 02/30] io_uring/kbuf: rename io_unregister_pbuf_ring() to io_unregister_buf_ring() Joanne Koong
2025-12-03  0:34 ` [PATCH v1 03/30] io_uring/kbuf: add support for kernel-managed buffer rings Joanne Koong
2025-12-03  0:34 ` [PATCH v1 04/30] io_uring/kbuf: add mmap " Joanne Koong
2025-12-03  0:35 ` [PATCH v1 05/30] io_uring/kbuf: support kernel-managed buffer rings in buffer selection Joanne Koong
2025-12-03  0:35 ` [PATCH v1 06/30] io_uring/kbuf: add buffer ring pinning/unpinning Joanne Koong
2025-12-03  4:13   ` Caleb Sander Mateos
2025-12-04 18:41     ` Joanne Koong
2025-12-03  0:35 ` [PATCH v1 07/30] io_uring/rsrc: add fixed buffer table pinning/unpinning Joanne Koong
2025-12-03  4:49   ` Caleb Sander Mateos
2025-12-03 22:52     ` Joanne Koong
2025-12-04  1:24       ` Caleb Sander Mateos
2025-12-04 20:07         ` Joanne Koong
2025-12-10  3:35           ` Caleb Sander Mateos
2025-12-13  6:07             ` Joanne Koong
2025-12-03  0:35 ` [PATCH v1 08/30] io_uring/kbuf: add recycling for pinned kernel managed buffer rings Joanne Koong
2025-12-03  0:35 ` [PATCH v1 09/30] io_uring: add io_uring_cmd_import_fixed_index() Joanne Koong
2025-12-03 21:43   ` Caleb Sander Mateos
2025-12-04 18:56     ` Joanne Koong
2025-12-05 16:56       ` Caleb Sander Mateos
2025-12-05 23:28         ` Joanne Koong
2025-12-11  2:57           ` Caleb Sander Mateos
2025-12-03  0:35 ` [PATCH v1 10/30] io_uring/kbuf: add io_uring_is_kmbuf_ring() Joanne Koong
2025-12-03  0:35 ` [PATCH v1 11/30] io_uring/kbuf: return buffer id in buffer selection Joanne Koong
2025-12-03 21:53   ` Caleb Sander Mateos
2025-12-04 19:22     ` Joanne Koong
2025-12-04 21:57       ` Caleb Sander Mateos
2025-12-03  0:35 ` [PATCH v1 12/30] io_uring/kbuf: export io_ring_buffer_select() Joanne Koong
2025-12-03  0:35 ` [PATCH v1 13/30] io_uring/cmd: set selected buffer index in __io_uring_cmd_done() Joanne Koong
2025-12-03  0:35 ` [PATCH v1 14/30] io_uring: add release callback for ring death Joanne Koong
2025-12-03 22:25   ` Caleb Sander Mateos
2025-12-03 22:54     ` Joanne Koong
2025-12-03  0:35 ` [PATCH v1 15/30] fuse: refactor io-uring logic for getting next fuse request Joanne Koong
2025-12-03  0:35 ` [PATCH v1 16/30] fuse: refactor io-uring header copying to ring Joanne Koong
2025-12-03  0:35 ` [PATCH v1 17/30] fuse: refactor io-uring header copying from ring Joanne Koong
2025-12-03  0:35 ` [PATCH v1 18/30] fuse: use enum types for header copying Joanne Koong
2025-12-03  0:35 ` [PATCH v1 19/30] fuse: refactor setting up copy state for payload copying Joanne Koong
2025-12-03  0:35 ` [PATCH v1 20/30] fuse: support buffer copying for kernel addresses Joanne Koong
2025-12-03  0:35 ` [PATCH v1 21/30] fuse: add io-uring kernel-managed buffer ring Joanne Koong
2025-12-03  0:35 ` [PATCH v1 22/30] io_uring/rsrc: refactor io_buffer_register_bvec()/io_buffer_unregister_bvec() Joanne Koong
2025-12-07  8:33   ` Caleb Sander Mateos
2025-12-13  5:11     ` Joanne Koong
2025-12-16  3:07       ` Caleb Sander Mateos
2025-12-03  0:35 ` [PATCH v1 23/30] io_uring/rsrc: split io_buffer_register_request() logic Joanne Koong
2025-12-07  8:41   ` Caleb Sander Mateos
2025-12-13  5:24     ` Joanne Koong
2025-12-15 17:09       ` Caleb Sander Mateos
2025-12-03  0:35 ` [PATCH v1 24/30] io_uring/rsrc: Allow buffer release callback to be optional Joanne Koong
2025-12-07  8:42   ` Caleb Sander Mateos
2025-12-03  0:35 ` [PATCH v1 25/30] io_uring/rsrc: add io_buffer_register_bvec() Joanne Koong
2025-12-03  0:35 ` [PATCH v1 26/30] io_uring/rsrc: export io_buffer_unregister Joanne Koong
2025-12-03  0:35 ` [PATCH v1 27/30] fuse: rename fuse_set_zero_arg0() to fuse_zero_in_arg0() Joanne Koong
2025-12-03  0:35 ` Joanne Koong [this message]
2025-12-03  0:35 ` [PATCH v1 29/30] fuse: add zero-copy over io-uring Joanne Koong
2025-12-03  0:35 ` [PATCH v1 30/30] docs: fuse: add io-uring bufring and zero-copy documentation Joanne Koong
2025-12-13  7:52   ` Askar Safin
2025-12-15  3:18     ` Joanne Koong
2025-12-13  9:14 ` [PATCH v1 00/30] fuse/io-uring: add kernel-managed buffer rings and zero-copy Askar Safin
2025-12-15  3:24   ` Joanne Koong

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=20251203003526.2889477-29-joannelkoong@gmail.com \
    --to=joannelkoong@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bschubert@ddn.com \
    --cc=csander@purestorage.com \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=xiaobing.li@samsung.com \
    /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