Re: [PATCHv2 2/5] nvme: simplify passthrough bio cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 07, 2023 at 12:16:33PM -0700, Keith Busch wrote:
From: Keith Busch <kbusch@xxxxxxxxxx>

Set the bio's bi_end_io to handle the cleanup so that uring_cmd doesn't
need this complex pdu->{bio,req} switchero and restore.

Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
---
drivers/nvme/host/ioctl.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index d24ea2e051564..278c57ee0db91 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -159,6 +159,11 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,
	return req;
}

+static void nvme_uring_bio_end_io(struct bio *bio)
+{
+	blk_rq_unmap_user(bio);
+}
+
static int nvme_map_user_request(struct request *req, u64 ubuffer,
		unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
		u32 meta_seed, void **metap, struct io_uring_cmd *ioucmd,
@@ -204,6 +209,7 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
		*metap = meta;
	}

+	bio->bi_end_io = nvme_uring_bio_end_io;
	return ret;

out_unmap:
@@ -249,8 +255,6 @@ static int nvme_submit_user_cmd(struct request_queue *q,
	if (meta)
		ret = nvme_finish_user_metadata(req, meta_buffer, meta,
						meta_len, ret);
-	if (bio)
-		blk_rq_unmap_user(bio);

Is it safe to call blk_rq_unamp_user in irq context?
Agree that current code does some complex stuff, but that's to ensure
what the code-comment [1] says.

Also for polled-io, new-code will hit this warn-on [2] on calling
bio_put_percpu_cache.

[1] 623 * A matching blk_rq_unmap_user() must be issued at the end of I/O, while
624  *    still in process context.
625  */
626 int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
627                         struct rq_map_data *map_data,


[2]
773         if ((bio->bi_opf & REQ_POLLED) && !WARN_ON_ONCE(in_interrupt())) {
774                 bio->bi_next = cache->free_list;





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux