[PATCH 11/19] nvme-multipath: add nvme_mpath_get_iopolicy()

John Garry
2026-02-25T15:41:14Z

Add a function to return the iopolicy for the head structure.

Since iopolicy for NVMe is currently per-subsystem, we add the
mpath_iopolicy struct to the subsystem struct, and
nvme_mpath_get_iopolicy() needs to access that member.

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

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 12386f9caa72a..6cadbc0449d3d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1464,6 +1464,15 @@ void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
ctrl->ana_log_size = 0;
}

+static enum mpath_iopolicy_e nvme_mpath_get_iopolicy(
+ struct mpath_head *mpath_head)
+{
+ struct nvme_ns_head *head = mpath_head->drvdata;
+ struct nvme_subsystem *subsys = head->subsys;
+
+ return mpath_read_iopolicy(&subsys->mpath_iopolicy);
+}
+
static enum mpath_access_state nvme_mpath_get_access_state(
struct mpath_device *mpath_device)
{
@@ -1494,4 +1503,5 @@ static const struct mpath_head_template mpdt = {
.cdev_ioctl = nvme_mpath_cdev_ioctl,
.chr_uring_cmd = nvme_mpath_chr_uring_cmd,
.chr_uring_cmd_iopoll = nvme_ns_chr_uring_cmd_iopoll,
+ .get_iopolicy = nvme_mpath_get_iopolicy,
};
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index bc0ad0bbb68fd..da9bd1ada6ad6 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -502,6 +502,7 @@ struct nvme_subsystem {
struct ida ns_ida;
#ifdef CONFIG_NVME_MULTIPATH
enum nvme_iopolicy iopolicy;
+ struct mpath_iopolicy mpath_iopolicy;
#endif
};

--
2.43.5