From: John Garry <john.g.garry@oracle.com>
To: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me, axboe@fb.com,
martin.petersen@oracle.com,
james.bottomley@hansenpartnership.com, hare@suse.com,
bmarzins@redhat.com, nilay@linux.ibm.com
Cc: jmeneghi@redhat.com, linux-nvme@lists.infradead.org,
linux-scsi@vger.kernel.org, michael.christie@oracle.com,
snitzer@kernel.org, dm-devel@lists.linux.dev,
linux-kernel@vger.kernel.org,
John Garry <john.g.garry@oracle.com>
Subject: [PATCH v2 06/13] nvme-multipath: add nvme_mpath_cdev_ioctl()
Date: Tue, 28 Apr 2026 11:12:49 +0000 [thread overview]
Message-ID: <20260428111256.1778475-7-john.g.garry@oracle.com> (raw)
In-Reply-To: <20260428111256.1778475-1-john.g.garry@oracle.com>
Add nvme_mpath_cdev_ioctl(), which does the same as
nvme_ns_head_chr_ioctl()
Also add nvme_mpath_ioctl_begin() and nvme_mpath_ioctl_finish() - they are
special handling for how the SRCU read lock needs to be dropped for the
controller command IOCTL handling. In this, nvme_mpath_ioctl_begin() takes
a reference to the controller, and then mpath_chr_ioctl() will drop the
SRCU read lock before calling nvme_mpath_cdev_ioctl() and finally the
controller reference is dropped in nvme_mpath_ioctl_finish().
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
drivers/nvme/host/ioctl.c | 37 +++++++++++++++++++++++++++++++----
drivers/nvme/host/multipath.c | 3 +++
drivers/nvme/host/nvme.h | 6 ++++++
3 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 8844bbd395159..ee99b8dbcdfff 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -624,11 +624,9 @@ int nvme_ioctl(struct block_device *bdev, blk_mode_t mode,
return nvme_ns_ioctl(ns, cmd, argp, flags, open_for_write);
}
-long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+static long _nvme_ns_chr_ioctl(struct nvme_ns *ns, unsigned int cmd,
+ unsigned long arg, bool open_for_write)
{
- struct nvme_ns *ns =
- container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
- bool open_for_write = file->f_mode & FMODE_WRITE;
void __user *argp = (void __user *)arg;
if (is_ctrl_ioctl(cmd))
@@ -636,6 +634,14 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return nvme_ns_ioctl(ns, cmd, argp, 0, open_for_write);
}
+long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct nvme_ns *ns =
+ container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
+
+ return _nvme_ns_chr_ioctl(ns, cmd, arg, file->f_mode & FMODE_WRITE);
+}
+
static int nvme_uring_cmd_checks(unsigned int issue_flags)
{
@@ -690,6 +696,29 @@ int nvme_ns_chr_uring_cmd_iopoll(struct io_uring_cmd *ioucmd,
return 0;
}
#ifdef CONFIG_NVME_MULTIPATH
+long nvme_mpath_cdev_ioctl(struct mpath_device *mpath_device, unsigned int cmd,
+ unsigned long arg, bool open_for_write)
+{
+ return _nvme_ns_chr_ioctl(nvme_mpath_to_ns(mpath_device), cmd,
+ arg, open_for_write);
+}
+
+void nvme_mpath_ioctl_begin(struct mpath_device *mpath_device,
+ unsigned int cmd, void **data)
+{
+ struct nvme_ctrl *ctrl = nvme_mpath_to_ns(mpath_device)->ctrl;
+
+ if (is_ctrl_ioctl(cmd)) {
+ nvme_get_ctrl(ctrl);
+ *data = ctrl;
+ }
+}
+
+void nvme_mpath_ioctl_finish(void *opaque)
+{
+ nvme_put_ctrl(opaque);
+}
+
static int nvme_ns_head_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,
void __user *argp, struct nvme_ns_head *head, int srcu_idx,
bool open_for_write)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index d9ab52a29ea8b..5e49cd716f859 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1445,4 +1445,7 @@ static const struct mpath_head_template mpdt = {
.del_cdev = nvme_mpath_del_cdev,
.is_disabled = nvme_mpath_is_disabled,
.is_optimized = nvme_mpath_is_optimized,
+ .cdev_ioctl = nvme_mpath_cdev_ioctl,
+ .ioctl_begin = nvme_mpath_ioctl_begin,
+ .ioctl_finish = nvme_mpath_ioctl_finish,
};
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index f3026da0f39d9..1ec45cce05c9c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1053,6 +1053,12 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head);
void nvme_mpath_start_request(struct request *rq);
void nvme_mpath_end_request(struct request *rq);
+long nvme_mpath_cdev_ioctl(struct mpath_device *mpath_device, unsigned int cmd,
+ unsigned long arg, bool open_for_write);
+void nvme_mpath_ioctl_begin(struct mpath_device *mpath_device,
+ unsigned int cmd, void **opaque);
+void nvme_mpath_ioctl_finish(void *opaque);
+
static inline void nvme_trace_bio_complete(struct request *req)
{
struct nvme_ns *ns = req->q->queuedata;
--
2.43.5
next prev parent reply other threads:[~2026-04-28 11:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 11:12 [PATCH v2 00/13] nvme: switch to libmultipath John Garry
2026-04-28 11:12 ` [PATCH v2 01/13] nvme-multipath: pass NS head to nvme_mpath_revalidate_paths() John Garry
2026-04-28 11:12 ` [PATCH v2 02/13] nvme-multipath: add initial support for using libmultipath John Garry
2026-04-28 11:12 ` [PATCH v2 03/13] nvme-multipath: add nvme_mpath_available_path() John Garry
2026-04-28 11:12 ` [PATCH v2 04/13] nvme-multipath: add nvme_mpath_{add, remove}_cdev() John Garry
2026-04-28 11:12 ` [PATCH v2 05/13] nvme-multipath: add nvme_mpath_is_{disabled, optimised} John Garry
2026-04-28 11:12 ` John Garry [this message]
2026-04-28 11:12 ` [PATCH v2 07/13] nvme-multipath: add uring_cmd support John Garry
2026-04-28 11:12 ` [PATCH v2 08/13] nvme-multipath: add nvme_mpath_get_iopolicy() John Garry
2026-04-28 11:12 ` [PATCH v2 09/13] nvme-multipath: add nvme_mpath_synchronize() John Garry
2026-04-28 11:12 ` [PATCH v2 10/13] nvme-multipath: add nvme_{add,delete}_ns() John Garry
2026-04-28 11:12 ` [PATCH v2 11/13] nvme-multipath: add nvme_mpath_head_queue_if_no_path() John Garry
2026-04-28 11:12 ` [PATCH v2 12/13] nvme-multipath: add nvme_mpath_get_nr_active() John Garry
2026-04-28 11:12 ` [PATCH v2 13/13] nvme-multipath: switch to use libmultipath John Garry
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=20260428111256.1778475-7-john.g.garry@oracle.com \
--to=john.g.garry@oracle.com \
--cc=axboe@fb.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=jmeneghi@redhat.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
--cc=snitzer@kernel.org \
/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