From: Christoph Hellwig <hch@lst.de>
To: Kanchan Joshi <joshi.k@samsung.com>
Cc: axboe@kernel.dk, hch@lst.de, io-uring@vger.kernel.org,
linux-nvme@lists.infradead.org, asml.silence@gmail.com,
ming.lei@redhat.com, mcgrof@kernel.org, pankydev8@gmail.com,
javier@javigon.com, joshiiitr@gmail.com, anuj20.g@samsung.com
Subject: Re: [RFC 0/5] big-cqe based uring-passthru
Date: Mon, 4 Apr 2022 09:21:52 +0200 [thread overview]
Message-ID: <20220404072152.GE444@lst.de> (raw)
In-Reply-To: <20220401110310.611869-1-joshi.k@samsung.com>
I really can't get excited about the pdu thingy. Here is a patch
(on top of the series and the patch sent in reply to patch 4) that
does away with it and just adds a oob_user field to struct io_uring_cmd
to simplify the handling a fair bit:
---
From 426fa5de1d5f5a718b797eda2fc3ea47010662f7 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Mon, 4 Apr 2022 08:24:43 +0200
Subject: io_uring: explicit support for out of band data in io_uring_cmd
Instead of the magic pdu byte array, which in its current form causes
unaligned pointers and a lot of casting add explicit support for out
of band data in struct io_uring_cmd and just leave a normal private
data pointer to the driver.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/ioctl.c | 35 +++++++----------------------------
include/linux/io_uring.h | 10 ++++++++--
2 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index ea6cfd4321942..b93c6ecfcd2ab 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -37,27 +37,9 @@ static int nvme_ioctl_finish_metadata(struct bio *bio, int ret,
return ret;
}
-/*
- * This overlays struct io_uring_cmd pdu.
- * Expect build errors if this grows larger than that.
- */
-struct nvme_uring_cmd_pdu {
- union {
- struct bio *bio;
- struct request *req;
- };
- void __user *meta_buffer;
-} __packed;
-
-static struct nvme_uring_cmd_pdu *nvme_uring_cmd_pdu(struct io_uring_cmd *ioucmd)
-{
- return (struct nvme_uring_cmd_pdu *)&ioucmd->pdu;
-}
-
static void nvme_uring_task_cb(struct io_uring_cmd *ioucmd)
{
- struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd);
- struct request *req = pdu->req;
+ struct request *req = ioucmd->private;
struct bio *bio = req->bio;
int status;
u64 result;
@@ -71,7 +53,7 @@ static void nvme_uring_task_cb(struct io_uring_cmd *ioucmd)
blk_mq_free_request(req);
blk_rq_unmap_user(bio);
- status = nvme_ioctl_finish_metadata(bio, status, pdu->meta_buffer);
+ status = nvme_ioctl_finish_metadata(bio, status, ioucmd->oob_user);
result = le64_to_cpu(nvme_req(req)->result.u64);
io_uring_cmd_done(ioucmd, status, result);
}
@@ -79,12 +61,10 @@ static void nvme_uring_task_cb(struct io_uring_cmd *ioucmd)
static void nvme_end_async_pt(struct request *req, blk_status_t err)
{
struct io_uring_cmd *ioucmd = req->end_io_data;
- struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd);
- /* extract bio before reusing the same field for request */
- struct bio *bio = pdu->bio;
+ struct bio *bio = ioucmd->private;
- pdu->req = req;
req->bio = bio;
+ ioucmd->private = req;
/* this takes care of moving rest of completion-work to task context */
io_uring_cmd_complete_in_task(ioucmd, nvme_uring_task_cb);
@@ -381,7 +361,6 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
{
struct nvme_passthru_cmd64 *cmd =
(struct nvme_passthru_cmd64 *)ioucmd->cmd;
- struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd);
struct request_queue *q = ns ? ns->queue : ctrl->admin_q;
struct nvme_command c;
struct request *req;
@@ -415,10 +394,10 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
return PTR_ERR(req);
/* to free bio on completion, as req->bio will be null at that time */
- pdu->bio = req->bio;
- pdu->meta_buffer = nvme_to_user_ptr(cmd->metadata);
- req->end_io_data = ioucmd;
+ ioucmd->private = req->bio;
+ ioucmd->oob_user = nvme_to_user_ptr(cmd->metadata);
+ req->end_io_data = ioucmd;
blk_execute_rq_nowait(req, 0, nvme_end_async_pt);
return -EIOCBQUEUED;
}
diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h
index 0aba7b50cde65..95b56e45cd539 100644
--- a/include/linux/io_uring.h
+++ b/include/linux/io_uring.h
@@ -23,8 +23,14 @@ struct io_uring_cmd {
u32 flags;
u32 cmd_op;
u16 cmd_len;
- u16 unused;
- u8 pdu[28]; /* available inline for free use */
+
+ void *private;
+
+ /*
+ * Out of band data can be used for data that is not the main data.
+ * E.g. block device PI/metadata or additional information.
+ */
+ void __user *oob_user;
};
#if defined(CONFIG_IO_URING)
--
2.30.2
next prev parent reply other threads:[~2022-04-04 7:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220401110829epcas5p39f3cf4d3f6eb8a5c59794787a2b72b15@epcas5p3.samsung.com>
2022-04-01 11:03 ` [RFC 0/5] big-cqe based uring-passthru Kanchan Joshi
2022-04-01 11:03 ` [RFC 1/5] io_uring: add support for 128-byte SQEs Kanchan Joshi
2022-04-01 11:03 ` [RFC 2/5] fs: add file_operations->async_cmd() Kanchan Joshi
2022-04-04 7:09 ` Christoph Hellwig
2022-04-01 11:03 ` [RFC 3/5] io_uring: add infra and support for IORING_OP_URING_CMD Kanchan Joshi
2022-04-04 7:16 ` Christoph Hellwig
2022-04-04 8:20 ` Pavel Begunkov
2022-04-05 5:58 ` Christoph Hellwig
2022-04-06 6:37 ` Kanchan Joshi
2022-04-04 15:14 ` Kanchan Joshi
2022-04-05 6:00 ` Christoph Hellwig
2022-04-05 16:27 ` Kanchan Joshi
2022-04-01 11:03 ` [RFC 4/5] io_uring: add support for big-cqe Kanchan Joshi
2022-04-04 7:07 ` Christoph Hellwig
2022-04-04 14:04 ` Kanchan Joshi
2022-04-01 11:03 ` [RFC 5/5] nvme: wire-up support for async-passthru on char-device Kanchan Joshi
2022-04-04 7:20 ` Christoph Hellwig
2022-04-04 14:25 ` Kanchan Joshi
2022-04-05 6:02 ` Christoph Hellwig
2022-04-05 15:40 ` Jens Axboe
2022-04-05 15:49 ` Kanchan Joshi
2022-04-06 5:20 ` Kanchan Joshi
2022-04-06 5:23 ` Christoph Hellwig
2022-04-23 17:53 ` Christoph Hellwig
2022-04-25 17:38 ` Kanchan Joshi
2022-04-29 13:16 ` Kanchan Joshi
2022-04-04 7:21 ` Christoph Hellwig [this message]
2022-04-05 15:37 ` [RFC 0/5] big-cqe based uring-passthru 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=20220404072152.GE444@lst.de \
--to=hch@lst.de \
--cc=anuj20.g@samsung.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=javier@javigon.com \
--cc=joshi.k@samsung.com \
--cc=joshiiitr@gmail.com \
--cc=linux-nvme@lists.infradead.org \
--cc=mcgrof@kernel.org \
--cc=ming.lei@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.