From: Sidong Yang <[email protected]>
To: Josef Bacik <[email protected]>,
David Sterba <[email protected]>, Jens Axboe <[email protected]>,
Pavel Begunkov <[email protected]>
Cc: [email protected], [email protected],
[email protected], Sidong Yang <[email protected]>
Subject: [RFC PATCH v4 2/5] io-uring/cmd: add iou_vec field for io_uring_cmd
Date: Mon, 17 Mar 2025 13:57:39 +0000 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
This patch adds iou_vec field for io_uring_cmd. Also it needs to be
cleanup for cache. It could be used in uring cmd api that imports
multiple fixed buffers.
Signed-off-by: Sidong Yang <[email protected]>
---
io_uring/io_uring.c | 2 +-
io_uring/opdef.c | 1 +
io_uring/uring_cmd.c | 20 ++++++++++++++++++++
io_uring/uring_cmd.h | 4 ++++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 513f036bccbb..08506d1224c5 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->uring_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 e4cd6fe9fd47..bf4002e93ec5 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -29,6 +29,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->iou_vec);
+ if (ac->iou_vec.nr > IO_VEC_CACHE_SOFT_CAP)
+ io_vec_free(&ac->iou_vec);
+
if (io_alloc_cache_put(&req->ctx->uring_cache, cache)) {
ioucmd->sqe = NULL;
req->async_data = NULL;
@@ -36,6 +43,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)
{
@@ -346,3 +358,11 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
}
EXPORT_SYMBOL_GPL(io_uring_cmd_sock);
#endif
+
+void io_cmd_cache_free(const void *entry)
+{
+ struct io_async_cmd *ac = (struct io_async_cmd *)entry;
+
+ io_vec_free(&ac->iou_vec);
+ kfree(ac);
+}
diff --git a/io_uring/uring_cmd.h b/io_uring/uring_cmd.h
index f3593012658c..8986224e0c57 100644
--- a/io_uring/uring_cmd.h
+++ b/io_uring/uring_cmd.h
@@ -1,13 +1,17 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/io_uring_types.h>
#include <linux/io_uring/cmd.h>
struct io_async_cmd {
struct io_uring_cmd_data data;
+ struct iou_vec iou_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
next prev parent reply other threads:[~2025-03-17 13:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 13:57 [RFC PATCH v4 0/5] introduce io_uring_cmd_import_fixed_vec Sidong Yang
2025-03-17 13:57 ` [RFC PATCH v4 1/5] io_uring/cmd: introduce io_async_cmd for hide io_uring_cmd_data Sidong Yang
2025-03-17 13:57 ` Sidong Yang [this message]
2025-03-17 13:57 ` [RFC PATCH v4 3/5] io-uring/cmd: introduce io_uring_cmd_import_fixed_vec Sidong Yang
2025-03-17 13:57 ` [RFC PATCH v4 4/5] btrfs: ioctl: introduce btrfs_uring_import_iovec() Sidong Yang
2025-03-17 15:37 ` Caleb Sander Mateos
2025-03-18 0:51 ` Sidong Yang
2025-03-17 15:40 ` Jens Axboe
2025-03-18 1:58 ` Sidong Yang
2025-03-18 7:25 ` Pavel Begunkov
2025-03-18 7:55 ` Sidong Yang
2025-03-18 13:18 ` Jens Axboe
2025-03-17 13:57 ` [RFC PATCH v4 5/5] btrfs: ioctl: don't free iov when -EAGAIN in uring encoded read Sidong Yang
2025-03-18 7:21 ` Pavel Begunkov
2025-03-18 7:58 ` Sidong Yang
2025-03-18 7:30 ` [RFC PATCH v4 0/5] introduce io_uring_cmd_import_fixed_vec Pavel Begunkov
2025-03-18 7:41 ` Sidong Yang
2025-03-18 13:19 ` Jens Axboe
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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