* [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec
@ 2025-03-19 6:12 Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 1/5] io_uring: rename the data cmd cache Sidong Yang
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Sidong Yang @ 2025-03-19 6:12 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Jens Axboe, Pavel Begunkov
Cc: linux-btrfs, linux-kernel, io-uring, Sidong Yang
This patche series introduce io_uring_cmd_import_vec. With this function,
Multiple fixed buffer could be used in uring cmd. It's vectored version
for io_uring_cmd_import_fixed(). Also this patch series includes a usage
for new api for encoded read/write in btrfs by using uring cmd.
There was approximately 10 percent of performance improvements through benchmark.
The benchmark code is in
https://github.com/SidongYang/btrfs-encoded-io-test/blob/main/main.c
./main -l
Elapsed time: 0.598997 seconds
./main -l -f
Elapsed time: 0.540332 seconds
Additionally, There is a commit that fixed a memory bug in btrfs uring encoded
read.
v2:
- don't export iou_vc, use bvec for btrfs
- use io_is_compat for checking compat
- reduce allocation/free for import fixed vec
v3:
- add iou_vec cache in io_uring_cmd and use it
- also encoded write fixed supported
v4:
- add a patch that introduce io_async_cmd
- add a patch that fixes a bug in btrfs encoded read
v5:
- use Pavel's original patches rebased for axboe/for-6.15/io_uring-reg-vec
- pop a patch that fixes btrfs encoded read
Pavel Begunkov (4):
io_uring: rename the data cmd cache
io_uring/cmd: don't expose entire cmd async data
io_uring/cmd: add iovec cache for commands
io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
Sidong Yang (1):
btrfs: ioctl: introduce btrfs_uring_import_iovec()
fs/btrfs/ioctl.c | 34 ++++++++++++++------
include/linux/io_uring/cmd.h | 13 ++++++++
include/linux/io_uring_types.h | 2 +-
io_uring/io_uring.c | 6 ++--
io_uring/opdef.c | 3 +-
io_uring/uring_cmd.c | 59 +++++++++++++++++++++++++++++-----
io_uring/uring_cmd.h | 17 ++++++++++
7 files changed, 112 insertions(+), 22 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH v5 1/5] io_uring: rename the data cmd cache
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
@ 2025-03-19 6:12 ` Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 2/5] io_uring/cmd: don't expose entire cmd async data Sidong Yang
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Sidong Yang @ 2025-03-19 6:12 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Jens Axboe, Pavel Begunkov
Cc: linux-btrfs, linux-kernel, io-uring
From: Pavel Begunkov <[email protected]>
Pick a more descriptive name for the cmd async data cache.
Signed-off-by: Pavel Begunkov <[email protected]>
---
include/linux/io_uring_types.h | 2 +-
io_uring/io_uring.c | 4 ++--
io_uring/uring_cmd.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index 0e87e292bfb5..c17d2eedf478 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -318,7 +318,7 @@ struct io_ring_ctx {
struct io_alloc_cache apoll_cache;
struct io_alloc_cache netmsg_cache;
struct io_alloc_cache rw_cache;
- struct io_alloc_cache uring_cache;
+ struct io_alloc_cache cmd_cache;
/*
* Any cancelable uring_cmd is added to this list in
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 5ff30a7092ed..7f26ad334e30 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -289,7 +289,7 @@ static void io_free_alloc_caches(struct io_ring_ctx *ctx)
io_alloc_cache_free(&ctx->apoll_cache, kfree);
io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free);
io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free);
- io_alloc_cache_free(&ctx->uring_cache, kfree);
+ io_alloc_cache_free(&ctx->cmd_cache, kfree);
io_alloc_cache_free(&ctx->msg_cache, kfree);
io_futex_cache_free(ctx);
io_rsrc_cache_free(ctx);
@@ -334,7 +334,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
ret |= io_alloc_cache_init(&ctx->rw_cache, IO_ALLOC_CACHE_MAX,
sizeof(struct io_async_rw),
offsetof(struct io_async_rw, clear));
- ret |= io_alloc_cache_init(&ctx->uring_cache, IO_ALLOC_CACHE_MAX,
+ ret |= io_alloc_cache_init(&ctx->cmd_cache, IO_ALLOC_CACHE_MAX,
sizeof(struct io_uring_cmd_data), 0);
spin_lock_init(&ctx->msg_lock);
ret |= io_alloc_cache_init(&ctx->msg_cache, IO_ALLOC_CACHE_MAX,
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index de39b602aa82..792bd54851b1 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -28,7 +28,7 @@ static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
if (issue_flags & IO_URING_F_UNLOCKED)
return;
- if (io_alloc_cache_put(&req->ctx->uring_cache, cache)) {
+ if (io_alloc_cache_put(&req->ctx->cmd_cache, cache)) {
ioucmd->sqe = NULL;
req->async_data = NULL;
req->flags &= ~REQ_F_ASYNC_DATA;
@@ -171,7 +171,7 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req,
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
struct io_uring_cmd_data *cache;
- cache = io_uring_alloc_async_data(&req->ctx->uring_cache, req);
+ cache = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
if (!cache)
return -ENOMEM;
cache->op_data = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v5 2/5] io_uring/cmd: don't expose entire cmd async data
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 1/5] io_uring: rename the data cmd cache Sidong Yang
@ 2025-03-19 6:12 ` Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 3/5] io_uring/cmd: add iovec cache for commands Sidong Yang
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Sidong Yang @ 2025-03-19 6:12 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Jens Axboe, Pavel Begunkov
Cc: linux-btrfs, linux-kernel, io-uring
From: Pavel Begunkov <[email protected]>
io_uring needs private bits in cmd's ->async_data, and they should never
be exposed to drivers as it'd certainly be abused. Leave struct
io_uring_cmd_data for the drivers but wrap it into a structure. It's a
prep patch and doesn't do anything useful yet.
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/io_uring.c | 2 +-
io_uring/opdef.c | 2 +-
io_uring/uring_cmd.c | 18 +++++++++++-------
io_uring/uring_cmd.h | 6 ++++++
4 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 7f26ad334e30..5eb9be063a7c 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -335,7 +335,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
sizeof(struct io_async_rw),
offsetof(struct io_async_rw, clear));
ret |= io_alloc_cache_init(&ctx->cmd_cache, IO_ALLOC_CACHE_MAX,
- sizeof(struct io_uring_cmd_data), 0);
+ sizeof(struct io_async_cmd), 0);
spin_lock_init(&ctx->msg_lock);
ret |= io_alloc_cache_init(&ctx->msg_cache, IO_ALLOC_CACHE_MAX,
sizeof(struct io_kiocb), 0);
diff --git a/io_uring/opdef.c b/io_uring/opdef.c
index 7fd173197b1e..e4aa61a414fb 100644
--- a/io_uring/opdef.c
+++ b/io_uring/opdef.c
@@ -416,7 +416,7 @@ const struct io_issue_def io_issue_defs[] = {
.plug = 1,
.iopoll = 1,
.iopoll_queue = 1,
- .async_size = sizeof(struct io_uring_cmd_data),
+ .async_size = sizeof(struct io_async_cmd),
.prep = io_uring_cmd_prep,
.issue = io_uring_cmd,
},
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index 792bd54851b1..7c126ee497ea 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -19,7 +19,8 @@
static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
- struct io_uring_cmd_data *cache = req->async_data;
+ struct io_async_cmd *ac = req->async_data;
+ struct io_uring_cmd_data *cache = &ac->data;
if (cache->op_data) {
kfree(cache->op_data);
@@ -169,12 +170,15 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req,
const struct io_uring_sqe *sqe)
{
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
- struct io_uring_cmd_data *cache;
+ struct io_async_cmd *ac;
- cache = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
- if (!cache)
+ /* see io_uring_cmd_get_async_data() */
+ BUILD_BUG_ON(offsetof(struct io_async_cmd, data) != 0);
+
+ ac = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
+ if (!ac)
return -ENOMEM;
- cache->op_data = NULL;
+ ac->data.op_data = NULL;
/*
* Unconditionally cache the SQE for now - this is only needed for
@@ -183,8 +187,8 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req,
* that it doesn't read in per-op data, play it safe and ensure that
* any SQE data is stable beyond prep. This can later get relaxed.
*/
- memcpy(cache->sqes, sqe, uring_sqe_size(req->ctx));
- ioucmd->sqe = cache->sqes;
+ memcpy(ac->data.sqes, sqe, uring_sqe_size(req->ctx));
+ ioucmd->sqe = ac->data.sqes;
return 0;
}
diff --git a/io_uring/uring_cmd.h b/io_uring/uring_cmd.h
index f6837ee0955b..2ec3a8785534 100644
--- a/io_uring/uring_cmd.h
+++ b/io_uring/uring_cmd.h
@@ -1,5 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/io_uring/cmd.h>
+
+struct io_async_cmd {
+ struct io_uring_cmd_data data;
+};
+
int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags);
int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v5 3/5] io_uring/cmd: add iovec cache for commands
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 1/5] io_uring: rename the data cmd cache Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 2/5] io_uring/cmd: don't expose entire cmd async data Sidong Yang
@ 2025-03-19 6:12 ` Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec Sidong Yang
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Sidong Yang @ 2025-03-19 6:12 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Jens Axboe, Pavel Begunkov
Cc: linux-btrfs, linux-kernel, io-uring
From: Pavel Begunkov <[email protected]>
Add iou_vec to commands and wire caching for it, but don't expose it to
users just yet.
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/io_uring.c | 2 +-
io_uring/opdef.c | 1 +
io_uring/uring_cmd.c | 20 ++++++++++++++++++++
io_uring/uring_cmd.h | 5 +++++
4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 5eb9be063a7c..8ef93ce4a539 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -289,7 +289,7 @@ static void io_free_alloc_caches(struct io_ring_ctx *ctx)
io_alloc_cache_free(&ctx->apoll_cache, kfree);
io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free);
io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free);
- io_alloc_cache_free(&ctx->cmd_cache, kfree);
+ io_alloc_cache_free(&ctx->cmd_cache, io_cmd_cache_free);
io_alloc_cache_free(&ctx->msg_cache, kfree);
io_futex_cache_free(ctx);
io_rsrc_cache_free(ctx);
diff --git a/io_uring/opdef.c b/io_uring/opdef.c
index e4aa61a414fb..489384c0438b 100644
--- a/io_uring/opdef.c
+++ b/io_uring/opdef.c
@@ -755,6 +755,7 @@ const struct io_cold_def io_cold_defs[] = {
},
[IORING_OP_URING_CMD] = {
.name = "URING_CMD",
+ .cleanup = io_uring_cmd_cleanup,
},
[IORING_OP_SEND_ZC] = {
.name = "SEND_ZC",
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index 7c126ee497ea..abcc1ad236ef 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -16,6 +16,14 @@
#include "rsrc.h"
#include "uring_cmd.h"
+void io_cmd_cache_free(const void *entry)
+{
+ struct io_async_cmd *ac = (struct io_async_cmd *)entry;
+
+ io_vec_free(&ac->vec);
+ kfree(ac);
+}
+
static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
@@ -29,6 +37,13 @@ static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
if (issue_flags & IO_URING_F_UNLOCKED)
return;
+
+ req->flags &= ~REQ_F_NEED_CLEANUP;
+
+ io_alloc_cache_vec_kasan(&ac->vec);
+ if (ac->vec.nr > IO_VEC_CACHE_SOFT_CAP)
+ io_vec_free(&ac->vec);
+
if (io_alloc_cache_put(&req->ctx->cmd_cache, cache)) {
ioucmd->sqe = NULL;
req->async_data = NULL;
@@ -36,6 +51,11 @@ static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
}
}
+void io_uring_cmd_cleanup(struct io_kiocb *req)
+{
+ io_req_uring_cleanup(req, 0);
+}
+
bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx,
struct io_uring_task *tctx, bool cancel_all)
{
diff --git a/io_uring/uring_cmd.h b/io_uring/uring_cmd.h
index 2ec3a8785534..b45ec7cffcd1 100644
--- a/io_uring/uring_cmd.h
+++ b/io_uring/uring_cmd.h
@@ -1,13 +1,18 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/io_uring/cmd.h>
+#include <linux/io_uring_types.h>
struct io_async_cmd {
struct io_uring_cmd_data data;
+ struct iou_vec vec;
};
int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags);
int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+void io_uring_cmd_cleanup(struct io_kiocb *req);
bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx,
struct io_uring_task *tctx, bool cancel_all);
+
+void io_cmd_cache_free(const void *entry);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v5 4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
` (2 preceding siblings ...)
2025-03-19 6:12 ` [RFC PATCH v5 3/5] io_uring/cmd: add iovec cache for commands Sidong Yang
@ 2025-03-19 6:12 ` Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 5/5] btrfs: ioctl: introduce btrfs_uring_import_iovec() Sidong Yang
2025-03-19 15:26 ` (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Jens Axboe
5 siblings, 0 replies; 10+ messages in thread
From: Sidong Yang @ 2025-03-19 6:12 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Jens Axboe, Pavel Begunkov
Cc: linux-btrfs, linux-kernel, io-uring
From: Pavel Begunkov <[email protected]>
io_uring_cmd_import_fixed_vec() is a cmd helper around vectored
registered buffer import functions, which caches the memory under
the hood. The lifetime of the vectore and hence the iterator is bound to
the request. Furthermore, the user is not allowed to call it multiple
times for a single request.
Signed-off-by: Pavel Begunkov <[email protected]>
---
include/linux/io_uring/cmd.h | 13 +++++++++++++
io_uring/uring_cmd.c | 19 +++++++++++++++++++
io_uring/uring_cmd.h | 6 ++++++
3 files changed, 38 insertions(+)
diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h
index 598cacda4aa3..e6723fa95160 100644
--- a/include/linux/io_uring/cmd.h
+++ b/include/linux/io_uring/cmd.h
@@ -43,6 +43,11 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
struct iov_iter *iter,
struct io_uring_cmd *ioucmd,
unsigned int issue_flags);
+int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
+ const struct iovec __user *uvec,
+ size_t uvec_segs,
+ int ddir, struct iov_iter *iter,
+ unsigned issue_flags);
/*
* Completes the request, i.e. posts an io_uring CQE and deallocates @ioucmd
@@ -76,6 +81,14 @@ io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
{
return -EOPNOTSUPP;
}
+static inline int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
+ const struct iovec __user *uvec,
+ size_t uvec_segs,
+ int ddir, struct iov_iter *iter,
+ unsigned issue_flags)
+{
+ return -EOPNOTSUPP;
+}
static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret,
u64 ret2, unsigned issue_flags)
{
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index abcc1ad236ef..c3eb2c263520 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -279,6 +279,25 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
}
EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed);
+int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
+ const struct iovec __user *uvec,
+ size_t uvec_segs,
+ int ddir, struct iov_iter *iter,
+ unsigned issue_flags)
+{
+ struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);
+ struct io_async_cmd *ac = req->async_data;
+ int ret;
+
+ ret = io_prep_reg_iovec(req, &ac->vec, uvec, uvec_segs);
+ if (ret)
+ return ret;
+
+ return io_import_reg_vec(ddir, iter, req, &ac->vec, uvec_segs,
+ issue_flags);
+}
+EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed_vec);
+
void io_uring_cmd_issue_blocking(struct io_uring_cmd *ioucmd)
{
struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);
diff --git a/io_uring/uring_cmd.h b/io_uring/uring_cmd.h
index b45ec7cffcd1..14e525255854 100644
--- a/io_uring/uring_cmd.h
+++ b/io_uring/uring_cmd.h
@@ -16,3 +16,9 @@ bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx,
struct io_uring_task *tctx, bool cancel_all);
void io_cmd_cache_free(const void *entry);
+
+int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
+ const struct iovec __user *uvec,
+ size_t uvec_segs,
+ int ddir, struct iov_iter *iter,
+ unsigned issue_flags);
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v5 5/5] btrfs: ioctl: introduce btrfs_uring_import_iovec()
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
` (3 preceding siblings ...)
2025-03-19 6:12 ` [RFC PATCH v5 4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec Sidong Yang
@ 2025-03-19 6:12 ` Sidong Yang
2025-03-19 15:26 ` (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Jens Axboe
5 siblings, 0 replies; 10+ messages in thread
From: Sidong Yang @ 2025-03-19 6:12 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Jens Axboe, Pavel Begunkov
Cc: linux-btrfs, linux-kernel, io-uring, Sidong Yang
This patch introduces btrfs_uring_import_iovec(). In encoded read/write
with uring cmd, it uses import_iovec without supporting fixed buffer.
btrfs_using_import_iovec() could use fixed buffer if cmd flags has
IORING_URING_CMD_FIXED.
Signed-off-by: Sidong Yang <[email protected]>
---
fs/btrfs/ioctl.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6c18bad53cd3..e5b4af41ca6b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4802,7 +4802,29 @@ struct btrfs_uring_encoded_data {
struct iov_iter iter;
};
-static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue_flags)
+static int btrfs_uring_import_iovec(struct io_uring_cmd *cmd,
+ unsigned int issue_flags, int rw)
+{
+ struct btrfs_uring_encoded_data *data =
+ io_uring_cmd_get_async_data(cmd)->op_data;
+ int ret;
+
+ if (cmd->flags & IORING_URING_CMD_FIXED) {
+ data->iov = NULL;
+ ret = io_uring_cmd_import_fixed_vec(cmd, data->args.iov,
+ data->args.iovcnt, rw,
+ &data->iter, issue_flags);
+ } else {
+ data->iov = data->iovstack;
+ ret = import_iovec(rw, data->args.iov, data->args.iovcnt,
+ ARRAY_SIZE(data->iovstack), &data->iov,
+ &data->iter);
+ }
+ return ret;
+}
+
+static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd,
+ unsigned int issue_flags)
{
size_t copy_end_kernel = offsetofend(struct btrfs_ioctl_encoded_io_args, flags);
size_t copy_end;
@@ -4874,10 +4896,7 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
goto out_acct;
}
- data->iov = data->iovstack;
- ret = import_iovec(ITER_DEST, data->args.iov, data->args.iovcnt,
- ARRAY_SIZE(data->iovstack), &data->iov,
- &data->iter);
+ ret = btrfs_uring_import_iovec(cmd, issue_flags, ITER_DEST);
if (ret < 0)
goto out_acct;
@@ -5022,10 +5041,7 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
if (data->args.len > data->args.unencoded_len - data->args.unencoded_offset)
goto out_acct;
- data->iov = data->iovstack;
- ret = import_iovec(ITER_SOURCE, data->args.iov, data->args.iovcnt,
- ARRAY_SIZE(data->iovstack), &data->iov,
- &data->iter);
+ ret = btrfs_uring_import_iovec(cmd, issue_flags, ITER_SOURCE);
if (ret < 0)
goto out_acct;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
` (4 preceding siblings ...)
2025-03-19 6:12 ` [RFC PATCH v5 5/5] btrfs: ioctl: introduce btrfs_uring_import_iovec() Sidong Yang
@ 2025-03-19 15:26 ` Jens Axboe
2025-03-19 15:27 ` Jens Axboe
5 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2025-03-19 15:26 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Pavel Begunkov, Sidong Yang
Cc: linux-btrfs, linux-kernel, io-uring
On Wed, 19 Mar 2025 06:12:46 +0000, Sidong Yang wrote:
> This patche series introduce io_uring_cmd_import_vec. With this function,
> Multiple fixed buffer could be used in uring cmd. It's vectored version
> for io_uring_cmd_import_fixed(). Also this patch series includes a usage
> for new api for encoded read/write in btrfs by using uring cmd.
>
> There was approximately 10 percent of performance improvements through benchmark.
> The benchmark code is in
> https://github.com/SidongYang/btrfs-encoded-io-test/blob/main/main.c
>
> [...]
Applied, thanks!
[1/5] io_uring: rename the data cmd cache
commit: 575e7b0629d4bd485517c40ff20676180476f5f9
[2/5] io_uring/cmd: don't expose entire cmd async data
commit: 5f14404bfa245a156915ee44c827edc56655b067
[3/5] io_uring/cmd: add iovec cache for commands
commit: fe549edab6c3b7995b58450e31232566b383a249
[4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
commit: b24cb04c1e072ecd859a98b2e4258ca8fe8d2d4d
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec
2025-03-19 15:26 ` (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Jens Axboe
@ 2025-03-19 15:27 ` Jens Axboe
2025-03-19 17:07 ` David Sterba
0 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2025-03-19 15:27 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Pavel Begunkov, Sidong Yang
Cc: linux-btrfs, linux-kernel, io-uring
On 3/19/25 9:26 AM, Jens Axboe wrote:
>
> On Wed, 19 Mar 2025 06:12:46 +0000, Sidong Yang wrote:
>> This patche series introduce io_uring_cmd_import_vec. With this function,
>> Multiple fixed buffer could be used in uring cmd. It's vectored version
>> for io_uring_cmd_import_fixed(). Also this patch series includes a usage
>> for new api for encoded read/write in btrfs by using uring cmd.
>>
>> There was approximately 10 percent of performance improvements through benchmark.
>> The benchmark code is in
>> https://github.com/SidongYang/btrfs-encoded-io-test/blob/main/main.c
>>
>> [...]
>
> Applied, thanks!
>
> [1/5] io_uring: rename the data cmd cache
> commit: 575e7b0629d4bd485517c40ff20676180476f5f9
> [2/5] io_uring/cmd: don't expose entire cmd async data
> commit: 5f14404bfa245a156915ee44c827edc56655b067
> [3/5] io_uring/cmd: add iovec cache for commands
> commit: fe549edab6c3b7995b58450e31232566b383a249
> [4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
> commit: b24cb04c1e072ecd859a98b2e4258ca8fe8d2d4d
1-4 look pretty straight forward to me - I'll be happy to queue the
btrfs one as well if the btrfs people are happy with it, just didn't
want to assume anything here.
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec
2025-03-19 15:27 ` Jens Axboe
@ 2025-03-19 17:07 ` David Sterba
2025-03-19 17:10 ` Jens Axboe
0 siblings, 1 reply; 10+ messages in thread
From: David Sterba @ 2025-03-19 17:07 UTC (permalink / raw)
To: Jens Axboe
Cc: Josef Bacik, David Sterba, Pavel Begunkov, Sidong Yang,
linux-btrfs, linux-kernel, io-uring
On Wed, Mar 19, 2025 at 09:27:37AM -0600, Jens Axboe wrote:
> On 3/19/25 9:26 AM, Jens Axboe wrote:
> >
> > On Wed, 19 Mar 2025 06:12:46 +0000, Sidong Yang wrote:
> >> This patche series introduce io_uring_cmd_import_vec. With this function,
> >> Multiple fixed buffer could be used in uring cmd. It's vectored version
> >> for io_uring_cmd_import_fixed(). Also this patch series includes a usage
> >> for new api for encoded read/write in btrfs by using uring cmd.
> >>
> >> There was approximately 10 percent of performance improvements through benchmark.
> >> The benchmark code is in
> >> https://github.com/SidongYang/btrfs-encoded-io-test/blob/main/main.c
> >>
> >> [...]
> >
> > Applied, thanks!
> >
> > [1/5] io_uring: rename the data cmd cache
> > commit: 575e7b0629d4bd485517c40ff20676180476f5f9
> > [2/5] io_uring/cmd: don't expose entire cmd async data
> > commit: 5f14404bfa245a156915ee44c827edc56655b067
> > [3/5] io_uring/cmd: add iovec cache for commands
> > commit: fe549edab6c3b7995b58450e31232566b383a249
> > [4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
> > commit: b24cb04c1e072ecd859a98b2e4258ca8fe8d2d4d
>
> 1-4 look pretty straight forward to me - I'll be happy to queue the
> btrfs one as well if the btrfs people are happy with it, just didn't
> want to assume anything here.
For 6.15 is too late so it makes more sense to take it through the btrfs
patches targetting 6.16.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec
2025-03-19 17:07 ` David Sterba
@ 2025-03-19 17:10 ` Jens Axboe
0 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2025-03-19 17:10 UTC (permalink / raw)
To: dsterba
Cc: Josef Bacik, David Sterba, Pavel Begunkov, Sidong Yang,
linux-btrfs, linux-kernel, io-uring
On 3/19/25 11:07 AM, David Sterba wrote:
> On Wed, Mar 19, 2025 at 09:27:37AM -0600, Jens Axboe wrote:
>> On 3/19/25 9:26 AM, Jens Axboe wrote:
>>>
>>> On Wed, 19 Mar 2025 06:12:46 +0000, Sidong Yang wrote:
>>>> This patche series introduce io_uring_cmd_import_vec. With this function,
>>>> Multiple fixed buffer could be used in uring cmd. It's vectored version
>>>> for io_uring_cmd_import_fixed(). Also this patch series includes a usage
>>>> for new api for encoded read/write in btrfs by using uring cmd.
>>>>
>>>> There was approximately 10 percent of performance improvements through benchmark.
>>>> The benchmark code is in
>>>> https://github.com/SidongYang/btrfs-encoded-io-test/blob/main/main.c
>>>>
>>>> [...]
>>>
>>> Applied, thanks!
>>>
>>> [1/5] io_uring: rename the data cmd cache
>>> commit: 575e7b0629d4bd485517c40ff20676180476f5f9
>>> [2/5] io_uring/cmd: don't expose entire cmd async data
>>> commit: 5f14404bfa245a156915ee44c827edc56655b067
>>> [3/5] io_uring/cmd: add iovec cache for commands
>>> commit: fe549edab6c3b7995b58450e31232566b383a249
>>> [4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
>>> commit: b24cb04c1e072ecd859a98b2e4258ca8fe8d2d4d
>>
>> 1-4 look pretty straight forward to me - I'll be happy to queue the
>> btrfs one as well if the btrfs people are happy with it, just didn't
>> want to assume anything here.
>
> For 6.15 is too late so it makes more sense to take it through the btrfs
> patches targetting 6.16.
No problem - Sidong, guessing you probably want to resend patch 5/5 once
btrfs has a next branch based on 6.15-rc1 or later.
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-03-19 17:10 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 6:12 [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 1/5] io_uring: rename the data cmd cache Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 2/5] io_uring/cmd: don't expose entire cmd async data Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 3/5] io_uring/cmd: add iovec cache for commands Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 4/5] io_uring/cmd: introduce io_uring_cmd_import_fixed_vec Sidong Yang
2025-03-19 6:12 ` [RFC PATCH v5 5/5] btrfs: ioctl: introduce btrfs_uring_import_iovec() Sidong Yang
2025-03-19 15:26 ` (subset) [RFC PATCH v5 0/5] introduce io_uring_cmd_import_fixed_vec Jens Axboe
2025-03-19 15:27 ` Jens Axboe
2025-03-19 17:07 ` David Sterba
2025-03-19 17:10 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox