From: Keith Busch <kbusch@meta.com>
To: <linux-nvme@lists.infradead.org>, <linux-block@vger.kernel.org>,
<joshi.k@samsung.com>, <axboe@kernel.dk>, <hch@lst.de>,
<xiaoguang.wang@linux.alibaba.com>
Cc: Keith Busch <kbusch@kernel.org>
Subject: [RFC 3/3] nvme: create special request queue for cdev
Date: Mon, 1 May 2023 08:33:06 -0700 [thread overview]
Message-ID: <20230501153306.537124-4-kbusch@meta.com> (raw)
In-Reply-To: <20230501153306.537124-1-kbusch@meta.com>
From: Keith Busch <kbusch@kernel.org>
The cdev only services passthrough commands which don't merge, track
stats, or need accounting. Give it a special request queue with all
these options cleared so that we're not adding overhead for it.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 29 +++++++++++++++++++++++++----
drivers/nvme/host/ioctl.c | 4 ++--
drivers/nvme/host/nvme.h | 1 +
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 0f1cb6f418182..5bb05c91d866d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4071,21 +4071,39 @@ static const struct file_operations nvme_ns_chr_fops = {
static int nvme_add_ns_cdev(struct nvme_ns *ns)
{
+ struct nvme_ctrl *ctrl = ns->ctrl;
+ struct request_queue *q;
int ret;
- ns->cdev_device.parent = ns->ctrl->device;
+ ns->cdev_device.parent = ctrl->device;
ret = dev_set_name(&ns->cdev_device, "ng%dn%d",
- ns->ctrl->instance, ns->head->instance);
+ ctrl->instance, ns->head->instance);
if (ret)
return ret;
ret = nvme_cdev_add(&ns->cdev, &ns->cdev_device, &nvme_ns_chr_fops,
- ns->ctrl->ops->module);
+ ctrl->ops->module);
if (ret)
goto out_free_name;
+ q = blk_mq_init_queue(ctrl->tagset);
+ if (IS_ERR(q)) {
+ ret = PTR_ERR(q);
+ goto out_free_cdev;
+ }
+
+ blk_queue_flag_clear(QUEUE_FLAG_IO_STAT, q);
+ blk_queue_flag_clear(QUEUE_FLAG_STATS, q);
+ blk_queue_flag_clear(QUEUE_FLAG_NOMERGES, q);
+ q->queuedata = ns;
+ ns->cdev_queue = q;
+
return 0;
+out_free_cdev:
+ cdev_device_del(&ns->cdev, &ns->cdev_device);
+ return ret;
+
out_free_name:
kfree_const(ns->cdev_device.kobj.name);
return ret;
@@ -4399,8 +4417,11 @@ static void nvme_ns_remove(struct nvme_ns *ns)
/* guarantee not available in head->list */
synchronize_srcu(&ns->head->srcu);
- if (!nvme_ns_head_multipath(ns->head))
+ if (!nvme_ns_head_multipath(ns->head)) {
+ blk_mq_destroy_queue(ns->cdev_queue);
+ blk_put_queue(ns->cdev_queue);
nvme_cdev_del(&ns->cdev, &ns->cdev_device);
+ }
del_gendisk(ns->disk);
down_write(&ns->ctrl->namespaces_rwsem);
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 3804e5205b42b..bf4fcb5d270e9 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -553,7 +553,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
{
struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd);
const struct nvme_uring_cmd *cmd = ioucmd->cmd;
- struct request_queue *q = ns ? ns->queue : ctrl->admin_q;
+ struct request_queue *q = ns ? ns->cdev_queue : ctrl->admin_q;
struct nvme_uring_data d;
struct nvme_command c;
struct request *req;
@@ -791,7 +791,7 @@ int nvme_ns_chr_uring_cmd_iopoll(struct io_uring_cmd *ioucmd,
bio = READ_ONCE(ioucmd->cookie);
ns = container_of(file_inode(ioucmd->file)->i_cdev,
struct nvme_ns, cdev);
- q = ns->queue;
+ q = ns->cdev_queue;
if (test_bit(QUEUE_FLAG_POLL, &q->queue_flags) && bio && bio->bi_bdev)
ret = bio_poll(bio, iob, poll_flags);
rcu_read_unlock();
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index bf46f122e9e1e..d837c118f4f18 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -495,6 +495,7 @@ struct nvme_ns {
struct cdev cdev;
struct device cdev_device;
+ struct request_queue *cdev_queue;
struct nvme_fault_inject fault_inject;
--
2.34.1
next prev parent reply other threads:[~2023-05-01 15:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230501154403epcas5p388c607114ad6f9d20dfd3ec958d88947@epcas5p3.samsung.com>
2023-05-01 15:33 ` [RFC 0/3] nvme uring passthrough diet Keith Busch
2023-05-01 15:33 ` [RFC 1/3] nvme: skip block cgroups for passthrough commands Keith Busch
2023-05-03 5:04 ` Christoph Hellwig
2023-05-03 15:25 ` Keith Busch
2023-05-15 15:47 ` Keith Busch
2023-05-01 15:33 ` [RFC 2/3] nvme: fix cdev name leak Keith Busch
2023-05-01 15:33 ` Keith Busch [this message]
2023-05-02 12:20 ` [RFC 3/3] nvme: create special request queue for cdev Johannes Thumshirn
2023-05-03 5:04 ` Christoph Hellwig
2023-05-03 14:56 ` Keith Busch
2023-05-01 19:01 ` [RFC 0/3] nvme uring passthrough diet Kanchan Joshi
2023-05-01 19:31 ` Keith Busch
2023-05-03 7:27 ` Kanchan Joshi
2023-05-03 15:20 ` Keith Busch
2023-05-05 8:14 ` 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=20230501153306.537124-4-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=joshi.k@samsung.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=xiaoguang.wang@linux.alibaba.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.