I'm working with JBODs and would like to access the disks inside through dm-multipath. For performance reasons I would like to use to prioritizer to pin individual disks to different paths. For testing purposes this can be done with the weighted_path prioritizer, but for production use this is unsatisfactory, as neither the device name nor the SCSI address are persistent over reboots. Thus I wrote a new, simple prioritizer to call an external program to determine what the prio should be. I would like to ask if there is interest to include this (or something similar) upstream (see attached patch). Remark: After I did this, I've seen the wwn regex mode in the upcoming 0.6 version, which would also provide a solution to the problem I started out with. But using this would still means one had to recreate multipath.conf each time one replaces a failed disk, so I still believe having an external upcall makes sense in some situations. Any thoughts?
From 124b54531dd1859755175ca5e9e4882d15cdd87d Mon Sep 17 00:00:00 2001 From: Oliver Mangold <oliver.mangold@xxxxxxxxxxxx> Date: Fri, 22 Apr 2016 12:53:55 +0200 Subject: [PATCH] libmultipath: adding new prioritizer 'upcall' to call external program --- libmultipath/prioritizers/Makefile | 1 + libmultipath/prioritizers/upcall.c | 25 +++++++++++++++++++++++++ multipath/multipath.conf.5 | 6 ++++++ 3 files changed, 32 insertions(+) create mode 100644 libmultipath/prioritizers/upcall.c diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index 6cfac88..1b32d00 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -15,6 +15,7 @@ LIBS = \ libpriodatacore.so \ libpriohds.so \ libprioweightedpath.so \ + libprioupcall.so \ libprioiet.so CFLAGS += -I.. diff --git a/libmultipath/prioritizers/upcall.c b/libmultipath/prioritizers/upcall.c new file mode 100644 index 0000000..175b8fe --- /dev/null +++ b/libmultipath/prioritizers/upcall.c @@ -0,0 +1,25 @@ +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#include <prio.h> +#include <structs.h> + +int getprio (struct path * pp, char * args) +{ + char* cmd; + int ret = asprintf(&cmd, "%s %s", args, pp->dev); + if (ret == -1) + return -1; + FILE* pipe = popen( cmd, "r" ); + free(cmd); + int prio; + int count = fscanf(pipe, "%i", &prio); + ret = pclose(pipe); + if (ret != 0) + return -1; + if (count != 1) + return -1; + return prio; +} diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index 0d4df0f..d8d6ad6 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -217,6 +217,9 @@ Generate a random priority between 1 and 10. Generate the path priority based on the regular expression and the priority provided as argument. requires prio_args keyword. .TP +.B upcall +Call an external program to calculate the priority. +.TP Default value is \fBnone\fR. .RE .TP @@ -243,6 +246,9 @@ If .I exclusive_pref_bit is set, paths with the TPGS pref bit set will always be in their own path group. +.TP +.B upcall +Cmdline to execute to determine device priority. The name of the component device of interest is added as the last argument. .RE .TP .B features -- 2.8.0
-- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel