From: Kanchan Joshi <joshi.k@samsung.com>
To: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-block@vger.kernel.org
Cc: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org,
javier@javigon.com, anuj20.g@samsung.com, joshiiitr@gmail.com,
pankydev8@gmail.com
Subject: [RFC 06/13] io_uring: add support for uring_cmd with fixed-buffer
Date: Mon, 20 Dec 2021 19:47:27 +0530 [thread overview]
Message-ID: <20211220141734.12206-7-joshi.k@samsung.com> (raw)
In-Reply-To: <20211220141734.12206-1-joshi.k@samsung.com>
From: Anuj Gupta <anuj20.g@samsung.com>
Add IORING_OP_URING_CMD_FIXED opcode that enables performing the
operation with previously registered buffers.
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/io_uring.c | 29 ++++++++++++++++++++++++++++-
include/uapi/linux/io_uring.h | 6 +++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index cc6735913c4b..2870a891e441 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1122,6 +1122,10 @@ static const struct io_op_def io_op_defs[] = {
.needs_file = 1,
.offsets = 1,
},
+ [IORING_OP_URING_CMD_FIXED] = {
+ .needs_file = 1,
+ .offsets = 1,
+ },
};
/* requests with any of those set should undergo io_disarm_next() */
@@ -4133,6 +4137,7 @@ EXPORT_SYMBOL_GPL(io_uring_cmd_done);
static int io_uring_cmd_prep(struct io_kiocb *req,
const struct io_uring_sqe *sqe)
{
+ struct io_ring_ctx *ctx = req->ctx;
const struct io_uring_cmd_sqe *csqe = (const void *) sqe;
struct io_uring_cmd *cmd = &req->uring_cmd;
@@ -4145,7 +4150,13 @@ static int io_uring_cmd_prep(struct io_kiocb *req,
}
cmd->op = READ_ONCE(csqe->op);
- cmd->len = READ_ONCE(csqe->len);
+ if (req->opcode == IORING_OP_URING_CMD_FIXED) {
+ req->imu = NULL;
+ io_req_set_rsrc_node(req, ctx);
+ req->buf_index = READ_ONCE(csqe->buf_index);
+ req->uring_cmd.flags |= URING_CMD_FIXEDBUFS;
+ } else
+ cmd->len = READ_ONCE(csqe->len);
/*
* The payload is the last 40 bytes of an io_uring_cmd_sqe, with the
@@ -4160,6 +4171,20 @@ static int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
struct file *file = req->file;
int ret;
+ if (req->opcode == IORING_OP_URING_CMD_FIXED) {
+ u32 index, buf_index = req->buf_index;
+ struct io_ring_ctx *ctx = req->ctx;
+ struct io_mapped_ubuf *imu = req->imu;
+
+ if (likely(!imu)) {
+ if (unlikely(buf_index >= ctx->nr_user_bufs))
+ return -EFAULT;
+ index = array_index_nospec(buf_index, ctx->nr_user_bufs);
+ imu = READ_ONCE(ctx->user_bufs[index]);
+ req->imu = imu;
+ }
+ }
+
ret = file->f_op->async_cmd(&req->uring_cmd, issue_flags);
/* queued async, consumer will call io_uring_cmd_done() when complete */
if (ret == -EIOCBQUEUED)
@@ -6675,6 +6700,7 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
case IORING_OP_LINKAT:
return io_linkat_prep(req, sqe);
case IORING_OP_URING_CMD:
+ case IORING_OP_URING_CMD_FIXED:
return io_uring_cmd_prep(req, sqe);
}
@@ -6960,6 +6986,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
ret = io_linkat(req, issue_flags);
break;
case IORING_OP_URING_CMD:
+ case IORING_OP_URING_CMD_FIXED:
ret = io_uring_cmd(req, issue_flags);
break;
default:
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 7191419f2236..cb331f201255 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -79,7 +79,10 @@ struct io_uring_cmd_sqe {
__u64 user_data;
__u16 op;
__u16 personality;
- __u32 len;
+ union {
+ __u32 len;
+ __u16 buf_index;
+ };
__u64 pdu[5];
};
@@ -164,6 +167,7 @@ enum {
IORING_OP_SYMLINKAT,
IORING_OP_LINKAT,
IORING_OP_URING_CMD,
+ IORING_OP_URING_CMD_FIXED,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.25.1
next prev parent reply other threads:[~2021-12-21 2:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20211220142227epcas5p280851b0a62baa78379979eb81af7a096@epcas5p2.samsung.com>
2021-12-20 14:17 ` [RFC 00/13] uring-passthru for nvme Kanchan Joshi
2021-12-20 14:17 ` [RFC 01/13] io_uring: add infra for uring_cmd completion in submitter-task Kanchan Joshi
2022-02-17 2:13 ` Luis Chamberlain
2022-02-17 15:39 ` Kanchan Joshi
2022-02-17 15:50 ` Jens Axboe
2022-02-17 17:56 ` Luis Chamberlain
2022-02-18 17:41 ` Kanchan Joshi
2022-02-17 18:46 ` Luis Chamberlain
2022-02-17 18:53 ` Jens Axboe
2021-12-20 14:17 ` [RFC 02/13] nvme: wire-up support for async-passthru on char-device Kanchan Joshi
2021-12-20 14:17 ` [RFC 03/13] io_uring: mark iopoll not supported for uring-cmd Kanchan Joshi
2022-02-17 2:16 ` Luis Chamberlain
2022-02-17 2:52 ` Jens Axboe
2021-12-20 14:17 ` [RFC 04/13] io_uring: modify unused field in io_uring_cmd to store flags Kanchan Joshi
2021-12-20 14:17 ` [RFC 05/13] io_uring: add flag and helper for fixed-buffer uring-cmd Kanchan Joshi
2021-12-20 14:17 ` Kanchan Joshi [this message]
2021-12-20 14:17 ` [RFC 07/13] nvme: enable passthrough with fixed-buffer Kanchan Joshi
2021-12-20 14:17 ` [RFC 08/13] io_uring: plug for async bypass Kanchan Joshi
2021-12-20 14:17 ` [RFC 09/13] block: wire-up support for plugging Kanchan Joshi
2021-12-20 14:17 ` [RFC 10/13] block: factor out helper for bio allocation from cache Kanchan Joshi
2021-12-20 14:17 ` [RFC 11/13] nvme: enable bio-cache for fixed-buffer passthru Kanchan Joshi
2021-12-20 14:17 ` [RFC 12/13] nvme: allow user passthrough commands to poll Kanchan Joshi
2021-12-20 14:17 ` [RFC 13/13] nvme: Add async passthru polling support Kanchan Joshi
2021-12-21 3:45 ` [RFC 00/13] uring-passthru for nvme Jens Axboe
2021-12-21 14:36 ` Kanchan Joshi
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=20211220141734.12206-7-joshi.k@samsung.com \
--to=joshi.k@samsung.com \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=io-uring@vger.kernel.org \
--cc=javier@javigon.com \
--cc=joshiiitr@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=pankydev8@gmail.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