[PATCH v3 03/10] nvme-multipath: add nvme_mpath_{add, remove}_cdev()
John Garry
john.g.garry at oracle.com
Fri Jul 3 03:31:57 PDT 2026
These are for mpath_head_template.add_cdev+del_cdev callbacks.
Currently the same functionality is in nvme_add_ns_head_cdev() and
nvme_cdev_del().
Signed-off-by: John Garry <john.g.garry at oracle.com>
---
drivers/nvme/host/multipath.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 14c4370f7303f..e0573ca71ec60 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -630,6 +630,24 @@ 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 = nvme_mpath_to_ns_head(mpath_head);
+ char name[32];
+
+ head->cdev_device.parent = &head->subsys->dev;
+ snprintf(name, sizeof(name), "ng%dn%d", head->subsys->instance,
+ head->instance);
+
+ return nvme_cdev_add(name, &mpath_head->cdev, &mpath_head->cdev_device,
+ &mpath_chr_fops, THIS_MODULE);
+}
+
+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);
@@ -1519,4 +1537,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.7
More information about the Linux-nvme
mailing list