[PATCH 08/19] nvme-multipath: add nvme_mpath_get_access_state()
From: John Garry
Date: Wed Feb 25 2026 - 10:59:44 EST
Add nvme_mpath_get_access_state(), which gets the NS ana_state and
translates into enum mpath_access_state.
This replicates functionality for checking ana state in __nvme_find_path().
Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx>
---
drivers/nvme/host/multipath.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 07461a7d8d1fa..a67db36f3c5a5 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1464,6 +1464,24 @@ void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
ctrl->ana_log_size = 0;
}
+static enum mpath_access_state nvme_mpath_get_access_state(
+ struct mpath_device *mpath_device)
+{
+ struct nvme_ns *ns = nvme_mpath_to_ns(mpath_device);
+
+ switch (ns->ana_state) {
+ case NVME_ANA_OPTIMIZED:
+ return MPATH_STATE_OPTIMIZED;
+ case NVME_ANA_NONOPTIMIZED:
+ return MPATH_STATE_ACTIVE;
+ case NVME_ANA_INACCESSIBLE:
+ case NVME_ANA_PERSISTENT_LOSS:
+ case NVME_ANA_CHANGE:
+ default:
+ return MPATH_STATE_INVALID;
+ }
+}
+
__maybe_unused
static const struct mpath_head_template mpdt = {
.available_path = nvme_mpath_available_path,
@@ -1471,4 +1489,5 @@ 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,
+ .get_access_state = nvme_mpath_get_access_state,
};
--
2.43.5