multipathd: Add 'sysfs' prioritizer
cover multipathd: Add 'sysfs' prioritizer
Hi all,
hardly necessary to send an entire patchset, but there you go. I've now modified the sysfs prioritizer to generate the same priority the alua one would do, including the 'exclusive_pref_bit' setting.
So this should address the issues Ben raised.
Hannes Reinecke (2):
alua prioritizer: Fix typo 'perf'
multipathd: Add 'sysfs' prioritizer
libmultipath/discovery.c | 33 +++++++++++++++++++++ libmultipath/discovery.h | 2 ++ libmultipath/prio.h | 1 + libmultipath/prioritizers/Makefile | 3 +- libmultipath/prioritizers/alua.c | 8 ++--- libmultipath/prioritizers/sysfs.c | 61 ++++++++++++++++++++++++++++++++++++++ libmultipath/propsel.c | 6 +++- multipath/multipath.conf.5 | 17 +++++++++-- 8 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 libmultipath/prioritizers/sysfs.c
Signature · 1 line
2.6.6
PATCH 1/2 alua prioritizer: Fix typo 'perf'
The bit is called the 'preferred_path' bit. Nothing do to with performance.
--- libmultipath/prioritizers/alua.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
libmultipath/prioritizers/alua.c +4 -4
@@ -75,7 +75,7 @@ get_alua_info(struct path * pp)return rc; } -int get_exclusive_perf_arg (char *args) +int get_exclusive_pref_arg (char *args) {char *ptr;
@@ -96,12 +96,12 @@ int getprio (struct path * pp, char * args)int rc;int aas;int priopath; -int exclusive_perf; +int exclusive_pref;if (pp->fd <0 )return -ALUA_PRIO_NO_INFORMATION ; - exclusive_perf =get_exclusive_perf_arg (args); + exclusive_pref =get_exclusive_pref_arg (args); rc =get_alua_info (pp);if (rc >=0 ) { aas = (rc &0x0f );
@@ -122,7 +122,7 @@ int getprio (struct path * pp, char * args)default : rc =0 ; } -if (priopath && (aas !=AAS_OPTIMIZED || exclusive_perf)) +if (priopath && (aas !=AAS_OPTIMIZED || exclusive_pref)) rc +=80 ; }else {switch (-rc) {
Signature · 1 line
2.6.6
PATCH 2/2 multipathd: Add 'sysfs' prioritizer
In reply to Hannes ReineckeRecent kernels have an 'access_state' attribute which allows us to read the asymmetric access state directly from sysfs.
--- libmultipath/discovery.c | 33 +++++++++++++++++++++ libmultipath/discovery.h | 2 ++ libmultipath/prio.h | 1 + libmultipath/prioritizers/Makefile | 3 +- libmultipath/prioritizers/sysfs.c | 61 ++++++++++++++++++++++++++++++++++++++ libmultipath/propsel.c | 6 +++- multipath/multipath.conf.5 | 17 +++++++++-- 7 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 libmultipath/prioritizers/sysfs.c
libmultipath/discovery.c +33 -0
@@ -208,6 +208,8 @@ declare_sysfs_get_str(devtype);declare_sysfs_get_str (vendor);declare_sysfs_get_str (model);declare_sysfs_get_str (rev); +declare_sysfs_get_str (access_state); +declare_sysfs_get_str (preferred_path); ssize_t sysfs_get_vpd (struct udev_device * udev, int pg,
@@ -483,6 +485,37 @@ int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address)return 1 ; } +int +sysfs_get_asymmetric_access_state (struct path *pp,char *buff,int buflen) +{ +struct udev_device *parent = pp->udev; +char value[16 ], *eptr; +unsigned int preferred; + +while (parent) { +const char *subsys =udev_device_get_subsystem (parent); +if (subsys && !strncmp (subsys,"scsi" ,4 )) +break ; + parent =udev_device_get_parent (parent); + } + +if (!parent) +return -1 ; + +if (sysfs_get_access_state (parent, buff, buflen) <=0 ) +return -1 ; + +if (sysfs_get_preferred_path (parent, value,16 ) <=0 ) +return 0 ; + + preferred =strtoul (value, &eptr,0 ); +if (value == eptr || preferred ==ULONG_MAX ) { +/* Parse error, ignore */ +return 0 ; + } +return preferred; +} +static void sysfs_set_rport_tmo (struct multipath *mpp,struct path *pp) {
libmultipath/discovery.h +2 -0
@@ -47,6 +47,8 @@ int sysfs_get_host_pci_name(struct path *pp, char *pci_name);int sysfs_get_iscsi_ip_address (struct path *pp,char *ip_address);ssize_t sysfs_get_vpd (struct udev_device * udev,int pg,unsigned char * buff,size_t len); +int sysfs_get_asymmetric_access_state (struct path *pp, +char *buff,int buflen);/* * discovery bitmask
libmultipath/prio.h +1 -0
@@ -29,6 +29,7 @@ struct path;#define PRIO_RDAC "rdac"#define PRIO_DATACORE "datacore"#define PRIO_WEIGHTED_PATH "weightedpath" +#define PRIO_SYSFS "sysfs"/* * Value used to mark the fact prio was not defined
libmultipath/prioritizers/Makefile +2 -1
@@ -15,7 +15,8 @@ LIBS = \ libpriodatacore.so \ libpriohds.so \ libprioweightedpath.so \ - libprioiet.so + libprioiet.so \ + libpriosysfs.so CFLAGS += -I..
libmultipath/prioritizers/sysfs.c new file +61 -0
61 lines not on this page · raw message
libmultipath/propsel.c +5 -1
@@ -374,6 +374,7 @@ detect_prio(struct path * pp)int ret;struct prio *p = &pp->prio;int tpgs =0 ; +char buff[512 ];if ((tpgs =get_target_port_group_support (pp->fd)) <=0 )return ;
@@ -383,7 +384,10 @@ detect_prio(struct path * pp)return ;if (get_asymmetric_access_state (pp->fd, ret) <0 )return ; -prio_get (p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); +if (sysfs_get_asymmetric_access_state (pp, buff,512 ) <0 ) +prio_get (p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); +else +prio_get (p,PRIO_SYSFS ,DEFAULT_PRIO_ARGS ); }#define set_prio (src, msg) \
multipath/multipath.conf.5 +15 -2
@@ -203,6 +203,11 @@ Generate the path priority for NetApp arrays. .B rdac Generate the path priority for LSI/Engenio/NetApp E-Series RDAC controller. .TP +.B sysfs +Use the sysfs attributes access_state and preferred_path to generate the +path priority. This prioritizer accepts the optional prio_arg +.I exclusive_pref_bit +.TP .B hp_sw Generate the path priority for Compaq/HP controller in active/standby mode.
@@ -241,7 +246,7 @@ these values can be looked up through sysfs or by running .B alua If .I exclusive_pref_bit -is set, paths with the TPGS pref bit set will always be in their own path +is set, paths with the preferred path bit set will always be in their own path group. .RE .TP
@@ -449,8 +454,16 @@ If set to .I yes , multipath will try to detect if the device supports ALUA. If so, the device will automatically use the +.I sysfs +prioritizer if the required sysfs attributes +.I access_state +and +.I preferred_path +are supported, or the .I alua -prioritizer. If not, the prioritizer will be selected as usual. Default is +prioritizer if not. If set to +.I no +, the prioritizer will be selected as usual. Default is .I no .TP .B force_sync
Signature · 1 line
2.6.6
Benjamin Marzinski
maintainerQuoted 7 lines · Hannes Reinecke
Hi all,
hardly necessary to send an entire patchset, but there you go. I've now modified the sysfs prioritizer to generate the same priority the alua one would do, including the '
exclusive_pref_bit' setting.
So this should address the issues Ben raised.
Thanks
ACK
-Ben
Quoted 18 lines
Hannes Reinecke (2):
alua prioritizer: Fix typo 'perf'
multipathd: Add 'sysfs' prioritizerlibmultipath/discovery.c | 33 +++++++++++++++++++++ libmultipath/discovery.h | 2 ++ libmultipath/prio.h | 1 + libmultipath/prioritizers/Makefile | 3 +- libmultipath/prioritizers/alua.c | 8 ++--- libmultipath/prioritizers/sysfs.c | 61 ++++++++++++++++++++++++++++++++++++++ libmultipath/propsel.c | 6 +++- multipath/multipath.conf.5 | 17 +++++++++-- 8 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 libmultipath/prioritizers/sysfs.cSignature · 1 line
2.6.6