Linux SCSI subsystem development
 help / color / mirror / Atom feed
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 04/13] nvme-multipath: add nvme_mpath_{add, remove}_cdev()
Date: Tue, 28 Apr 2026 11:12:47 +0000	[thread overview]
Message-ID: <20260428111256.1778475-5-john.g.garry@oracle.com> (raw)
In-Reply-To: <20260428111256.1778475-1-john.g.garry@oracle.com>

These are for mpath_head_template.add_cdev+del_cdev callbacks.

Currently the same functionality is in nvme_add_ns_cdev() and
nvme_cdev_del().

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 drivers/nvme/host/multipath.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index cc5a3c6c272f7..0bdc7e0dbce50 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -608,6 +608,26 @@ const struct block_device_operations nvme_ns_head_ops = {
 	.pr_ops		= &nvme_pr_ops,
 };
 
+static int nvme_mpath_add_cdev(struct mpath_head *mpath_head)
+{
+	struct nvme_ns_head *head = mpath_head->drvdata;
+	int ret;
+
+	mpath_head->cdev_device.parent = &head->subsys->dev;
+	ret = dev_set_name(&mpath_head->cdev_device, "ng%dn%d",
+			   head->subsys->instance, head->instance);
+	if (ret)
+		return ret;
+	ret = nvme_cdev_add(&mpath_head->cdev, &mpath_head->cdev_device,
+			    &mpath_chr_fops, THIS_MODULE);
+	return ret;
+}
+
+static void nvme_mpath_del_cdev(struct mpath_head *mpath_head)
+{
+	nvme_cdev_del(&mpath_head->cdev, &mpath_head->cdev_device);
+}
+
 static inline struct nvme_ns_head *cdev_to_ns_head(struct cdev *cdev)
 {
 	return container_of(cdev, struct nvme_ns_head, cdev);
@@ -1411,4 +1431,6 @@ void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
 __maybe_unused
 static const struct mpath_head_template mpdt = {
 	.available_path = nvme_mpath_available_path,
+	.add_cdev = nvme_mpath_add_cdev,
+	.del_cdev = nvme_mpath_del_cdev,
 };
-- 
2.43.5


  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 ` John Garry [this message]
2026-04-28 11:12 ` [PATCH v2 05/13] nvme-multipath: add nvme_mpath_is_{disabled, optimised} John Garry
2026-04-28 11:12 ` [PATCH v2 06/13] nvme-multipath: add nvme_mpath_cdev_ioctl() John Garry
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-5-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