Thread (2 messages) 2 messages, 2 authors, 2021-12-20

Re: [PATCHv3] nvme: add 'iopolicy' module parameter

From: Sagi Grimberg <sagi@grimberg.me>
Date: 2021-12-20 10:36:29


On 12/20/21 11:30 AM, Hannes Reinecke wrote:
quoted hunk ↗ jump to hunk
While the 'iopolicy' sysfs attribute can be set at runtime, most
storage arrays prefer to use the 'round-robin' iopolicy per default.
We can use udev rules to set this, but is getting rather unwieldy
for rebranded arrays as we would have to update the udev rules
anytime a new array shows up, leading to the same mess we currently
have in multipathd for configuring the RDAC arrays.

Hence this patch adds a module parameter 'iopolicy' to allow the
admin to switch the default, and to do away with the need for a
udev rule here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
  drivers/nvme/host/core.c      |  4 +---
  drivers/nvme/host/multipath.c | 27 +++++++++++++++++++++++++++
  drivers/nvme/host/nvme.h      |  4 ++++
  3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 44c375a1edbb..be404004c235 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2747,9 +2747,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
  		return -EINVAL;
  	}
  	subsys->awupf = le16_to_cpu(id->awupf);
-#ifdef CONFIG_NVME_MULTIPATH
-	subsys->iopolicy = NVME_IOPOLICY_NUMA;
-#endif
+	nvme_mpath_default_iopolicy(subsys);
  
  	subsys->dev.class = nvme_subsys_class;
  	subsys->dev.release = nvme_release_subsystem;
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 7f2071f2460c..de98c0e05777 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -13,6 +13,33 @@ module_param(multipath, bool, 0444);
  MODULE_PARM_DESC(multipath,
  	"turn on native support for multiple controllers per subsystem");
  
+static int iopolicy = NVME_IOPOLICY_NUMA;
+
+static int nvme_set_iopolicy(const char *val, const struct kernel_param *kp)
+{
+	char *endp;
+	int p;
+
+	if (!val)
+		return -EINVAL;
+	p = simple_strtoul(val, &endp, 0);
+	if (p != NVME_IOPOLICY_NUMA &&
+	    p != NVME_IOPOLICY_RR)
+		return -EINVAL;
+	iopolicy = p;
+	return 0;
+}
+
+module_param_call(iopolicy, nvme_set_iopolicy, param_get_int,
+		  &iopolicy, 0644);
+MODULE_PARM_DESC(iopolicy,
+	"Default multipath I/O policy; 0 - NUMA (default), 1 - Round-robin");
Maybe make this a string? user will set numa|round-robin ? That is the
sysfs interface iirc...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help