--- libmultipath/config.h | 1 libmultipath/configure.c | 48 ++++++++++++++++++++++++++++++++++++++++------- multipath/main.c | 8 +++++-- 3 files changed, 48 insertions(+), 9 deletions(-) Index: multipath-584343/libmultipath/config.h =================================================================== --- multipath-584343.orig/libmultipath/config.h +++ multipath-584343/libmultipath/config.h @@ -78,6 +78,7 @@ struct config { int flush_on_last_del; int queue_without_daemon; int checker_timeout; + int allow_queueing; uid_t uid; gid_t gid; mode_t mode; Index: multipath-584343/libmultipath/configure.c =================================================================== --- multipath-584343.orig/libmultipath/configure.c +++ multipath-584343/libmultipath/configure.c @@ -13,6 +13,7 @@ #include <sys/file.h> #include <errno.h> #include <libdevmapper.h> +#include <fcntl.h> #include <checkers.h> @@ -438,6 +439,35 @@ deadmap (struct multipath * mpp) return 1; /* dead */ } +int +pidfile_check(const char *file) +{ + int fd; + struct flock lock; + + fd = open(file, O_RDONLY); + if (fd < 0) { + if (errno == ENOENT) + return 0; + condlog(0, "Cannot open pidfile, %s : %s", file, + strerror(errno)); + return -1; + } + lock.l_type = F_WRLCK; + lock.l_start = 0; + lock.l_whence = SEEK_SET; + lock.l_len = 0; + + if (fcntl(fd, F_GETLK, &lock) < 0) { + condlog(0, "Cannot check lock on pidfile, %s : %s", file, + strerror(errno)); + return -1; + } + if (lock.l_type == F_UNLCK) + return 0; + return 1; +} + extern int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid) { @@ -536,13 +566,17 @@ coalesce_paths (struct vectors * vecs, v } if (r == DOMAP_DRY) continue; - - if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) { - if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) - dm_queue_if_no_path(mpp->alias, 0); - else - dm_queue_if_no_path(mpp->alias, 1); - } +#ifndef DAEMON + if (!conf->allow_queueing && !pidfile_check(DEFAULT_PIDFILE)) + dm_queue_if_no_path(mpp->alias, 0); + else +#endif + if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) { + if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) + dm_queue_if_no_path(mpp->alias, 0); + else + dm_queue_if_no_path(mpp->alias, 1); + } if (mpp->pg_timeout != PGTIMEOUT_UNDEF) { if (mpp->pg_timeout == -PGTIMEOUT_NONE) dm_set_pg_timeout(mpp->alias, 0); Index: multipath-584343/multipath/main.c =================================================================== --- multipath-584343.orig/multipath/main.c +++ multipath-584343/multipath/main.c @@ -72,7 +72,7 @@ static void usage (char * progname) { fprintf (stderr, VERSION_STRING); - fprintf (stderr, "Usage: %s\t[-v level] [-d] [-h|-l|-ll|-f|-F|-r]\n", + fprintf (stderr, "Usage: %s\t[-v level] [-d] [-h|-l|-ll|-f|-F|-r|-q]\n", progname); fprintf (stderr, "\t\t\t[-p failover|multibus|group_by_serial|group_by_prio]\n" \ @@ -84,6 +84,7 @@ usage (char * progname) "\t 2\t\t\tdefault verbosity\n" \ "\t 3\t\t\tprint debug information\n" \ "\t-h\t\tprint this usage text\n" \ + "\t-q\t\tallow queue_if_no_path when multipathd is nor running\n"\ "\t-b file\t\tbindings file location\n" \ "\t-d\t\tdry run, do not create or update devmaps\n" \ "\t-l\t\tshow multipath topology (sysfs and DM info)\n" \ @@ -324,7 +325,7 @@ main (int argc, char *argv[]) if (load_config(DEFAULT_CONFIGFILE)) exit(1); - while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:r")) != EOF ) { + while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:rq")) != EOF ) { switch(arg) { case 1: printf("optarg : %s\n",optarg); break; @@ -335,6 +336,9 @@ main (int argc, char *argv[]) conf->verbosity = atoi(optarg); break; + case 'q': + conf->allow_queueing = 1; + break; case 'b': if (conf->bindings_file) FREE(conf->bindings_file);