Skip to contentSkip to conversation

nvme-multipath: round-robin I/O policy

PATCH New Hannes Reinecke 2 participants 2 messages Feb 18, 2019 – Feb 19, 2019 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 nvme-multipath: round-robin I/O policy

Implement a simple round-robin I/O policy for multipathing. Path selection is done in two rounds, first iterating across all optimized paths, and, if that doesn't return any valid paths, iterate over all optimized and non-optimized paths.
If no paths are found we're using the existing algorithm. This patch also implements a sysfs attribute 'iopolicy' to switch between the current, NUMA-aware I/O policy and the 'round-robin' I/O policy.

Signed-off-by Hannes Reinecke <hare at suse.com>
---
 drivers/nvme/host/core.c      |  6 +++
 drivers/nvme/host/multipath.c | 86 ++++++++++++++++++++++++++++++++++++++++++-
 drivers/nvme/host/nvme.h      |  9 +++++
 3 files changed, 100 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +6 -0
index c365f0aa9433..f2f75831decd 100644
@@ -2325,6 +2325,9 @@ static struct attribute *nvme_subsys_attrs[] = {
 	&subsys_attr_serial.attr,
 	&subsys_attr_firmware_rev.attr,
 	&subsys_attr_subsysnqn.attr,
+#ifdef CONFIG_NVME_MULTIPATH
+	&subsys_attr_iopolicy.attr,
+#endif
 	NULL,
 };
 
@@ -2377,6 +2380,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	memcpy(subsys->firmware_rev, id->fr, sizeof(subsys->firmware_rev));
 	subsys->vendor_id = le16_to_cpu(id->vid);
 	subsys->cmic = id->cmic;
+#ifdef CONFIG_NVME_MULTIPATH
+	subsys->iopolicy = NVME_IOPOLICY_NUMA;
+#endif
 
 	subsys->dev.class = nvme_subsys_class;
 	subsys->dev.release = nvme_release_subsystem;
drivers/nvme/host/multipath.c +85 -1

110 lines not on this page · raw message

drivers/nvme/host/nvme.h +9 -0
index a0cc733c753e..36d4b166a155 100644
@@ -251,6 +251,11 @@ struct nvme_ctrl {
 	unsigned long discard_page_busy;
 };
 
+enum nvme_iopolicy {
+	NVME_IOPOLICY_NUMA,
+	NVME_IOPOLICY_RR,
+};
+
 struct nvme_subsystem {
 	int			instance;
 	struct device		dev;
@@ -270,6 +275,9 @@ struct nvme_subsystem {
 	u8			cmic;
 	u16			vendor_id;
 	struct ida		ns_ida;
+#ifdef CONFIG_NVME_MULTIPATH
+	enum nvme_iopolicy	iopolicy;
+#endif
 };
 
 /*
@@ -490,6 +498,7 @@ static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
 
 extern struct device_attribute dev_attr_ana_grpid;
 extern struct device_attribute dev_attr_ana_state;
+extern struct device_attribute subsys_attr_iopolicy;
 
 #else
 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
Signature · 1 line
2.16.4
maintainer Applied
#1 lore raw

PATCH v3 1/1 nvme-multipath: round-robin I/O policy

Thanks,

applied to nvme-5.1.