Multipath patch sync
Subsystems (2)
Benjamin Marzinski
maintainerv2 cover Multipath patch sync
This is a resend of my previous batch of patches. The only one that has changed (besides in offsets) is patch 10 "multipathd: delay reloads during creation". I renamed the config option "missing_uev_wait_timeout". When it triggers, multipath will simply print a warning message and re-enable reloads as if it had received the uevent.
I also added a new patch that adds a new keyword to the weightedpath prioritizer, so that you can refer to paths in a persistent way.
Benjamin Marzinski (18):
multipathd: use /run instead of /var/run retrigger uevents to try and get the uid through udev Fix issues with user_friendly_names initramfs bindings Add libmpathcmd library and use it internally
libmultipath: add ignore_new_boot_devs option
libmultipath: fix PAD and PRINT macros
libmultipath: Cut down on alua prioritizer ioctls
multipathd: fail if pidfile can't be created
libmultipath: check correct function for define
multipathd: delay reloads during creation
multipath: Fix minor text issues
kpartx: verify partition devices
multipath: add exclusive_pref_bit for alua prio
multipathd: print "fail" when remove fails
multipath: check partitions unused before removing multipathd.service: remove blk-availability Requires
multipathd: use 64-bit int for command key
multipath: add wwn keyword to weightedpath prio
Makefile | 1 + Makefile.inc | 12 +- kpartx/devmapper.c | 17 ++- kpartx/devmapper.h | 2 +- kpartx/kpartx.c | 70 ++++++++++- libmpathcmd/Makefile | 30 +++++ libmpathcmd/mpath_cmd.c | 178 +++++++++++++++++++++++++++ libmpathcmd/mpath_cmd.h | 125 +++++++++++++++++++ libmpathpersist/Makefile | 9 +- libmpathpersist/mpath_persist.c | 2 +- libmpathpersist/mpath_updatepr.c | 14 +-- libmultipath/Makefile | 5 +- libmultipath/config.c | 7 +- libmultipath/config.h | 5 + libmultipath/configure.c | 20 +-- libmultipath/defaults.h | 6 +- libmultipath/devmapper.c | 46 +++++-- libmultipath/devmapper.h | 2 +- libmultipath/dict.c | 20 ++- libmultipath/discovery.c | 28 +++-- libmultipath/discovery.h | 2 + libmultipath/print.c | 25 ++-- libmultipath/print.h | 4 + libmultipath/prioritizers/alua.c | 44 ++++--- libmultipath/prioritizers/alua_rtpg.c | 69 +++++++---- libmultipath/prioritizers/alua_rtpg.h | 2 +- libmultipath/prioritizers/weightedpath.c | 37 ++++++ libmultipath/prioritizers/weightedpath.h | 1 + libmultipath/propsel.c | 2 +- libmultipath/structs.h | 10 ++ libmultipath/uxsock.c | 73 +++-------- libmultipath/uxsock.h | 5 +- libmultipath/wwids.c | 19 +-- mpathpersist/Makefile | 2 +- multipath.conf.defaults | 1 + multipath/Makefile | 5 +- multipath/main.c | 6 +- multipath/multipath.conf.5 | 36 +++++- multipathd/Makefile | 5 +- multipathd/cli.c | 22 ++-- multipathd/cli.h | 20 +-- multipathd/cli_handlers.c | 73 ++++++++--- multipathd/main.c | 205 ++++++++++++++++++++++++++----- multipathd/main.h | 1 + multipathd/multipathd.8 | 4 + multipathd/multipathd.init.suse | 2 +- multipathd/multipathd.service | 3 +- multipathd/uxclnt.c | 13 +- multipathd/uxlsnr.c | 11 +- 49 files changed, 1031 insertions(+), 270 deletions(-) create mode 100644 libmpathcmd/Makefile create mode 100644 libmpathcmd/mpath_cmd.c create mode 100644 libmpathcmd/mpath_cmd.h
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 1/18 multipathd: use /run instead of /var/run
/var/run is now usually a symlink to /run. If /var is on a separate filesytem, when multipathd starts up, it might end up writing to /var/run before the /var filesytem is mounted and thus not have its pidfile accessible at /var/run afterwards. On most distrubutions /run is now a tmpfs and should always be available before multipathd is started, so multipath should just write there directly, instead of through the symlink.
If /var/run is not a symlink, continue using it.
--- Makefile.inc | 10 +++++++++- libmultipath/defaults.h | 2 +- multipathd/multipathd.init.suse | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
Makefile.inc +9 -1
@@ -21,6 +21,14 @@ ifndef LIB endif endif +ifndef RUN + ifeq ($(shell test -L /var/run -o ! -d /var/run && echo 1),1) + RUN=run + else + RUN=var/run + endif +endif + ifndef SYSTEMD ifeq ($(shell systemctl --version > /dev/null 2>&1 && echo 1), 1) SYSTEMD = $(shell systemctl --version 2> /dev/null | sed -n 's/systemd \([0-9]*\)/\1/p')
@@ -54,7 +62,7 @@ ifndef RPM_OPT_FLAGS endif OPTFLAGS = $(RPM_OPT_FLAGS) -Wunused -Wstrict-prototypes -CFLAGS = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\" +CFLAGS = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" SHARED_FLAGS = -shared %.o: %.c
libmultipath/defaults.h +1 -1
@@ -26,7 +26,7 @@#define MAX_CHECKINT (a) (a << 2)#define MAX_DEV_LOSS_TMO 0x7FFFFFFF -#define DEFAULT_PIDFILE "/var/run/multipathd.pid" +#define DEFAULT_PIDFILE "/" RUN_DIR "/multipathd.pid"#define DEFAULT_SOCKET "/org/kernel/linux/storage/multipathd"#define DEFAULT_CONFIGFILE "/etc/multipath.conf"#define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"
multipathd/multipathd.init.suse +1 -1
@@ -17,7 +17,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/sbin/multipathd -PIDFILE=/var/run/multipathd.pid +PIDFILE=/run/multipathd.pid MPATH_INIT_TIMEOUT=10 ARGS=""
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 2/18 retrigger uevents to try and get the uid through udev
In reply to Benjamin MarzinskiIdeally, udev will be able to grab the wwid when a path device is discovered, but sometimes this isn't possible. In these cases, the best thing that could happen would be for udev to actually get the information, and add it to its database. This patch makes multipath retrigger uevents a limited number of times before giving up and trying to get the information itself.
There are two configurables that control how it does this, "retrigger_tries" and "retrigger_delay". The first sets the number of times it will try to retrigger a uevent to get the wwid, the second sets the amount of time to wait between retriggers.
This patch currently only tries reinitializing the path on change events after multipathd has triggered a change event, and it only tries once per triggered change event. Now, its possible that other change events could occur on the device without multipathd tirggering them. As the patch stands now, it won't try to initialize the device on those. It will, however still try in the checkerloop, but only after it has finished retriggering the uevents. We could be much more aggressive here, and assume that devices that simply won't have a WWID should already be taken care of by the blacklists, so it would be always a good idea to recheck devices on change events. What would be ideal is if udev would let us know when it had problems or timed out when processing a uevent, so we would know if retiggering the uevent would be useful.
--- libmultipath/config.c | 2 ++ libmultipath/config.h | 2 ++ libmultipath/defaults.h | 2 ++ libmultipath/dict.c | 8 ++++++++ libmultipath/discovery.c | 28 ++++++++++++++++------------ libmultipath/structs.h | 8 ++++++++ multipathd/main.c | 40 +++++++++++++++++++++++++--------------- 7 files changed, 63 insertions(+), 27 deletions(-)
libmultipath/config.c +2 -0
@@ -619,6 +619,8 @@ load_config (char * file, struct udev *udev) conf->find_multipaths =DEFAULT_FIND_MULTIPATHS ; conf->uxsock_timeout =DEFAULT_UXSOCK_TIMEOUT ; conf->uid_attribute =set_default (DEFAULT_UID_ATTRIBUTE ); + conf->retrigger_tries =DEFAULT_RETRIGGER_TRIES ; + conf->retrigger_delay =DEFAULT_RETRIGGER_DELAY ;/* * preload default hwtable
libmultipath/config.h +2 -0
@@ -135,6 +135,8 @@ struct config {int delay_watch_checks;int delay_wait_checks;int uxsock_timeout; +int retrigger_tries; +int retrigger_delay;unsigned int version[3 ];char * dev;
libmultipath/defaults.h +2 -0
@@ -21,6 +21,8 @@#define DEFAULT_DELAY_CHECKS DELAY_CHECKS_OFF#define DEFAULT_UEVENT_STACKSIZE 256#define DEFAULT_UXSOCK_TIMEOUT 1000 +#define DEFAULT_RETRIGGER_DELAY 10 +#define DEFAULT_RETRIGGER_TRIES 3#define DEFAULT_CHECKINT 5#define MAX_CHECKINT (a) (a << 2)
libmultipath/dict.c +8 -0
@@ -389,6 +389,12 @@ declare_hw_snprint(deferred_remove, print_yes_no_undef) declare_mp_handler(deferred_remove, set_yes_no_undef) declare_mp_snprint(deferred_remove, print_yes_no_undef) +declare_def_handler(retrigger_tries, set_int) +declare_def_snprint(retrigger_tries, print_int) + +declare_def_handler(retrigger_delay, set_int) +declare_def_snprint(retrigger_delay, print_int) +static int def_config_dir_handler (vector strvec) {
@@ -1365,6 +1371,8 @@ init_keywords(void)install_keyword ("delay_wait_checks" , &def_delay_wait_checks_handler, &snprint_def_delay_wait_checks);install_keyword ("find_multipaths" , &def_find_multipaths_handler, &snprint_def_find_multipaths);install_keyword ("uxsock_timeout" , &def_uxsock_timeout_handler, &snprint_def_uxsock_timeout); +install_keyword ("retrigger_tries" , &def_retrigger_tries_handler, &snprint_def_retrigger_tries); +install_keyword ("retrigger_delay" , &def_retrigger_delay_handler, &snprint_def_retrigger_delay);__deprecated install_keyword ("default_selector" , &def_selector_handler,NULL );__deprecated install_keyword ("default_path_grouping_policy" , &def_pgpolicy_handler,NULL );__deprecated install_keyword ("default_uid_attribute" , &def_uid_attribute_handler,NULL );
libmultipath/discovery.c +16 -12
@@ -1547,7 +1547,7 @@ get_uid (struct path * pp) pp->dev, strerror(-len)); } -if (len <=0 && +if (len <=0 && pp->retriggers >= conf->retrigger_tries && !strcmp (pp->uid_attribute,DEFAULT_UID_ATTRIBUTE )) { len =get_vpd_uid (pp); origin ="sysfs" ;
@@ -1651,11 +1651,19 @@ pathinfo (struct path *pp, vector hwtable, int mask) } } -if ((mask &DI_WWID ) && !strlen (pp->wwid)) +if ((mask &DI_WWID ) && !strlen (pp->wwid)) {get_uid (pp); +if (!strlen (pp->wwid)) { + pp->initialized =INIT_MISSING_UDEV ; + pp->tick = conf->retrigger_delay; +return PATHINFO_OK ; + } +else + pp->tick =1 ; + } +if (mask &DI_BLACKLIST && mask &DI_WWID ) { -if (!strlen (pp->wwid) || -filter_wwid (conf->blist_wwid, conf->elist_wwid, +if (filter_wwid (conf->blist_wwid, conf->elist_wwid, pp->wwid, pp->dev) >0 ) {return PATHINFO_SKIPPED ; }
@@ -1665,17 +1673,13 @@ pathinfo (struct path *pp, vector hwtable, int mask)* Retrieve path priority, even for PATH_DOWN paths if it has never * been successfully obtained before. */ -if ((mask &DI_PRIO ) && path_state ==PATH_UP ) { +if ((mask &DI_PRIO ) && path_state ==PATH_UP &&strlen (pp->wwid)) {if (pp->state !=PATH_DOWN || pp->priority ==PRIO_UNDEF ) { -if (!strlen (pp->wwid)) -get_uid (pp); -if (!strlen (pp->wwid)) -return PATHINFO_SKIPPED ;get_prio (pp); } } - pp->initialized =1 ; + pp->initialized =INIT_OK ;return PATHINFO_OK ; blank:
@@ -1684,7 +1688,7 @@ blank:*/ memset (pp->wwid,0 ,WWID_SIZE ); pp->chkrstate = pp->state =PATH_DOWN ; - pp->initialized =0 ; + pp->initialized =INIT_FAILED ; -return 0 ; +return PATHINFO_OK ; }
libmultipath/structs.h +8 -0
@@ -145,6 +145,13 @@ enum delay_checks_states { DELAY_CHECKS_UNDEF = 0, }; +enum initialized_states { +INIT_FAILED , +INIT_MISSING_UDEV , +INIT_REQUESTED_UDEV , +INIT_OK , +}; +struct sg_id {int host_no;int channel;
@@ -202,6 +209,7 @@ struct path {struct multipath * mpp;int fd;int initialized; +int retriggers;/* configlet pointers */ struct hwentry * hwe;
multipathd/main.c +25 -15
@@ -458,11 +458,6 @@ uev_add_path (struct uevent *uev, struct vectors * vecs)condlog (3 ,"%s: failed to get path info" , uev->kernel);return 1 ; } -if (!strlen (pp->wwid)) { -condlog (3 ,"%s: Failed to get path wwid" , uev->kernel); -free_path (pp); -return 1 ; - } ret =store_path (vecs->pathvec, pp);if (!ret) { pp->checkint = conf->checkint;
@@ -722,20 +717,23 @@ static int uev_update_path (struct uevent *uev, struct vectors * vecs) { int ro, retval = 0; +struct path * pp; + + pp =find_path_by_dev (vecs->pathvec, uev->kernel); +if (!pp) { +condlog (0 ,"%s: spurious uevent, path not found" , + uev->kernel); +return 1 ; + } + +if (pp->initialized ==INIT_REQUESTED_UDEV ) +return uev_add_path (uev, vecs); ro =uevent_get_disk_ro (uev);if (ro >=0 ) { -struct path * pp; -condlog (2 ,"%s: update path write_protect to '%d' (uevent)" , uev->kernel, ro); - pp =find_path_by_dev (vecs->pathvec, uev->kernel); -if (!pp) { -condlog (0 ,"%s: spurious uevent, path not found" , - uev->kernel); -return 1 ; - }if (pp->mpp) { retval =reload_map (vecs, pp->mpp,0 );
@@ -1165,12 +1163,24 @@ check_path (struct vectors * vecs, struct path * pp)int disable_reinstate =0 ;int oldchkrstate = pp->chkrstate; -if (pp->initialized && !pp->mpp) +if ((pp->initialized ==INIT_OK || + pp->initialized ==INIT_REQUESTED_UDEV ) && !pp->mpp)return 0 ;if (pp->tick && --pp->tick)return 0 ;/* don't check this path yet */ +if (!pp->mpp && pp->initialized ==INIT_MISSING_UDEV && + pp->retriggers < conf->retrigger_tries) { +condlog (2 ,"%s: triggering change event to reinitialize" , + pp->dev); + pp->initialized =INIT_REQUESTED_UDEV ; + pp->retriggers++; +sysfs_attr_set_value (pp->udev,"uevent" ,"change" , +strlen ("change" )); +return 0 ; + } +/* * provision a next check soonest, * in case we exit abnormaly from here
@@ -1197,7 +1207,7 @@ check_path (struct vectors * vecs, struct path * pp)return 1 ; }if (!pp->mpp) { -if (!strlen (pp->wwid) && +if (!strlen (pp->wwid) && pp->initialized !=INIT_MISSING_UDEV && (newstate ==PATH_UP || newstate ==PATH_GHOST )) {condlog (2 ,"%s: add missing path" , pp->dev);if (pathinfo (pp, conf->hwtable,DI_ALL ) ==0 ) {
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 3/18 Fix issues with user_friendly_names initramfs bindings
In reply to Benjamin MarzinskiMultipath has an issue with user_friendly_names set in the initramfs. If the bindings are in the initramfs bindings file, it will create them, and it may use bindings that are different than the ones in the regular file system. Once multipathd starts up in the regular file system, it will try to register the existing bindings, but that may (and in many cases, is likely to) fail. If it can't reanme it, will pick a new binding. Since when multipathd starts discovering the existing devices, it obviously doesn't know all of the existing devices yet, it may very well pick a binding that's already in use by a device that it hasn't discovered yet. In this case multipath will be unable to rename the device to the new binding. Unfortunately, if it fails the rename, it never resets the alias of the device stored in the mpvec to current alias of the actual dm device. So multipath will have devices in the mpvec where the alias and the wwid don't match the actual dm devices that exist. This can cause all sorts of problems.
This patch does two things to deal with this. First, it makes sure that if the rename fails, the device will reset its alias to the one that it currently has. Second, it fixes the -B option to actually work correctly, so that it can be started that way in the initramfs.
--- libmultipath/config.c | 1 - libmultipath/configure.c | 3 +++ multipathd/main.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
libmultipath/config.c +0 -1
@@ -601,7 +601,6 @@ load_config (char * file, struct udev *udev)get_sys_max_fds (&conf->max_fds); conf->bindings_file =set_default (DEFAULT_BINDINGS_FILE ); conf->wwids_file =set_default (DEFAULT_WWIDS_FILE ); - conf->bindings_read_only =0 ; conf->multipath_dir =set_default (DEFAULT_MULTIPATHDIR ); conf->features =set_default (DEFAULT_FEATURES ); conf->flush_on_last_del =0 ;
libmultipath/configure.c +3 -0
@@ -421,6 +421,9 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)condlog (2 ,"%s: unable to rename %s to %s (%s is used by %s)" , mpp->wwid, cmpp->alias, mpp->alias, mpp->alias, cmpp_by_name->wwid); +/* reset alias to existing alias */ +FREE (mpp->alias); + mpp->alias =STRDUP (cmpp->alias); mpp->action =ACT_NOTHING ;return ; }
multipathd/main.c +1 -0
@@ -1570,6 +1570,7 @@ reconfigure (struct vectors * vecs)if (!load_config (DEFAULT_CONFIGFILE , udev)) {dm_drv_version (conf->version,TGT_MPATH ); conf->verbosity = old->verbosity; + conf->bindings_read_only = old->bindings_read_only; conf->daemon =1 ;configure (vecs,1 );free_config (old);
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 4/18 Add libmpathcmd library and use it internally
In reply to Benjamin MarzinskiOther programs would like to communicate with multipathd to issue command or check status. Instead of having them exec multipathd, I've pulled the code that sends commands and receives replies from multipathd into its own library. I've made the multipath tools use this library internally as well.
--- Makefile | 1 + Makefile.inc | 2 + libmpathcmd/Makefile | 30 +++++++ libmpathcmd/mpath_cmd.c | 178 +++++++++++++++++++++++++++++++++++++++ libmpathcmd/mpath_cmd.h | 125 +++++++++++++++++++++++++++ libmpathpersist/Makefile | 9 +- libmpathpersist/mpath_updatepr.c | 14 +-- libmultipath/Makefile | 3 +- libmultipath/config.c | 3 +- libmultipath/configure.c | 10 +-- libmultipath/defaults.h | 1 - libmultipath/dict.c | 8 +- libmultipath/uxsock.c | 73 ++++------------ libmultipath/uxsock.h | 5 +- mpathpersist/Makefile | 2 +- multipath/Makefile | 5 +- multipath/main.c | 5 +- multipathd/Makefile | 5 +- multipathd/main.c | 1 + multipathd/uxclnt.c | 13 ++- multipathd/uxlsnr.c | 11 +-- 21 files changed, 398 insertions(+), 106 deletions(-) create mode 100644 libmpathcmd/Makefile create mode 100644 libmpathcmd/mpath_cmd.c create mode 100644 libmpathcmd/mpath_cmd.h
Makefile +1 -0
@@ -20,6 +20,7 @@ export KRNLSRC export KRNLOBJ BUILDDIRS = \ + libmpathcmd \ libmultipath \ libmultipath/prioritizers \ libmultipath/checkers \
Makefile.inc +2 -0
@@ -50,9 +50,11 @@ man5dir = $(prefix)/usr/share/man/man5 man3dir = $(prefix)/usr/share/man/man3 rcdir = $(prefix)/etc/init.d syslibdir = $(prefix)/$(LIB) +incdir = $(prefix)/usr/include libdir = $(prefix)/$(LIB)/multipath unitdir = $(prefix)/$(SYSTEMDPATH)/systemd/system mpathpersistdir = $(TOPDIR)/libmpathpersist +mpathcmddir = $(TOPDIR)/libmpathcmd GZIP = gzip -9 -c INSTALL_PROGRAM = install
libmpathcmd/Makefile new file +30 -0
@@ -0,0 +1,30 @@ +# Makefile +# +include ../Makefile.inc + +SONAME=0 +DEVLIB = libmpathcmd.so +LIBS = $(DEVLIB).$(SONAME) + +OBJS = mpath_cmd.o + +all: $(LIBS) + +$(LIBS): $(OBJS) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ $(CFLAGS) -o $@ $(OBJS) $(LIBDEPS) + ln -sf $@ $(DEVLIB) + +install: $(LIBS) + $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir) + $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS) + ln -sf $(LIBS) $(DESTDIR)$(syslibdir)/$(DEVLIB) + $(INSTALL_PROGRAM) -d $(DESTDIR)$(incdir) + $(INSTALL_PROGRAM) -m 755 mpath_cmd.h $(DESTDIR)$(incdir) + +uninstall: + rm -f $(DESTDIR)$(syslibdir)/$(LIBS) + rm -f $(DESTDIR)$(syslibdir)/$(DEVLIB) + rm -f $(DESTDIR)$(incdir)/mpath_cmd.h + +clean: + rm -f core *.a *.o *.gz *.so *.so.*
libmpathcmd/mpath_cmd.c new file +178 -0
178 lines not on this page · raw message
libmpathcmd/mpath_cmd.h new file +125 -0
125 lines not on this page · raw message
libmpathpersist/Makefile +5 -4
@@ -10,8 +10,9 @@ DEVLIB = libmpathpersist.so LIBS = $(DEVLIB).$(SONAME) -CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath +CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) +LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \ + -L$(mpathcmddir) -lmpathcmd OBJS = mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o
@@ -30,12 +31,12 @@ install: $(LIBS) $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS) $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(syslibdir) $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(man3dir) - $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)/usr/include/ + $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(incdir) $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)/usr/share/doc/mpathpersist/ ln -sf $(DESTDIR)$(syslibdir)/$(LIBS) $(DESTDIR)$(syslibdir)/$(DEVLIB) install -m 644 mpath_persistent_reserve_in.3.gz $(DESTDIR)$(man3dir) install -m 644 mpath_persistent_reserve_out.3.gz $(DESTDIR)$(man3dir) - install -m 644 mpath_persist.h $(DESTDIR)/usr/include/ + install -m 644 mpath_persist.h $(DESTDIR)$(incdir) uninstall: rm -f $(DESTDIR)$(syslibdir)/$(LIBS)
libmpathpersist/mpath_updatepr.c +7 -7
@@ -12,9 +12,9 @@#include <sys/poll.h> #include <errno.h> #include <debug.h> +#include <mpath_cmd.h> +#include <uxsock.h> #include "memory.h" -#include "../libmultipath/uxsock.h" -#include "../libmultipath/defaults.h" unsigned long mem_allocated;/* Total memory used in Bytes */
@@ -23,10 +23,9 @@ int update_prflag(char * arg1, char * arg2, int noisy)int fd;char str[64 ];char *reply; -size_t len;int ret =0 ; - fd =ux_socket_connect (DEFAULT_SOCKET ); + fd =mpath_connect ();if (fd ==-1 ) {condlog (0 ,"ux socket connect error" );return 1 ;
@@ -34,10 +33,10 @@ int update_prflag(char * arg1, char * arg2, int noisy)snprintf (str,sizeof (str),"map %s %s" , arg1, arg2);condlog (2 ,"%s: pr flag message=%s" , arg1, str); -send_packet (fd, str,strlen (str) +1 ); - ret =recv_packet (fd, &reply, &len,DEFAULT_UXSOCK_TIMEOUT ); +send_packet (fd, str); + ret =recv_packet (fd, &reply,DEFAULT_REPLY_TIMEOUT );if (ret <0 ) { -condlog (2 ,"%s: message=%s error=%d" , arg1, str, -ret); +condlog (2 ,"%s: message=%s error=%d" , arg1, str, errno); ret =-2 ; }else {condlog (2 ,"%s: message=%s reply=%s" , arg1, str, reply);
@@ -51,5 +50,6 @@ int update_prflag(char * arg1, char * arg2, int noisy) }free (reply); +mpath_disconnect (fd);return ret; }
libmultipath/Makefile +2 -1
@@ -7,7 +7,8 @@ include ../Makefile.inc SONAME=0 DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) -LIBDEPS = -lpthread -ldl -ldevmapper -ludev +CFLAGS += -I$(mpathcmddir) +LIBDEPS = -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd ifdef SYSTEMD ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) LIBDEPS += -lsystemd
libmultipath/config.c +2 -1
@@ -24,6 +24,7 @@#include "defaults.h" #include "prio.h" #include "devmapper.h" +#include "mpath_cmd.h" static int hwe_strmatch (struct hwentry *hwe1,struct hwentry *hwe2)
@@ -616,7 +617,7 @@ load_config (char * file, struct udev *udev) conf->partition_delim =NULL ; conf->processed_main_config =0 ; conf->find_multipaths =DEFAULT_FIND_MULTIPATHS ; - conf->uxsock_timeout =DEFAULT_UXSOCK_TIMEOUT ; + conf->uxsock_timeout =DEFAULT_REPLY_TIMEOUT ; conf->uid_attribute =set_default (DEFAULT_UID_ATTRIBUTE ); conf->retrigger_tries =DEFAULT_RETRIGGER_TRIES ; conf->retrigger_delay =DEFAULT_RETRIGGER_DELAY ;
libmultipath/configure.c +5 -5
@@ -14,6 +14,7 @@#include <errno.h> #include <libdevmapper.h> #include <libudev.h> +#include <mpath_cmd.h> #include "checkers.h" #include "vector.h"
@@ -708,16 +709,15 @@ int check_daemon(void) {int fd;char *reply; -size_t len;int ret =0 ; - fd =ux_socket_connect (DEFAULT_SOCKET ); + fd =mpath_connect ();if (fd ==-1 )return 0 ; -if (send_packet (fd,"show daemon" ,12 ) !=0 ) +if (send_packet (fd,"show daemon" ) !=0 ) goto out; -if (recv_packet (fd, &reply, &len, conf->uxsock_timeout) !=0 ) +if (recv_packet (fd, &reply, conf->uxsock_timeout) !=0 ) goto out;if (strstr (reply,"shutdown" ))
@@ -728,7 +728,7 @@ int check_daemon(void) out_free:FREE (reply); out: -close (fd); +mpath_disconnect (fd);return ret; }
libmultipath/defaults.h +0 -1
@@ -20,7 +20,6 @@#define DEFAULT_DEFERRED_REMOVE DEFERRED_REMOVE_OFF#define DEFAULT_DELAY_CHECKS DELAY_CHECKS_OFF#define DEFAULT_UEVENT_STACKSIZE 256 -#define DEFAULT_UXSOCK_TIMEOUT 1000#define DEFAULT_RETRIGGER_DELAY 10#define DEFAULT_RETRIGGER_TRIES 3
libmultipath/dict.c +3 -5
@@ -21,6 +21,7 @@#include "prio.h" #include "errno.h" #include <inttypes.h> +#include <mpath_cmd.h> static int set_int (vector strvec,void *ptr)
@@ -1051,10 +1052,10 @@ def_uxsock_timeout_handler(vector strvec)return 1 ;if (sscanf (buff,"%u" , &uxsock_timeout) ==1 && - uxsock_timeout >DEFAULT_UXSOCK_TIMEOUT ) + uxsock_timeout >DEFAULT_REPLY_TIMEOUT ) conf->uxsock_timeout = uxsock_timeout;else - conf->uxsock_timeout =DEFAULT_UXSOCK_TIMEOUT ; + conf->uxsock_timeout =DEFAULT_REPLY_TIMEOUT ;free (buff);return 0 ;
@@ -1143,9 +1144,6 @@ declare_ble_handler(elist_property)static int snprint_def_uxsock_timeout (char * buff,int len,void * data) { -if (conf->uxsock_timeout ==DEFAULT_UXSOCK_TIMEOUT ) -return 0 ; -return snprintf (buff, len,"%u" , conf->uxsock_timeout); }
libmultipath/uxsock.c +15 -58
106 lines not on this page · raw message
libmultipath/uxsock.h +2 -3
@@ -1,7 +1,6 @@/* some prototypes */ -int ux_socket_connect (const char *name);int ux_socket_listen (const char *name); -int send_packet (int fd,const char *buf,size_t len); -int recv_packet (int fd,char **buf,size_t *len,unsigned int timeout); +int send_packet (int fd,const char *buf); +int recv_packet (int fd,char **buf,unsigned int timeout);size_t write_all (int fd,const void *buf,size_t len);ssize_t read_all (int fd,void *buf,size_t len,unsigned int timeout);
mpathpersist/Makefile +1 -1
@@ -5,7 +5,7 @@ include ../Makefile.inc OBJS = main.o CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -LDFLAGS += -lpthread -ldevmapper -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath -ludev +LDFLAGS += -lpthread -ldevmapper -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -L$(mpathcmddir) -lmpathcmd -lmultipath -ludev EXEC = mpathpersist
multipath/Makefile +3 -2
@@ -6,8 +6,9 @@ include ../Makefile.inc OBJS = main.o -CFLAGS += -I$(multipathdir) -LDFLAGS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath -ludev +CFLAGS += -I$(multipathdir) -I$(mpathcmddir) +LDFLAGS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath -ludev \ + -L$(mpathcmddir) -lmpathcmd EXEC = multipath
multipath/main.c +3 -2
@@ -57,6 +57,7 @@#include <sys/resource.h> #include <wwids.h> #include <uxsock.h> +#include <mpath_cmd.h> int logsink;
@@ -633,13 +634,13 @@ main (int argc, char *argv[]) conf->dev_type == DEV_UEVENT) {int fd; - fd =ux_socket_connect (DEFAULT_SOCKET ); + fd =mpath_connect ();if (fd ==-1 ) {printf ("%s is not a valid multipath device path\n" , conf->dev); goto out; } -close (fd); +mpath_disconnect (fd); }if (conf->cmd ==CMD_REMOVE_WWID && !conf->dev) {condlog (0 ,"the -w option requires a device" );
multipathd/Makefile +3 -2
@@ -5,7 +5,7 @@ include ../Makefile.inc # # basic flags setting # -CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) +CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) ifdef SYSTEMD CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) endif
@@ -18,7 +18,8 @@ ifdef SYSTEMD endif endif LDFLAGS += -ludev -ldl \ - -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist + -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ + -L$(mpathcmddir) -lmpathcmd # # debuging stuff
multipathd/main.c +1 -0
@@ -21,6 +21,7 @@#include <systemd/sd-daemon.h> #endif #include <semaphore.h> +#include <mpath_cmd.h> #include <mpath_persist.h> #include <time.h>
multipathd/uxclnt.c +6 -7
@@ -18,6 +18,7 @@#include <readline/readline.h> #include <readline/history.h> +#include <mpath_cmd.h> #include <uxsock.h> #include <memory.h> #include <defaults.h>
@@ -74,7 +75,6 @@ static void process(int fd, unsigned int timeout) rl_readline_name ="multipathd" ; rl_completion_entry_function = key_generator;while ((line =readline ("multipathd> " ))) { -size_t len;size_t llen =strlen (line);if (!llen) {
@@ -85,8 +85,8 @@ static void process(int fd, unsigned int timeout)if (need_quit (line, llen))break ; -if (send_packet (fd, line, llen +1 ) !=0 )break ; - ret =recv_packet (fd, &reply, &len, timeout); +if (send_packet (fd, line) !=0 )break ; + ret =recv_packet (fd, &reply, timeout);if (ret !=0 )break ;print_reply (reply);
@@ -102,14 +102,13 @@ static void process(int fd, unsigned int timeout)static void process_req (int fd,char * inbuf,unsigned int timeout) {char *reply; -size_t len;int ret; -if (send_packet (fd, inbuf,strlen (inbuf) +1 ) !=0 ) { +if (send_packet (fd, inbuf) !=0 ) {printf ("cannot send packet\n" );return ; } - ret =recv_packet (fd, &reply, &len, timeout); + ret =recv_packet (fd, &reply, timeout);if (ret <0 ) {if (ret == -ETIMEDOUT )printf ("timeout receiving packet\n" );
@@ -128,7 +127,7 @@ int uxclnt(char * inbuf, unsigned int timeout) {int fd; - fd =ux_socket_connect (DEFAULT_SOCKET ); + fd =mpath_connect ();if (fd ==-1 )exit (1 );
multipathd/uxlsnr.c +4 -7
@@ -31,6 +31,7 @@#include <uxsock.h> #include <defaults.h> #include <config.h> +#include <mpath_cmd.h> #include "main.h" #include "cli.h"
@@ -128,7 +129,6 @@ void uxsock_cleanup(void *arg)void *uxsock_listen (uxsock_trigger_fn uxsock_trigger,void * trigger_data) {int ux_sock; -size_t len;int rlen, timeout;char *inbuf;char *reply;
@@ -236,18 +236,15 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data) }if (gettimeofday (&start_time,NULL ) !=0 ) start_time.tv_sec =0 ; - -if (recv_packet (c->fd, &inbuf, &len, - timeout) !=0 ) { +if (recv_packet (c->fd, &inbuf, timeout) !=0 ) {dead_client (c); }else { - inbuf[len -1 ] =0 ;condlog (4 ,"Got request [%s]" , inbuf);uxsock_trigger (inbuf, &reply, &rlen, trigger_data);if (reply) { -if (send_packet (c->fd, reply, - rlen) !=0 ) { +if (send_packet (c->fd, + reply) !=0 ) {dead_client (c); } condlog(4, "Reply [%d bytes]",
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 5/18 libmultipath: add ignore_new_boot_devs option
In reply to Benjamin MarzinskiWhen multipath relies on the wwids file to determine whether a device is a multipath path (with "multipath -c"), it will fail the first time a new multipathable device is discovered, since the wwid clearly won't be in the wwids file. This is usually fine. Multipath will still set itself up on the device, and add the wwid to the wwids file. However, this causes a race, where multipath won't claim the path immediately, and something else may. Later multipath will try, and possibly succeed at, setting itself up on that device.
I've seen cases where this can cause problems during boot on and immediately after install, where multipath racing with LVM on an already labelled device can get the machine into a state where boot fails. This can be avoided if multipath simply doesn't set itself up on any devices that it didn't claim (with "multipath -c") in the initramfs. It can still safely attempt to set itself up on these devices later in boot, after the regular filesystem has been set up.
To allow this, this patch adds a new multipahtd commandline option, -n. When multipathd is run with this set, it will not create multipath devices if their wwid isn't already in the wwids file. This means that only devices that are claimed by "multipath -c" will be used by multipathd.
--- libmultipath/config.h | 1 + libmultipath/configure.c | 3 +-- libmultipath/wwids.c | 19 ++++++++++++------- multipathd/main.c | 9 ++++++--- multipathd/multipathd.8 | 4 ++++ 5 files changed, 24 insertions(+), 12 deletions(-)
libmultipath/config.h +1 -0
@@ -137,6 +137,7 @@ struct config {int uxsock_timeout;int retrigger_tries;int retrigger_delay; +int ignore_new_devs;unsigned int version[3 ];char * dev;
libmultipath/configure.c +1 -2
@@ -778,8 +778,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rcontinue ;/* If find_multipaths was selected check if the path is valid */ -if (conf->find_multipaths && !refwwid && - !should_multipath (pp1, pathvec)) { +if (!refwwid && !should_multipath (pp1, pathvec)) {orphan_path (pp1,"only one path" );continue ; }
libmultipath/wwids.c +12 -7
@@ -266,14 +266,19 @@ should_multipath(struct path *pp1, vector pathvec)int i;struct path *pp2; +if (!conf->find_multipaths && !conf->ignore_new_devs) +return 1 ; +condlog (4 ,"checking if %s should be multipathed" , pp1->dev); - vector_foreach_slot(pathvec, pp2, i) { -if (pp1->dev == pp2->dev) -continue ; -if (strncmp (pp1->wwid, pp2->wwid,WWID_SIZE ) ==0 ) { -condlog (3 ,"found multiple paths with wwid %s, " -"multipathing %s" , pp1->wwid, pp1->dev); -return 1 ; +if (!conf->ignore_new_devs) { + vector_foreach_slot(pathvec, pp2, i) { +if (pp1->dev == pp2->dev) +continue ; +if (strncmp (pp1->wwid, pp2->wwid,WWID_SIZE ) ==0 ) { +condlog (3 ,"found multiple paths with wwid %s, " +"multipathing %s" , pp1->wwid, pp1->dev); +return 1 ; + } } }if (check_wwids_file (pp1->wwid,0 ) <0 ) {
multipathd/main.c +6 -3
@@ -518,8 +518,7 @@ rescan: mpp->flush_on_last_del =FLUSH_UNDEF ; mpp->action =ACT_RELOAD ; }else { -if (conf->find_multipaths && - !should_multipath (pp, vecs->pathvec)) { +if (!should_multipath (pp, vecs->pathvec)) {orphan_path (pp,"only one path" );return 0 ; }
@@ -1572,6 +1571,7 @@ reconfigure (struct vectors * vecs)dm_drv_version (conf->version,TGT_MPATH ); conf->verbosity = old->verbosity; conf->bindings_read_only = old->bindings_read_only; + conf->ignore_new_devs = old->ignore_new_devs; conf->daemon =1 ;configure (vecs,1 );free_config (old);
@@ -2076,7 +2076,7 @@ main (int argc, char *argv[])if (!conf)exit (1 ); -while ((arg =getopt (argc, argv,":dsv:k::B" )) !=EOF ) { +while ((arg =getopt (argc, argv,":dsv:k::Bn" )) !=EOF ) {switch (arg) {case 'd' : foreground =1 ;
@@ -2102,6 +2102,9 @@ main (int argc, char *argv[])case 'B' : conf->bindings_read_only =1 ;break ; +case 'n' : + conf->ignore_new_devs =1 ; +break ;default : ; }
multipathd/multipathd.8 +4 -0
@@ -35,6 +35,10 @@ will use its WWID as its alias. .TP .B -k multipathd will enter interactive mode. From this mode, the available commands can be viewed by entering "help". When you are finished entering commands, press CTRL-D to quit. +.TP +.B -n +ignore new devices. Multipathd will not create a multipath device unless the +wwid for the device is already listed in the wwids file. .SH COMMANDS .TP
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 6/18 libmultipath: fix PAD and PRINT macros
In reply to Benjamin MarzinskiThe PAD and PRINT macros are multi-line macros that aren't enclosed in braces. This means that if they are used as single line code blocks with no braces, they won't work correctly. This is currently happening with the PAD macro, but should be fixed in both.
--- libmultipath/print.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
libmultipath/print.c +12 -5
@@ -32,14 +32,21 @@#define MAX (x,y) (x > y) ? x : y#define TAIL (line + len - 1 - c)#define NOPAD s = c -#define PAD (x) while ((int)(c - s) < (x) && (c < (line + len - 1))) \ - *c++ = ' '; s = c +#define PAD (x) \ +do { \ + while ((int)(c - s) < (x) && (c < (line + len - 1))) \ + *c++ = ' '; \ + s = c; \ +} while (0) +#define ENDLINE \ if (c > line) \ line[c - line - 1] = '\n' -#define PRINT(var, size, format, args...) \ - fwd = snprintf(var, size, format, ##args); \ - c += (fwd >= size) ? size : fwd; +#define PRINT(var, size, format, args...) \ +do { \ + fwd = snprintf(var, size, format, ##args); \ + c += (fwd >= size) ? size : fwd; \ +} while (0)/* * information printing helpers
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 7/18 libmultipath: Cut down on alua prioritizer ioctls
In reply to Benjamin MarzinskiCurrently, running the alua prioritizer on a path causes 5 ioctls on many devices. get_target_port_group_support() returns whether alua is supported. get_target_port_group() gets the TPG id. This often takes two ioctls because 128 bytes is not a large enough buffer size on many devices. Finally, get_asymmetric_access_state() also often takes two ioctls because of the buffer size. This can get to be problematic when there are thousands of paths. The goal of this patch to to cut this down to one call in the usual case.
In order to do this, get_target_port_group_support() is now only called when get_target_port_group() fails, to provide a more useful error message. Also, before doing an SGIO ioctl to get the vpd83 data, multipath first tries to read it from sysfs.
--- libmultipath/discovery.h | 2 + libmultipath/prioritizers/alua.c | 24 ++++++------ libmultipath/prioritizers/alua_rtpg.c | 69 ++++++++++++++++++++++++----------- libmultipath/prioritizers/alua_rtpg.h | 2 +- libmultipath/propsel.c | 2 +- 5 files changed, 63 insertions(+), 36 deletions(-)
libmultipath/discovery.h +2 -0
@@ -45,6 +45,8 @@ int sysfs_set_scsi_tmo (struct multipath *mpp);int sysfs_get_timeout (struct path *pp,unsigned int *timeout);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);/* * discovery bitmask
libmultipath/prioritizers/alua.c +11 -13
@@ -51,24 +51,22 @@ static const char *aas_print_string(int rc) }int -get_alua_info (int fd) +get_alua_info (struct path * pp) {int rc;int tpg; - rc =get_target_port_group_support (fd); -if (rc <0 ) -return -ALUA_PRIO_TPGS_FAILED ; - -if (rc ==TPGS_NONE ) -return -ALUA_PRIO_NOT_SUPPORTED ; - - tpg =get_target_port_group (fd); -if (tpg <0 ) + tpg =get_target_port_group (pp); +if (tpg <0 ) { + rc =get_target_port_group_support (pp->fd); +if (rc <0 ) +return -ALUA_PRIO_TPGS_FAILED ; +if (rc ==TPGS_NONE ) +return -ALUA_PRIO_NOT_SUPPORTED ;return -ALUA_PRIO_RTPG_FAILED ; - + }condlog (3 ,"reported target port group is %i" , tpg); - rc =get_asymmetric_access_state (fd, tpg); + rc =get_asymmetric_access_state (pp->fd, tpg);if (rc <0 )return -ALUA_PRIO_GETAAS_FAILED ;
@@ -86,7 +84,7 @@ int getprio (struct path * pp, char * args)if (pp->fd <0 )return -ALUA_PRIO_NO_INFORMATION ; - rc =get_alua_info (pp->fd); + rc =get_alua_info (pp);if (rc >=0 ) { aas = (rc &0x0f ); priopath = (rc &0x80 );
libmultipath/prioritizers/alua_rtpg.c +48 -21
123 lines not on this page · raw message
libmultipath/prioritizers/alua_rtpg.h +1 -1
@@ -23,7 +23,7 @@#define RTPG_TPG_NOT_FOUND 4int get_target_port_group_support (int fd); -int get_target_port_group (int fd); +int get_target_port_group (struct path * pp);int get_asymmetric_access_state (int fd,unsigned int tpg);#endif /* __RTPG_H__ */
libmultipath/propsel.c +1 -1
@@ -378,7 +378,7 @@ detect_prio(struct path * pp)if ((tpgs =get_target_port_group_support (pp->fd)) <=0 )return ; pp->tpgs = tpgs; - ret =get_target_port_group (pp->fd); + ret =get_target_port_group (pp);if (ret <0 )return ;if (get_asymmetric_access_state (pp->fd, ret) <0 )
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 8/18 multipathd: fail if pidfile can't be created
In reply to Benjamin MarzinskiRight now, multipathd ignores failures from pidfile_create. This means that multiple multipathd processes can be running at the same time. If someone runs "multipathd" and doesn't add a command after it, a new process will be created, even if one is already running. To avoid this, multipathd needs to actually fail if the pidfile can't be created or locked. Since we only really need the pidfile to keep from launching multiple processes, we can create in earlier in startup. This patch moves pidfile_create to as soon as we can be sure that we can log an error message, and fails multipathd if the create fails.
--- multipathd/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
multipathd/main.c +9 -9
@@ -1768,7 +1768,7 @@ child (void * param)#ifdef USE_SYSTEMD unsigned long checkint;#endif -int rc, pid_rc; +int rc;char *envp;mlockall (MCL_CURRENT |MCL_FUTURE );
@@ -1786,6 +1786,12 @@ child (void * param)log_thread_start (&log_attr);pthread_attr_destroy (&log_attr); } +if (pidfile_create (DEFAULT_PIDFILE , daemon_pid)) { +condlog (1 ,"failed to create pidfile" ); +if (logsink ==1 ) +log_thread_stop (); +exit (1 ); + } running_state =DAEMON_START ;
@@ -1905,10 +1911,6 @@ child (void * param) }pthread_attr_destroy (&misc_attr); -/* Startup complete, create logfile */ - pid_rc =pidfile_create (DEFAULT_PIDFILE , daemon_pid); -/* Ignore errors, we can live without */ - running_state =DAEMON_RUNNING ;#ifdef USE_SYSTEMD sd_notify (0 ,"READY=1\nSTATUS=running" );
@@ -1959,10 +1961,8 @@ child (void * param)dm_lib_exit ();/* We're done here */ -if (!pid_rc) { -condlog (3 ,"unlink pidfile" ); -unlink (DEFAULT_PIDFILE ); - } +condlog (3 ,"unlink pidfile" ); +unlink (DEFAULT_PIDFILE );condlog (2 ,"--------shut down-------" );
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 9/18 libmultipath: check correct function for define
In reply to Benjamin Marzinskimultipath was setting LIBUDEV_API_RECVBUF in the makefile if udev_monitor_set_resolve_buffer_size existed. However the correct fuction name (and the one used in the code) is udev_monitor_set_receive_buffer_size. As a result, multipath was never setting the receive buffer size. This patch simply fixes the Makefile define.
--- libmultipath/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/Makefile +1 -1
@@ -37,7 +37,7 @@ ifneq ($(strip $(LIBDM_API_COOKIE)),0) CFLAGS += -DLIBDM_API_COOKIE endif -LIBUDEV_API_RECVBUF = $(shell grep -Ecs '^[a-z]*[[:space:]]+udev_monitor_set_resolve_buffer_size' /usr/include/libudev.h) +LIBUDEV_API_RECVBUF = $(shell grep -Ecs '^[a-z]*[[:space:]]+udev_monitor_set_receive_buffer_size' /usr/include/libudev.h) ifneq ($(strip $(LIBUDEV_API_RECVBUF)),0) CFLAGS += -DLIBUDEV_API_RECVBUF
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 10/18 multipathd: delay reloads during creation
In reply to Benjamin Marzinskilvm needs PV devices to not be suspended while the udev rules are running, for them to be correctly identified as PVs. However, multipathd will often be in a situation where it will create a multipath device upon seeing a path, and then immediately reload the device upon seeing another path. If multipath is reloading a device while processing the udev event from its creation, lvm can fail to identify it as a PV. This can cause systems to fail to boot. Unfortunately, using udev synchronization cookies to solve this issue would cause a host of other issues that could only be avoided by a pretty substantial change in how multipathd does locking and event processing. The good news is that multipathd is already listening to udev events itself, and can make sure that it isn't reloading when it shouldn't be.
This patch makes multipathd delay or refuse any reloads that would happen between the time when it creates a device, and when it receives the change uevent from the device creation. The only reloads that it refuses are from the multipathd interactive commands that make no sense on a not fully started device. Otherwise, it processes the event or command, and sets a flag to either mark that device for an update, or to signal that multipathd needs a reconfigure. When the udev event for the creation arrives, multipath will reload the device if necessary. If a reconfigure has been requested, and no devices are currently being created, multipathd will also do the reconfigure then.
Also this patch adds a configurable timer "missing_uev_wait_timeout" defaulting to 30 seconds. If the udev creation event has not arrived after this timeout has triggered, multipathd will print an warning message, and re-enable device reloads, as if the event had occured.
Users can also manually re-enable device reloads by running
multipathd add map <map_waiting_on_udev>
--- libmultipath/config.c | 1 + libmultipath/config.h | 2 + libmultipath/configure.c | 4 ++ libmultipath/defaults.h | 1 + libmultipath/dict.c | 4 ++ libmultipath/structs.h | 2 + multipath.conf.defaults | 1 + multipath/multipath.conf.5 | 8 +++ multipathd/cli_handlers.c | 65 ++++++++++++++++++---- multipathd/main.c | 132 +++++++++++++++++++++++++++++++++++++++++++-- multipathd/main.h | 1 + 11 files changed, 208 insertions(+), 13 deletions(-)
libmultipath/config.c +1 -0
@@ -621,6 +621,7 @@ load_config (char * file, struct udev *udev) conf->uid_attribute =set_default (DEFAULT_UID_ATTRIBUTE ); conf->retrigger_tries =DEFAULT_RETRIGGER_TRIES ; conf->retrigger_delay =DEFAULT_RETRIGGER_DELAY ; + conf->uev_wait_timeout =DEFAULT_UEV_WAIT_TIMEOUT ;/* * preload default hwtable
libmultipath/config.h +2 -0
@@ -138,6 +138,8 @@ struct config {int retrigger_tries;int retrigger_delay;int ignore_new_devs; +int delayed_reconfig; +int uev_wait_timeout;unsigned int version[3 ];char * dev;
libmultipath/configure.c +4 -0
@@ -676,6 +676,10 @@ domap (struct multipath * mpp, char * params)*/ if (mpp->action !=ACT_CREATE ) mpp->action =ACT_NOTHING ; +else { + mpp->wait_for_udev =1 ; + mpp->uev_wait_tick = conf->uev_wait_timeout; + } }dm_setgeometry (mpp);return DOMAP_OK ;
libmultipath/defaults.h +1 -0
@@ -22,6 +22,7 @@#define DEFAULT_UEVENT_STACKSIZE 256#define DEFAULT_RETRIGGER_DELAY 10#define DEFAULT_RETRIGGER_TRIES 3 +#define DEFAULT_UEV_WAIT_TIMEOUT 30#define DEFAULT_CHECKINT 5#define MAX_CHECKINT (a) (a << 2)
libmultipath/dict.c +4 -0
@@ -396,6 +396,9 @@ declare_def_snprint(retrigger_tries, print_int) declare_def_handler(retrigger_delay, set_int) declare_def_snprint(retrigger_delay, print_int) +declare_def_handler(uev_wait_timeout, set_int) +declare_def_snprint(uev_wait_timeout, print_int) +static int def_config_dir_handler (vector strvec) {
@@ -1371,6 +1374,7 @@ init_keywords(void)install_keyword ("uxsock_timeout" , &def_uxsock_timeout_handler, &snprint_def_uxsock_timeout);install_keyword ("retrigger_tries" , &def_retrigger_tries_handler, &snprint_def_retrigger_tries);install_keyword ("retrigger_delay" , &def_retrigger_delay_handler, &snprint_def_retrigger_delay); +install_keyword ("missing_uev_wait_timeout" , &def_uev_wait_timeout_handler, &snprint_def_uev_wait_timeout);__deprecated install_keyword ("default_selector" , &def_selector_handler,NULL );__deprecated install_keyword ("default_path_grouping_policy" , &def_pgpolicy_handler,NULL );__deprecated install_keyword ("default_uid_attribute" , &def_uid_attribute_handler,NULL );
libmultipath/structs.h +2 -0
@@ -226,6 +226,8 @@ struct multipath {int bestpg;int queuedio;int action; +int wait_for_udev; +int uev_wait_tick;int pgfailback;int failback_tick;int rr_weight;
multipath.conf.defaults +1 -0
@@ -29,6 +29,7 @@ # config_dir "/etc/multipath/conf.d" # delay_watch_checks no # delay_wait_checks no +# missing_uev_wait_timeout 30 #} #blacklist { # devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
multipath/multipath.conf.5 +8 -0
@@ -488,6 +488,14 @@ can be processed. This will result in errors like In these cases it is recommended to increase the CLI timeout to avoid those issues. The default is .I 1000 +.TP +.B missing_uev_wait_timeout +Controls how many seconds multipathd will wait, after a new multipath device +is created, to receive a change event from udev for the device, before +automatically enabling device reloads. Usually multipathd will delay reloads +on a device until it receives a change uevent from the initial table load. The +default is +.I 30 . .SH "blacklist section" The
multipathd/cli_handlers.c +55 -10
116 lines not on this page · raw message
multipathd/main.c +129 -3
196 lines not on this page · raw message
multipathd/main.h +1 -0
@@ -18,6 +18,7 @@ extern pid_t daemon_pid;void exit_daemon (void );const char *daemon_status (void ); +int need_to_delay_reconfig (struct vectors *);int reconfigure (struct vectors *);int ev_add_path (struct path *,struct vectors *);int ev_remove_path (struct path *,struct vectors *);
Signature · 1 line
1.8.3.1
Re: [PATCH v2 10/18] multipathd: delay reloads during creation
Dne 8.4.2016 v 01:20 Benjamin Marzinski napsal(a):
Quoted 10 lines
lvm needs PV devices to not be suspended while the udev rules are running, for them to be correctly identified as PVs. However, multipathd will often be in a situation where it will create a multipath device upon seeing a path, and then immediately reload the device upon seeing another path. If multipath is reloading a device while processing the udev event from its creation, lvm can fail to identify it as a PV. This can cause systems to fail to boot. Unfortunately, using udev synchronization cookies to solve this issue would cause a host of other issues that could only be avoided by a pretty substantial change in how multipathd does locking and event processing.
This is somewhat misunderstanding of the core problem it's not about 'lvm2 needs to be not suspended'. So let me elaborate here with more details. (And Peter please fix me in case of mistakes ;)
Lvm2 command has lvm.conf settings allowing a user to select if he wants to scan devices that are suspended or not - there is already a 'race' - since checking device is not suspended and then opening it has lots of room for the race, but it's not a major issue in this case.
The reasons to skip reading suspended devices are primarily to avoid holding VG lock for potentially a very long time and also avoiding udev with its 'built-in' 30sec timeout to kills its worker process blocked in blkid scan with a danger of marking device as GONE and having further consequences like an automated umount by systemd....
Thus lvm2/dm udev rules implemented a (racy) check for skipping a read of suspended device and this check may also skip the call of pvscan with the generic assumption RESUME goes afterwards with a CHANGE event and device will be properly scanned anyway - so there would be no info lost - only gets into udev database later.
However now the multipathd *kills* this assumption - since the current udev rules implementation for multipath devices targets only for the initial scan and all subsequent RESUMES are supposed to be ignored as it's believed the device remained in the same state and only some paths have been added/lost. Scanning such a device thus shall not change any remembered info in udev database. As 'extra' bonus multipath may SUSPEND devices (and that's somehow solved by this patch) right after the initial activation of the device so the lvm2 check for skipping of suspended devices may have skipped the whole discovery operation and since further RESUMES were meant to be ignore, device remained invisible forever.
Now we get to the best technical solution for multipath here with other surrounding software (i.e. udev) - before multipath starts to mark RESUMES as 'ignorable' it should check/validate if udevdb already does contain a valid information about the device (i.e. it's been scanned...) and only in this case it would mark this device to be ignored.
This may of course mean there will be few more extra initial repeated scans - but it's the only 'safest' way to proceed (i.e. you can't resolve the problem with cookie waiting on loaded system - since the udev 30sec timeout is unpredictable....)
Regards
Zdenek
Benjamin Marzinski
maintainerRe: [PATCH v2 10/18] multipathd: delay reloads during creation
Quoted 10 lines · Zdenek Kabelac
However now the multipathd *kills* this assumption - since the current udev rules implementation for multipath devices targets only for the initial scan and all subsequent RESUMES are supposed to be ignored as it's believed the device remained in the same state and only some paths have been added/lost. Scanning such a device thus shall not change any remembered info in udev database. As 'extra' bonus multipath may SUSPEND devices (and that's somehow solved by this patch) right after the initial activation of the device so the lvm2 check for skipping of suspended devices may have skipped the whole discovery operation and since further RESUMES were meant to be ignore, device remained invisible forever.
Yep, that's the general idea of the patch, to avoid the case where the initial activation uevent isn't getting processed while the device is suspended.
Quoted 5 lines
Now we get to the best technical solution for multipath here with other surrounding software (i.e. udev) - before multipath starts to mark RESUMES as 'ignorable' it should check/validate if udevdb already does contain a valid information about the device (i.e. it's been scanned...) and only in this case it would mark this device to be ignored.
This makes sense, and has the benefit of not forcing multipathd to wait before doing reloads, or having to deal with what happens if the initial change uevent gets backed up. The only thing I'm not sure we have is a variable to check in the udev database that will get set (and then retained over subsequent uevents) when the device is scanned, regardless of whether any lvm metadata is found or not. Peter, does anything like this exist? I didn't see anything that looked like what we'd need. If nothing currently exists, could we add a variable that gets added to the udev database for a device whenever pvscan is run, and also gets imported from the database on all change events?
-Ben
Quoted 3 lines
Regards
Zdenek
Benjamin Marzinski
maintainerPATCH v2 11/18 multipath: Fix minor text issues
In reply to Benjamin MarzinskiThe multipath.conf man page gave the incorrect default for queue_without_daemon. The multipath usage output listed the -p option twice. And multipath was misspelled in an mpathpersist error message. This patch fixes these issues.
--- libmpathpersist/mpath_persist.c | 2 +- multipath/main.c | 1 - multipath/multipath.conf.5 | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)
libmpathpersist/mpath_persist.c +1 -1
@@ -852,7 +852,7 @@ int update_map_pr(struct multipath *mpp)if (!mpp->reservation_key) {/* Nothing to do. Assuming pr mgmt feature is disabled*/ -condlog (3 ,"%s: reservation_key not set in multiapth.conf" , mpp->alias); +condlog (3 ,"%s: reservation_key not set in multipath.conf" , mpp->alias);return MPATH_PR_SUCCESS ; }
multipath/main.c +0 -1
@@ -107,7 +107,6 @@ usage (char * progname)" -r force devmap reload\n" \" -i ignore wwids file\n" \" -B treat the bindings file as read only\n" \ -" -p policy failover|multibus|group_by_serial|group_by_prio\n" \" -b fil bindings file location\n" \" -w remove a device from the wwids file\n" \" -W reset the wwids file include only the current devices\n" \
multipath/multipath.conf.5 +1 -1
@@ -389,7 +389,7 @@ multipathd running, access to the paths cannot be restored, and the kernel cannot be told to stop queueing IO. Setting queue_without_daemon to .I no , avoids this problem. Default is -.I yes +.I no .TP .B bindings_file The full pathname of the binding file to be used when the user_friendly_names option is set. Defaults to
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 12/18 kpartx: verify partition devices
In reply to Benjamin MarzinskiWhen kpartx is modifies devices (either by removing them, or reloading them), it doesn't first verify that the device really is a partition of the expected device. If a dm device just happens to have the same name as a kpartx created device would, kpartx can either delete that device or remap it, causing all sorts of problems.
This patch makes kpartx check the uuid to verify that the device it is modifying really is a partition device for the correct dm device.
--- kpartx/devmapper.c | 17 ++++++++++--- kpartx/devmapper.h | 2 +- kpartx/kpartx.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 81 insertions(+), 8 deletions(-)
kpartx/devmapper.c +14 -3
@@ -167,12 +167,16 @@ addout: }extern int -dm_map_present (char * str) +dm_map_present (char * str,char **uuid) {int r =0 ;struct dm_task *dmt; +const char *uuidtmp;struct dm_info info; +if (uuid) + *uuid =NULL ; +if (!(dmt =dm_task_create (DM_DEVICE_INFO )))return 0 ;
@@ -187,8 +191,15 @@ dm_map_present (char * str)if (!dm_task_get_info (dmt, &info)) goto out; -if (info.exists) - r =1 ; +if (!info.exists) + goto out; + + r =1 ; +if (uuid) { + uuidtmp =dm_task_get_uuid (dmt); +if (uuidtmp &&strlen (uuidtmp)) + *uuid =strdup (uuidtmp); + } out:dm_task_destroy (dmt);return r;
kpartx/devmapper.h +1 -1
@@ -13,7 +13,7 @@ int dm_prereq (char *, int, int, int);int dm_simplecmd (int ,const char *,int ,uint16_t );int dm_addmap (int ,const char *,const char *,const char *,uint64_t ,int ,const char *,int ,mode_t ,uid_t ,gid_t ); -int dm_map_present (char *); +int dm_map_present (char *,char **);char *dm_mapname (int major,int minor);dev_t dm_get_first_dep (char *devname);char *dm_mapuuid (int major,int minor);
kpartx/kpartx.c +66 -4
144 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 13/18 multipath: add exclusive_pref_bit for alua prio
In reply to Benjamin MarzinskiThe SCSI spec is pretty vague on exactly what the tpgs pref bit should guarantee. In the past, the alua prioritizer has put paths with the pref bit set in their own priority group, and some users complained. Currently, the alua prioritizer puts paths with the tpgs pref bit set in the highest priority path group. However, if the path with the pref bit set is active/optimized, it will be grouped with other active/optimized paths. Other users complained about this. The only good solution is to allow users to configure what setting the pref bit does.
This patch allows user to set
prio_args "exclusive_pref_bit"
for the alua prioritizer. If this is set, a paths with the pref bit set will never get grouped with paths that don't have it set. If this is not set, multipath will continue to work as it currently does, where they may be grouped when all paths are active/optimized.
--- libmultipath/prioritizers/alua.c | 20 +++++++++++++++++++- multipath/multipath.conf.5 | 19 ++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-)
libmultipath/prioritizers/alua.c +19 -1
@@ -75,15 +75,33 @@ get_alua_info(struct path * pp)return rc; } +int get_exclusive_perf_arg (char *args) +{ +char *ptr; + +if (args ==NULL ) +return 0 ; + ptr =strstr (args,"exclusive_pref_bit" ); +if (!ptr) +return 0 ; +if (ptr[18 ] !='\0' && ptr[18 ] !=' ' && ptr[18 ] !='\t' ) +return 0 ; +if (ptr != args && ptr[-1 ] !=' ' && ptr[-1 ] !='\t' ) +return 0 ; +return 1 ; +} +int getprio (struct path * pp,char * args) {int rc;int aas;int priopath; +int exclusive_perf;if (pp->fd <0 )return -ALUA_PRIO_NO_INFORMATION ; + exclusive_perf =get_exclusive_perf_arg (args); rc =get_alua_info (pp);if (rc >=0 ) { aas = (rc &0x0f );
@@ -104,7 +122,7 @@ int getprio (struct path * pp, char * args)default : rc =0 ; } -if (priopath && aas !=AAS_OPTIMIZED ) +if (priopath && (aas !=AAS_OPTIMIZED || exclusive_perf)) rc +=80 ; }else {switch (-rc) {
multipath/multipath.conf.5 +16 -3
@@ -193,7 +193,9 @@ Return a constant priority of \fI1\fR. Generate the path priority for EMC arrays. .TP .B alua -Generate the path priority based on the SCSI-3 ALUA settings. +Generate the path priority based on the SCSI-3 ALUA settings. This prioritizer +accepts the optional prio_arg +.I exclusive_pref_bit .TP .B ontap Generate the path priority for NetApp arrays.
@@ -219,14 +221,25 @@ Default value is \fBnone\fR. .RE .TP .B prio_args -Arguments to pass to to the prio function. Currently only used with -.I weighted, which needs a value of the form +Arguments to pass to to the prio function. This only applies to certain +prioritizers +.RS +.TP 12 +.B weighted +Needs a value of the form .I "<hbtl|devname> <regex1> <prio1> <regex2> <prio2> ..." .I hbtl regex can be of SCSI H:B:T:L format Ex: 1:0:.:. , *:0:0:. .I devname regex can be of device name format Ex: sda , sd.e .TP +.B alua +If +.I exclusive_pref_bit +is set, paths with the TPGS pref bit set will always be in their own path +group. +.RE +.TP .B features Specify any device-mapper features to be used. Syntax is .I num list
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 14/18 multipathd: print "fail" when remove fails
In reply to Benjamin MarzinskiWhen multipathd fails to remove a path or a map, it was printing "ok" instead of "fail", and exitting with a 0 return code. Now it prints "fail" and exits with a 1, like it does when other commands fail.
--- multipathd/cli_handlers.c | 8 ++++---- multipathd/main.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
multipathd/cli_handlers.c +4 -4
@@ -511,7 +511,7 @@ cli_del_path (void * v, char ** reply, int * len, void * data) pp =find_path_by_dev (vecs->pathvec, param);if (!pp) {condlog (0 ,"%s: path already removed" , param); -return 0 ; +return 1 ; }return ev_remove_path (pp, vecs); }
@@ -585,19 +585,19 @@ cli_del_map (void * v, char ** reply, int * len, void * data) minor =dm_get_minor (param);if (minor <0 ) {condlog (2 ,"%s: not a device mapper table" , param); -return 0 ; +return 1 ; } major =dm_get_major (param);if (major <0 ) {condlog (2 ,"%s: not a device mapper table" , param); -return 0 ; +return 1 ; }sprintf (dev_path,"dm-%d" , minor); alias =dm_mapname (major, minor);if (!alias) {condlog (2 ,"%s: mapname not found for %d:%d" , param, major, minor); -return 0 ; +return 1 ; } rc =ev_remove_map (param, alias, minor, vecs);FREE (alias);
multipathd/main.c +2 -2
@@ -448,12 +448,12 @@ ev_remove_map (char * devname, char * alias, int minor, struct vectors * vecs)if (!mpp) {condlog (2 ,"%s: devmap not registered, can't remove" , devname); -return 0 ; +return 1 ; }if (strcmp (mpp->alias, alias)) {condlog (2 ,"%s: minor number mismatch (map %d, event %d)" , mpp->alias, mpp->dmi->minor, minor); -return 0 ; +return 1 ; }return flush_map (mpp, vecs,0 ); }
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 15/18 multipath: check partitions unused before removing
In reply to Benjamin MarzinskiIf kpartx partition devices are in-use, multipath will not be able to perform a non-deferred remove of the multipath device. So, before starting the remove, multipath should verify that none of the partition devices are currently in-use.
--- libmultipath/devmapper.c | 46 ++++++++++++++++++++++++++++++++++++++-------- libmultipath/devmapper.h | 2 +- 2 files changed, 39 insertions(+), 9 deletions(-)
libmultipath/devmapper.c +38 -8
@@ -36,6 +36,10 @@static int dm_cancel_remove_partmaps (const char * mapname);#endif +static int do_foreach_partmaps (const char * mapname, +int (*partmap_func)(const char *,void *), +void *data); +#ifndef LIBDM_API_COOKIE static inline int dm_task_set_cookie (struct dm_task *dmt,uint32_t *c,int a) {
@@ -735,6 +739,26 @@ out:return r; } +static int +partmap_in_use (const char *name,void *data) +{ +int part_count, *ret_count = (int *)data; +int open_count =dm_get_opencount (name); + +if (ret_count) + (*ret_count)++; + part_count =0 ; +if (open_count) { +if (do_foreach_partmaps (name, partmap_in_use, &part_count)) +return 1 ; +if (open_count != part_count) { +condlog (2 ,"%s: map in use" , name); +return 1 ; + } + } +return 0 ; +} +extern int _dm_flush_map (const char * mapname,int need_sync,int deferred_remove) {
@@ -743,6 +767,11 @@ _dm_flush_map (const char * mapname, int need_sync, int deferred_remove)if (!dm_is_mpath (mapname))return 0 ;/* nothing to do */ +/* If you aren't doing a deferred remove, make sure that no +* devices are in use */ +if (!do_deferred (deferred_remove) &&partmap_in_use (mapname,NULL )) +return 1 ; +if (dm_remove_partmaps (mapname, need_sync, deferred_remove))return 1 ;
@@ -851,7 +880,7 @@ dm_flush_maps (void) }int -dm_message (char * mapname,char * message) +dm_message (const char * mapname,char * message) {int r =1 ;struct dm_task *dmt;
@@ -1092,7 +1121,8 @@ bad: }static int -do_foreach_partmaps (const char * mapname,int (*partmap_func)(char *,void *), +do_foreach_partmaps (const char * mapname, +int (*partmap_func)(const char *,void *),void *data) {struct dm_task *dmt;
@@ -1165,7 +1195,7 @@ struct remove_data { };static int -remove_partmap (char *name,void *data) +remove_partmap (const char *name,void *data) {struct remove_data *rd = (struct remove_data *)data;
@@ -1192,7 +1222,7 @@ dm_remove_partmaps (const char * mapname, int need_sync, int deferred_remove)#ifdef LIBDM_API_DEFERRED static int -cancel_remove_partmap (char *name,void *unused) +cancel_remove_partmap (const char *name,void *unused) {if (dm_get_opencount (name))dm_cancel_remove_partmaps (name);
@@ -1312,13 +1342,13 @@ out: }struct rename_data { -char *old; +const char *old;char *new;char *delim; };static int -rename_partmap (char *name,void *data) +rename_partmap (const char *name,void *data) {char buff[PARAMS_SIZE ];int offset;
@@ -1335,7 +1365,7 @@ rename_partmap (char *name, void *data) }int -dm_rename_partmaps (char * old,char * new) +dm_rename_partmaps (const char * old,char * new) {struct rename_data rd;
@@ -1352,7 +1382,7 @@ dm_rename_partmaps (char * old, char * new) }int -dm_rename (char * old,char * new) +dm_rename (const char * old,char * new) {int r =0 ;struct dm_task *dmt;
libmultipath/devmapper.h +1 -1
@@ -46,7 +46,7 @@ int dm_remove_partmaps (const char * mapname, int need_sync, int deferred_remove);int dm_get_uuid (char *name,char *uuid);int dm_get_info (char * mapname,struct dm_info ** dmi); -int dm_rename (char * old,char * new); +int dm_rename (const char * old,char * new);int dm_reassign (const char * mapname);int dm_reassign_table (const char *name,char *old,char *new);int dm_setgeometry (struct multipath *mpp);
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 16/18 multipathd.service: remove blk-availability Requires
In reply to Benjamin Marzinskimultipathd.service can start up and run just fine without blk-availability.service. It is only necessary to coordinate shutdown order in certain multipath setups (over iscsi for instance). Thus, instead of "Requires", multipathd.service should use "Wants"
--- multipathd/multipathd.service | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
multipathd/multipathd.service +1 -2
@@ -1,11 +1,10 @@ [Unit] Description=Device-Mapper Multipath Device Controller -Requires=blk-availability.service Before=iscsi.service iscsid.service lvm2-activation-early.service Before=local-fs-pre.target After=multipathd.socket DefaultDependencies=no -Wants=local-fs-pre.target multipathd.socket +Wants=local-fs-pre.target multipathd.socket blk-availability.service Conflicts=shutdown.target [Service]
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 17/18 multipathd: use 64-bit int for command key
In reply to Benjamin MarzinskiThere are now more than 32 keywords for the multipathd client commands. Since these are represented by a bit flags, multipathd needs more than 32 bits for the client command keycodes. However, multipath is currently using unsigned long for these. This makes some client commands work incorrectly on 32-bit systems. This patch switches all the keys to use uint64_t instead.
--- multipathd/cli.c | 22 +++++++++++----------- multipathd/cli.h | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-)
multipathd/cli.c +11 -11
@@ -26,7 +26,7 @@ alloc_handler (void) }static int -add_key (vector vec,char * str,unsigned long code,int has_param) +add_key (vector vec,char * str,uint64_t code,int has_param) {struct key * kw;
@@ -57,7 +57,7 @@ out: }int -add_handler (unsigned long fp,int (*fn)(void *,char **,int *,void *)) +add_handler (uint64_t fp,int (*fn)(void *,char **,int *,void *)) {struct handler * h;
@@ -79,7 +79,7 @@ add_handler (unsigned long fp, int (*fn)(void *, char **, int *, void *)) }static struct handler * -find_handler (unsigned long fp) +find_handler (uint64_t fp) {int i;struct handler *h;
@@ -92,7 +92,7 @@ find_handler (unsigned long fp) }int -set_handler_callback (unsigned long fp,int (*fn)(void *,char **,int *,void *)) +set_handler_callback (uint64_t fp,int (*fn)(void *,char **,int *,void *)) {struct handler * h =find_handler (fp);
@@ -293,11 +293,11 @@ out:return r; } -static unsigned long +static uint64_t fingerprint (vector vec) {int i; -unsigned long fp =0 ; +uint64_t fp =0 ;struct key * kw;if (!vec)
@@ -343,7 +343,7 @@ static int do_genhelp(char *reply, int maxlen) {int len =0 ;int i, j; -unsigned long fp; +uint64_t fp;struct handler * h;struct key * kw;
@@ -442,7 +442,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data) }char * -get_keyparam (vector v,unsigned long code) +get_keyparam (vector v,uint64_t code) {struct key * kw;int i;
@@ -516,7 +516,7 @@ void cli_exit(void) }static int -key_match_fingerprint (struct key * kw,unsigned long fp) +key_match_fingerprint (struct key * kw,uint64_t fp) {if (!fp)return 0 ;
@@ -531,7 +531,7 @@ char * key_generator (const char * str, int state) {static int index, len, has_param; -static unsigned long rlfp; +static uint64_t rlfp;struct key * kw;int i;struct handler *h;
@@ -601,7 +601,7 @@ key_generator (const char * str, int state)* nfp is the candidate fingerprint we try to * validate against all known command fingerprints. */ -unsigned long nfp = rlfp | kw->code; +uint64_t nfp = rlfp | kw->code; vector_foreach_slot(handlers, h, i) {if (!rlfp || ((h->fingerprint & nfp) == nfp)) {/*
multipathd/cli.h +11 -9
@@ -1,3 +1,5 @@ +#include <stdint.h> +enum { __LIST, __ADD,
@@ -68,10 +70,10 @@ enum {#define WILDCARDS (1 << __WILDCARDS)#define QUIT (1 << __QUIT)#define SHUTDOWN (1 << __SHUTDOWN) -#define GETPRSTATUS (1UL << __GETPRSTATUS) -#define SETPRSTATUS (1UL << __SETPRSTATUS) -#define UNSETPRSTATUS (1UL << __UNSETPRSTATUS) -#define FMT (1UL << __FMT) +#define GETPRSTATUS (1ULL << __GETPRSTATUS) +#define SETPRSTATUS (1ULL << __SETPRSTATUS) +#define UNSETPRSTATUS (1ULL << __UNSETPRSTATUS) +#define FMT (1ULL << __FMT)#define INITIAL_REPLY_LEN 1200
@@ -92,21 +94,21 @@ enum {struct key {char * str;char * param; -unsigned long code; +uint64_t code;int has_param; };struct handler { -unsigned long fingerprint; +uint64_t fingerprint;int (*fn)(void *,char **,int *,void *); };int alloc_handlers (void ); -int add_handler (unsigned long fp,int (*fn)(void *,char **,int *,void *)); -int set_handler_callback (unsigned long fp,int (*fn)(void *,char **,int *,void *)); +int add_handler (uint64_t fp,int (*fn)(void *,char **,int *,void *)); +int set_handler_callback (uint64_t fp,int (*fn)(void *,char **,int *,void *));int parse_cmd (char * cmd,char ** reply,int * len,void *);int load_keys (void ); -char *get_keyparam (vector v,unsigned long code); +char *get_keyparam (vector v,uint64_t code);void free_keys (vector vec);void free_handlers (void );int cli_init (void );
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH v2 18/18 multipath: add wwn keyword to weightedpath prio
In reply to Benjamin Marzinskimultipath's weightedpath prioritizer now supports a "wwn" keyword, instead of just the "hbtl" and "devname" keywords. If this is used the regular expression for matching the device is of the form "host_wwnn:host_wwpn:target_wwnn:target_wwpn". These identifiers can either be looked up through sysfs, or using the following "multipathd show paths format" wildcards "%N:%R:%n:%r"
For instance, you could do something like this
prio weightedpath
prio_args "wwn 0x200000e08b80aea0:.*:.*:.* 300x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* 20 .*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.* 10"
This would map:
- all paths with the FC Host WWNN of 0x200000e08b80aea0 to a priority of 30
- all paths with the FC Host WWNN of 0x200100e08ba0aea0 and the Host WWPN of 0x210100e08ba0aea0 to a priority of 20
- all paths with the iscsi target name of iqn.2009-10.com.redhat.msp.lab.ask-06 (which multipath has always treated as the same as the FC Target WWNN) to a priority of 10
- and all other paths to a priority of 0
--- libmultipath/print.c | 8 +++---- libmultipath/print.h | 4 ++++ libmultipath/prioritizers/weightedpath.c | 37 ++++++++++++++++++++++++++++++++ libmultipath/prioritizers/weightedpath.h | 1 + multipath/multipath.conf.5 | 7 +++++- 5 files changed, 52 insertions(+), 5 deletions(-)
libmultipath/print.c +4 -4
@@ -489,19 +489,19 @@ out:return ret; } -static int +int snprint_host_wwnn (char * buff,size_t len,struct path * pp) {return snprint_host_attr (buff, len, pp,"node_name" ); } -static int +int snprint_host_wwpn (char * buff,size_t len,struct path * pp) {return snprint_host_attr (buff, len, pp,"port_name" ); } -static int +int snprint_tgt_wwpn (char * buff,size_t len,struct path * pp) {struct udev_device *rport_dev =NULL ;
@@ -531,7 +531,7 @@ out: } -static int +int snprint_tgt_wwnn (char * buff,size_t len,struct path * pp) {if (pp->tgt_node_name[0 ] =='\0' )
libmultipath/print.h +4 -0
@@ -51,6 +51,10 @@ int snprint_devices (char *, int, struct vectors *);int snprint_hwtable (char *,int ,vector );int snprint_mptable (char *,int ,vector );int snprint_overrides (char *,int ,struct hwentry *); +int snprint_host_wwnn (char *,size_t ,struct path *); +int snprint_host_wwpn (char *,size_t ,struct path *); +int snprint_tgt_wwnn (char *,size_t ,struct path *); +int snprint_tgt_wwpn (char *,size_t ,struct path *);void print_multipath_topology (struct multipath * mpp,int verbosity);void print_path (struct path * pp,char * style);
libmultipath/prioritizers/weightedpath.c +37 -0
@@ -32,6 +32,8 @@#include <memory.h> #include <debug.h> #include <regex.h> +#include <structs_vec.h> +#include <print.h> char *get_next_string (char **temp,char *split_char) {
@@ -42,6 +44,36 @@ char *get_next_string(char **temp, char *split_char)return token; } +#define CHECK_LEN \ +do { \ + if ((p - str) >= (len - 1)) { \ + condlog(0, "%s: %s - buffer size too small", pp->dev, pp->prio.name); \ + return -1; \ + } \ +} while(0) + +static int +build_wwn_path (struct path *pp,char *str,int len) +{ +char *p = str; + + p +=snprint_host_wwnn (p, str + len - p, pp); +CHECK_LEN ; + p +=snprintf (p, str + len - p,":" ); +CHECK_LEN ; + p +=snprint_host_wwpn (p, str + len - p, pp); +CHECK_LEN ; + p +=snprintf (p, str + len - p,":" ); +CHECK_LEN ; + p +=snprint_tgt_wwnn (p, str + len - p, pp); +CHECK_LEN ; + p +=snprintf (p, str + len - p,":" ); +CHECK_LEN ; + p +=snprint_tgt_wwpn (p, str + len - p, pp); +CHECK_LEN ; +return 0 ; +} +/* main priority routine */ int prio_path_weight (struct path *pp,char *prio_args) {
@@ -71,6 +103,11 @@ int prio_path_weight(struct path *pp, char *prio_args) pp->sg_id.channel, pp->sg_id.scsi_id, pp->sg_id.lun); }else if (!strcmp (regex,DEV_NAME )) {strcpy (path, pp->dev); + }else if (!strcmp (regex,WWN )) { +if (build_wwn_path (pp, path,FILE_NAME_SIZE ) !=0 ) { +FREE (arg); +return priority; + } }else {condlog (0 ,"%s: %s - Invalid arguments" , pp->dev, pp->prio.name);
libmultipath/prioritizers/weightedpath.h +1 -0
@@ -4,6 +4,7 @@#define PRIO_WEIGHTED_PATH "weightedpath"#define HBTL "hbtl"#define DEV_NAME "devname" +#define WWN "wwn"#define DEFAULT_PRIORITY 0int prio_path_weight (struct path *pp,char *prio_args);
multipath/multipath.conf.5 +6 -1
@@ -227,11 +227,16 @@ prioritizers .TP 12 .B weighted Needs a value of the form -.I "<hbtl|devname> <regex1> <prio1> <regex2> <prio2> ..." +.I "<hbtl|devname|wwn> <regex1> <prio1> <regex2> <prio2> ..." .I hbtl regex can be of SCSI H:B:T:L format Ex: 1:0:.:. , *:0:0:. .I devname regex can be of device name format Ex: sda , sd.e +.I wwn +regex can be of the form +.I "host_wwnn:host_wwpn:target_wwnn:target_wwpn" +these values can be looked up through sysfs or by running +.I mulitpathd show paths format "%N:%R:%n:%r" Ex: 0x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* , .*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.* .TP .B alua If
Signature · 1 line
1.8.3.1
Hi Ben,
This patchset is merged, thanks.
The version code has been bumped to 0.6.0
Best regards,
Christophe Varoqui
www.opensvc.com
Quoted 88 lines · Benjamin Marzinski
This is a resend of my previous batch of patches. The only one that has changed (besides in offsets) is patch 10 "multipathd: delay reloads during creation". I renamed the config option "
missing_uev_wait_timeout". When it triggers, multipath will simply print a warning message and re-enable reloads as if it had received the uevent.I also added a new patch that adds a new keyword to the weightedpath prioritizer, so that you can refer to paths in a persistent way.
Benjamin Marzinski (18):
multipathd: use /run instead of/var/runretrigger uevents to try and get the uid through udev Fix issues withuser_friendly_namesinitramfs bindings Add libmpathcmd library and use it internally
libmultipath: addignore_new_boot_devsoption
libmultipath: fix PAD and PRINT macros
libmultipath: Cut down on alua prioritizer ioctls
multipathd: fail if pidfile can't be created
libmultipath: check correct function for define
multipathd: delay reloads during creation
multipath: Fix minor text issues
kpartx: verify partition devices
multipath: addexclusive_pref_bitfor alua prio
multipathd: print "fail" when remove fails
multipath: check partitions unused before removing multipathd.service: remove blk-availability Requires
multipathd: use 64-bit int for command key
multipath: add wwn keyword to weightedpath prioMakefile | 1 + Makefile.inc | 12 +- kpartx/devmapper.c | 17 ++- kpartx/devmapper.h | 2 +- kpartx/kpartx.c | 70 ++++++++++- libmpathcmd/Makefile | 30 +++++ libmpathcmd/mpath_cmd.c | 178 +++++++++++++++++++++++++++ libmpathcmd/mpath_cmd.h | 125 +++++++++++++++++++ libmpathpersist/Makefile | 9 +- libmpathpersist/mpath_persist.c | 2 +- libmpathpersist/mpath_updatepr.c | 14 +-- libmultipath/Makefile | 5 +- libmultipath/config.c | 7 +- libmultipath/config.h | 5 + libmultipath/configure.c | 20 +-- libmultipath/defaults.h | 6 +- libmultipath/devmapper.c | 46 +++++-- libmultipath/devmapper.h | 2 +- libmultipath/dict.c | 20 ++- libmultipath/discovery.c | 28 +++-- libmultipath/discovery.h | 2 + libmultipath/print.c | 25 ++-- libmultipath/print.h | 4 + libmultipath/prioritizers/alua.c | 44 ++++--- libmultipath/prioritizers/alua_rtpg.c | 69 +++++++---- libmultipath/prioritizers/alua_rtpg.h | 2 +- libmultipath/prioritizers/weightedpath.c | 37 ++++++ libmultipath/prioritizers/weightedpath.h | 1 + libmultipath/propsel.c | 2 +- libmultipath/structs.h | 10 ++ libmultipath/uxsock.c | 73 +++-------- libmultipath/uxsock.h | 5 +- libmultipath/wwids.c | 19 +-- mpathpersist/Makefile | 2 +- multipath.conf.defaults | 1 + multipath/Makefile | 5 +- multipath/main.c | 6 +- multipath/multipath.conf.5 | 36 +++++- multipathd/Makefile | 5 +- multipathd/cli.c | 22 ++-- multipathd/cli.h | 20 +-- multipathd/cli_handlers.c | 73 ++++++++--- multipathd/main.c | 205 ++++++++++++++++++++++++++----- multipathd/main.h | 1 + multipathd/multipathd.8 | 4 + multipathd/multipathd.init.suse | 2 +- multipathd/multipathd.service | 3 +- multipathd/uxclnt.c | 13 +- multipathd/uxlsnr.c | 11 +- 49 files changed, 1031 insertions(+), 270 deletions(-) create mode 100644 libmpathcmd/Makefile create mode 100644 libmpathcmd/mpath_cmd.c create mode 100644 libmpathcmd/mpath_cmd.h--
1.8.3.1