From d52ae4f9d44d7e08375bfacac0bc7cc02ad1b54b Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Wed, 28 May 2025 15:13:47 +0200 Subject: Allow applications to retrieve the req payload (io-uring only) With io-uring the req owns the payload buffer, the application can directly access it and copy data into it. fuse_buf_copy_one() already has a check for dstmem == srcmem and skips data copies. fuse_reply_data fuse_reply_data_uring fuse_buf_copy fuse_buf_copy_one Signed-off-by: Bernd Schubert --- lib/fuse_lowlevel.c | 12 ++++++++++++ lib/fuse_uring.c | 24 ++++++++++++++++++++++++ lib/fuse_versionscript | 1 + 3 files changed, 37 insertions(+) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 6afcecd..e4544df 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -3317,6 +3317,18 @@ bool fuse_req_is_uring(fuse_req_t req) return req->is_uring; } +#ifndef HAVE_URING +int fuse_req_get_payload(fuse_req_t req, char **payload, size_t *payload_sz, + void **mr) +{ + (void)req; + (void)payload; + (void)payload_sz; + (void)mr; + return -ENOTSUP; +} +#endif + static struct { void (*func)(fuse_req_t req, const fuse_ino_t node, const void *arg); const char *name; diff --git a/lib/fuse_uring.c b/lib/fuse_uring.c index 104be14..ee68fab 100644 --- a/lib/fuse_uring.c +++ b/lib/fuse_uring.c @@ -190,6 +190,30 @@ static int fuse_uring_commit_sqe(struct fuse_ring_pool *ring_pool, return 0; } +int fuse_req_get_payload(fuse_req_t req, char **payload, size_t *payload_sz, + void **mr) +{ + struct fuse_ring_ent *ring_ent; + + /* Not possible without io-uring interface */ + if (!req->is_uring) + return -EINVAL; + + ring_ent = container_of(req, struct fuse_ring_ent, req); + + *payload = ring_ent->op_payload; + *payload_sz = ring_ent->req_payload_sz; + + /* + * For now unused, but will be used later when the application can + * allocate the buffers itself and register them for rdma. + */ + if (mr) + *mr = NULL; + + return 0; +} + int send_reply_uring(fuse_req_t req, int error, const void *arg, size_t argsize) { int res; diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript index 0e581f1..2feafcf 100644 --- a/lib/fuse_versionscript +++ b/lib/fuse_versionscript @@ -205,6 +205,7 @@ FUSE_3.17 { FUSE_3.18 { global: fuse_req_is_uring; + fuse_req_get_payload; fuse_set_feature_flag; fuse_unset_feature_flag; fuse_get_feature_flag; -- cgit v1.2.3