misc multipath patches
Subsystems (2)
Benjamin Marzinski
maintainercover misc multipath patches
The first two of these patches attempt to make it easier for external programs to communicate with multipathd. The first refactors the multipathd interactive command code into a seperate library that other programs can use. The second patch makes the output a bit easier to parse.
The third patch deals with a boot race that can happen on install or first boot.
The last patch modifies my earlier "multipathd: use /run instead of /var/run" patch to make in only apply if systemd is being used.
Benjamin Marzinski (4):
Add libmpathcmd library and use it internally
add raw format multipathd commands
libmultipath: add ignore_new_boot_devs option
Make use of /run depend on systemd
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 | 4 +- libmultipath/config.h | 1 + libmultipath/configure.c | 13 ++- libmultipath/defaults.h | 6 +- libmultipath/dict.c | 12 +-- libmultipath/print.c | 25 +++--- libmultipath/print.h | 4 +- libmultipath/uxsock.c | 73 ++++------------ libmultipath/uxsock.h | 5 +- libmultipath/wwids.c | 21 +++-- mpathpersist/Makefile | 2 +- multipath/Makefile | 5 +- multipath/main.c | 5 +- multipathd/Makefile | 5 +- multipathd/cli.c | 5 +- multipathd/cli.h | 6 +- multipathd/cli_handlers.c | 50 ++++++++--- multipathd/cli_handlers.h | 2 + multipathd/main.c | 6 +- multipathd/uxclnt.c | 13 ++- multipathd/uxlsnr.c | 11 +-- 29 files changed, 489 insertions(+), 147 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 1/4 Add libmpathcmd library and use it internally
Other 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 | 2 - 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(+), 107 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
@@ -42,9 +42,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)
@@ -617,7 +618,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 -2
@@ -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
@@ -29,7 +28,6 @@#define MAX_DEV_LOSS_TMO 0x7FFFFFFF#define DEFAULT_PIDFILE "/run/multipathd.pid" -#define DEFAULT_SOCKET "/org/kernel/linux/storage/multipathd"#define DEFAULT_CONFIGFILE "/etc/multipath.conf"#define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"#define DEFAULT_WWIDS_FILE "/etc/multipath/wwids"
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)
@@ -1054,10 +1055,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 ;
@@ -1146,9 +1147,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 2/4 add raw format multipathd commands
In reply to Benjamin MarzinskiThis patch adds the following multipathd interactive commands
show paths raw format $fmt
show maps raw format $fmt
These commands work just like the regular "show ... format" commands, except that they don't print a header, and don't add any extra padding that isn't in the format string. This should make it easier for programs wanting to parse the output from these commands.
--- libmultipath/print.c | 25 +++++++++++++----------- libmultipath/print.h | 4 ++-- multipathd/cli.c | 5 ++++- multipathd/cli.h | 6 ++++-- multipathd/cli_handlers.c | 50 +++++++++++++++++++++++++++++++++++------------ multipathd/cli_handlers.h | 2 ++ multipathd/main.c | 2 ++ 7 files changed, 65 insertions(+), 29 deletions(-)
libmultipath/print.c +14 -11
@@ -732,7 +732,7 @@ snprint_multipath_header (char * line, int len, char * format)int snprint_multipath (char * line,int len,char * format, -struct multipath * mpp) +struct multipath * mpp,int pad) {char * c = line;/* line cursor */ char * s = line;/* for padding */
@@ -759,7 +759,8 @@ snprint_multipath (char * line, int len, char * format, data->snprint (buff,MAX_FIELD_LEN , mpp);TAIL ,"%s" , buff); -PAD (data->width); +if (pad) +PAD (data->width); buff[0 ] ='\0' ; }while (*f++);
@@ -802,7 +803,7 @@ snprint_path_header (char * line, int len, char * format)int snprint_path (char * line,int len,char * format, -struct path * pp) +struct path * pp,int pad) {char * c = line;/* line cursor */ char * s = line;/* for padding */
@@ -829,7 +830,8 @@ snprint_path (char * line, int len, char * format, data->snprint (buff,MAX_FIELD_LEN , pp);TAIL ,"%s" , buff); -PAD (data->width); +if (pad) +PAD (data->width); }while (*f++);ENDLINE ;
@@ -921,7 +923,7 @@ snprint_multipath_topology (char * buff, int len, struct multipath * mpp,reset_multipath_layout ();if (verbosity ==1 ) -return snprint_multipath (buff, len,"%n" , mpp); +return snprint_multipath (buff, len,"%n" , mpp,1 );if (isatty (1 )) c +=sprintf (c,"%c[%dm" ,0x1B ,1 );/* bold on */
@@ -940,10 +942,11 @@ snprint_multipath_topology (char * buff, int len, struct multipath * mpp,if (isatty (1 )) c +=sprintf (c,"%c[%dm" ,0x1B ,0 );/* bold off */ - fwd +=snprint_multipath (buff + fwd, len - fwd, style, mpp); + fwd +=snprint_multipath (buff + fwd, len - fwd, style, mpp,1 );if (fwd > len)return len; - fwd +=snprint_multipath (buff + fwd, len - fwd,PRINT_MAP_PROPS , mpp); + fwd +=snprint_multipath (buff + fwd, len - fwd,PRINT_MAP_PROPS , mpp, +1 );if (fwd > len)return len;
@@ -970,7 +973,7 @@ snprint_multipath_topology (char * buff, int len, struct multipath * mpp,strcpy (f," |- " PRINT_PATH_INDENT ); else strcpy(f, " `- " PRINT_PATH_INDENT); - fwd +=snprint_path (buff + fwd, len - fwd, fmt, pp); + fwd +=snprint_path (buff + fwd, len - fwd, fmt, pp,1 );if (fwd > len)return len; }
@@ -1502,7 +1505,7 @@ snprint_devices (char * buff, int len, struct vectors *vecs)if (r >0 ) fwd +=snprintf (buff + fwd, len - fwd," devnode blacklisted, unmonitored" ); -else if (r <0 ) +else if (r <=0 ) fwd +=snprintf (buff + fwd, len - fwd," devnode whitelisted, unmonitored" ); }else
@@ -1532,7 +1535,7 @@ print_path (struct path * pp, char * style)char line[MAX_LINE_LEN ];memset (&line[0 ],0 ,MAX_LINE_LEN ); -snprint_path (&line[0 ],MAX_LINE_LEN , style, pp); +snprint_path (&line[0 ],MAX_LINE_LEN , style, pp,1 );printf ("%s" , line); }
@@ -1542,7 +1545,7 @@ print_multipath (struct multipath * mpp, char * style)char line[MAX_LINE_LEN ];memset (&line[0 ],0 ,MAX_LINE_LEN ); -snprint_multipath (&line[0 ],MAX_LINE_LEN , style, mpp); +snprint_multipath (&line[0 ],MAX_LINE_LEN , style, mpp,1 );printf ("%s" , line); }
libmultipath/print.h +2 -2
@@ -37,8 +37,8 @@ void get_path_layout (vector pathvec, int header);void get_multipath_layout (vector mpvec,int header);int snprint_path_header (char *,int ,char *);int snprint_multipath_header (char *,int ,char *); -int snprint_path (char *,int ,char *,struct path *); -int snprint_multipath (char *,int ,char *,struct multipath *); +int snprint_path (char *,int ,char *,struct path *,int ); +int snprint_multipath (char *,int ,char *,struct multipath *,int );int snprint_multipath_topology (char *,int ,struct multipath * mpp,int verbosity);int snprint_defaults (char *,int );
multipathd/cli.c +4 -1
@@ -180,7 +180,7 @@ load_keys (void) r +=add_key (keys,"config" ,CONFIG ,0 ); r +=add_key (keys,"blacklist" ,BLACKLIST ,0 ); r +=add_key (keys,"devices" ,DEVICES ,0 ); - r +=add_key (keys,"format" ,FMT ,1 ); + r +=add_key (keys,"raw" ,RAW ,0 ); r +=add_key (keys,"wildcards" ,WILDCARDS ,0 ); r +=add_key (keys,"quit" ,QUIT ,0 ); r +=add_key (keys,"exit" ,QUIT ,0 );
@@ -188,6 +188,7 @@ load_keys (void) r +=add_key (keys,"getprstatus" ,GETPRSTATUS ,0 ); r +=add_key (keys,"setprstatus" ,SETPRSTATUS ,0 ); r +=add_key (keys,"unsetprstatus" ,UNSETPRSTATUS ,0 ); + r +=add_key (keys,"format" ,FMT ,1 );if (r) {free_keys (keys);
@@ -463,6 +464,7 @@ cli_init (void) {add_handler (LIST +PATHS ,NULL );add_handler (LIST +PATHS +FMT ,NULL ); +add_handler (LIST +PATHS +RAW +FMT ,NULL );add_handler (LIST +PATH ,NULL );add_handler (LIST +STATUS ,NULL );add_handler (LIST +DAEMON ,NULL );
@@ -470,6 +472,7 @@ cli_init (void) {add_handler (LIST +MAPS +STATUS ,NULL );add_handler (LIST +MAPS +STATS ,NULL );add_handler (LIST +MAPS +FMT ,NULL ); +add_handler (LIST +MAPS +RAW +FMT ,NULL );add_handler (LIST +MAPS +TOPOLOGY ,NULL );add_handler (LIST +TOPOLOGY ,NULL );add_handler (LIST +MAP +TOPOLOGY ,NULL );
multipathd/cli.h +4 -2
@@ -26,13 +26,14 @@ enum { __CONFIG, __BLACKLIST, __DEVICES, - __FMT, + __RAW, __WILDCARDS, __QUIT, __SHUTDOWN, __GETPRSTATUS, __SETPRSTATUS, __UNSETPRSTATUS, + __FMT, };#define LIST (1 << __LIST)
@@ -62,7 +63,7 @@ enum {#define CONFIG (1 << __CONFIG)#define BLACKLIST (1 << __BLACKLIST)#define DEVICES (1 << __DEVICES) -#define FMT (1 << __FMT) +#define RAW (1 << __RAW)#define COUNT (1 << __COUNT)#define WILDCARDS (1 << __WILDCARDS)#define QUIT (1 << __QUIT)
@@ -70,6 +71,7 @@ enum {#define GETPRSTATUS (1UL << __GETPRSTATUS)#define SETPRSTATUS (1UL << __SETPRSTATUS)#define UNSETPRSTATUS (1UL << __UNSETPRSTATUS) +#define FMT (1UL << __FMT)#define INITIAL_REPLY_LEN 1200
multipathd/cli_handlers.c +37 -13
126 lines not on this page · raw message
multipathd/cli_handlers.h +2 -0
@@ -1,10 +1,12 @@int cli_list_paths (void * v,char ** reply,int * len,void * data);int cli_list_paths_fmt (void * v,char ** reply,int * len,void * data); +int cli_list_paths_raw (void * v,char ** reply,int * len,void * data);int cli_list_path (void * v,char ** reply,int * len,void * data);int cli_list_status (void * v,char ** reply,int * len,void * data);int cli_list_daemon (void * v,char ** reply,int * len,void * data);int cli_list_maps (void * v,char ** reply,int * len,void * data);int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data); +int cli_list_maps_raw (void * v,char ** reply,int * len,void * data);int cli_list_maps_status (void * v,char ** reply,int * len,void * data);int cli_list_maps_stats (void * v,char ** reply,int * len,void * data);int cli_list_map_topology (void * v,char ** reply,int * len,void * data);
multipathd/main.c +2 -0
@@ -904,6 +904,7 @@ uxlsnrloop (void * ap)set_handler_callback (LIST +PATHS , cli_list_paths);set_handler_callback (LIST +PATHS +FMT , cli_list_paths_fmt); +set_handler_callback (LIST +PATHS +RAW +FMT , cli_list_paths_raw);set_handler_callback (LIST +PATH , cli_list_path);set_handler_callback (LIST +MAPS , cli_list_maps);set_handler_callback (LIST +STATUS , cli_list_status);
@@ -911,6 +912,7 @@ uxlsnrloop (void * ap)set_handler_callback (LIST +MAPS +STATUS , cli_list_maps_status);set_handler_callback (LIST +MAPS +STATS , cli_list_maps_stats);set_handler_callback (LIST +MAPS +FMT , cli_list_maps_fmt); +set_handler_callback (LIST +MAPS +RAW +FMT , cli_list_maps_raw);set_handler_callback (LIST +MAPS +TOPOLOGY , cli_list_maps_topology);set_handler_callback (LIST +TOPOLOGY , cli_list_maps_topology);set_handler_callback (LIST +MAP +TOPOLOGY , cli_list_map_topology);
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 3/4 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 option, ignore_new_boot_devs. When enabled, this patch simply keeps multipath from being set up on devices that aren't already in the wwids file (along with all the other checks that multipath already does). This means that only devices that are claimed by "multipath -c" will be used by multipath.
--- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/configure.c | 3 +-- libmultipath/dict.c | 4 ++++ libmultipath/wwids.c | 21 ++++++++++++++------- multipathd/main.c | 3 +-- 6 files changed, 22 insertions(+), 11 deletions(-)
libmultipath/config.c +1 -0
@@ -623,6 +623,7 @@ load_config (char * file, struct udev *udev) conf->retrigger_tries =DEFAULT_RETRIGGER_TRIES ; conf->retrigger_delay =DEFAULT_RETRIGGER_DELAY ; conf->new_bindings_in_boot =0 ; + conf->ignore_new_boot_devs =0 ;/* * preload default hwtable
libmultipath/config.h +1 -0
@@ -138,6 +138,7 @@ struct config {int retrigger_tries;int retrigger_delay;int new_bindings_in_boot; +int ignore_new_boot_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/dict.c +4 -0
@@ -399,6 +399,9 @@ declare_def_snprint(retrigger_delay, print_int) declare_def_handler(new_bindings_in_boot, set_yes_no) declare_def_snprint(new_bindings_in_boot, print_yes_no) +declare_def_handler(ignore_new_boot_devs, set_yes_no) +declare_def_snprint(ignore_new_boot_devs, print_yes_no) +static int def_config_dir_handler (vector strvec) {
@@ -1375,6 +1378,7 @@ init_keywords(void)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 ("new_bindings_in_boot" , &def_new_bindings_in_boot_handler, &snprint_def_new_bindings_in_boot); +install_keyword ("ignore_new_boot_devs" , &def_ignore_new_boot_devs_handler, &snprint_def_ignore_new_boot_devs);__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/wwids.c +14 -7
@@ -15,6 +15,7 @@#include "wwids.h" #include "defaults.h" #include "config.h" +#include "util.h" /* * Copyright (c) 2010 Benjamin Marzinski, Redhat
@@ -265,15 +266,21 @@ should_multipath(struct path *pp1, vector pathvec) {int i;struct path *pp2; +int ignore_new_devs = (conf->ignore_new_boot_devs &&in_initrd ()); + +if (!conf->find_multipaths && !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 (!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 +1 -2
@@ -517,8 +517,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 ; }
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 4/4 Make use of /run depend on systemd
In reply to Benjamin MarzinskiWhile there are other ways to decide whether to use /run or /var/run, I believe this should be good enough, and it uses a Makefile define that already exists. If it doesn't work for everyone, I'll switch it to actually test the directories and add a new define to CFLAGS.
--- libmultipath/defaults.h | 4 ++++ 1 file changed, 4 insertions(+)
libmultipath/defaults.h +4 -0
@@ -27,7 +27,11 @@#define MAX_CHECKINT (a) (a << 2)#define MAX_DEV_LOSS_TMO 0x7FFFFFFF +#ifdef USE_SYSTEMD #define DEFAULT_PIDFILE "/run/multipathd.pid" +#else +#define DEFAULT_PIDFILE "/var/run/multipathd.pid" +#endif #define DEFAULT_CONFIGFILE "/etc/multipath.conf"#define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"#define DEFAULT_WWIDS_FILE "/etc/multipath/wwids"
Signature · 1 line
1.8.3.1