diff --git a/Makefile b/Makefile index 8bcaba6..1dee368 100644 --- a/Makefile +++ b/Makefile @@ -28,13 +28,8 @@ all: $(BUILDDIRS) $(BUILDDIRS): $(MAKE) -C $@ -libmultipath libdmmp: libmpathcmd -libmpathpersist multipath multipathd: libmultipath -mpathpersist multipathd: libmpathpersist - -libmultipath/checkers.install \ - libmultipath/prioritizers.install \ - libmultipath/foreign.install: libmultipath.install +multipath multipathd mpathpersist: libmultipath +mpathpersist: libmpathpersist $(BUILDDIRS.clean): $(MAKE) -C ${@:.clean=} clean diff --git a/Makefile.inc b/Makefile.inc index 220009e..d4d1e0d 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -37,7 +37,7 @@ endif ifndef SYSTEMD ifeq ($(shell pkg-config --modversion libsystemd >/dev/null 2>&1 && echo 1), 1) - SYSTEMD = $(shell pkg-config --modversion libsystemd | awk '{print $$1}') + SYSTEMD = $(shell pkg-config --modversion libsystemd) else ifeq ($(shell systemctl --version >/dev/null 2>&1 && echo 1), 1) SYSTEMD = $(shell systemctl --version 2> /dev/null | \ @@ -53,7 +53,7 @@ endif prefix = exec_prefix = $(prefix) usr_prefix = $(prefix) -bindir = $(exec_prefix)/usr/sbin +bindir = $(exec_prefix)/sbin libudevdir = $(prefix)/$(SYSTEMDPATH)/udev udevrulesdir = $(libudevdir)/rules.d multipathdir = $(TOPDIR)/libmultipath @@ -89,29 +89,16 @@ TEST_CC_OPTION = $(shell \ echo "$(2)"; \ fi) +STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) -WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,) -ifndef RPM_OPT_FLAGS - STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) - OPTFLAGS = -O2 -g -pipe -Wall -Werror=format-security \ - -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \ - $(STACKPROT) -grecord-gcc-switches \ - -fasynchronous-unwind-tables - ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1) - OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 - endif - ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-annobin-cc1 && echo 1),1) - OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 - endif -else - OPTFLAGS = $(RPM_OPT_FLAGS) -endif -OPTFLAGS += -Werror -Wextra -Wstrict-prototypes -Wformat=2 \ - -Werror=implicit-int -Werror=implicit-function-declaration \ - $(WNOCLOBBERED) \ - -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ - --param=ssp-buffer-size=4 +WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered,) +OPTFLAGS = -O2 -g -pipe -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \ + -Werror=implicit-function-declaration -Werror=format-security \ + $(WNOCLOBBERED) \ + -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ + $(STACKPROT) --param=ssp-buffer-size=4 +CPPFLAGS := -Wp,-D_FORTIFY_SOURCE=2 CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ -MMD -MP $(CFLAGS) BIN_CFLAGS = -fPIE -DPIE @@ -148,4 +135,4 @@ check_file = $(shell \ %.o: %.c @echo building $@ because of $? - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< diff --git a/kpartx/bsd.c b/kpartx/bsd.c index 950b0f9..0e661fb 100644 --- a/kpartx/bsd.c +++ b/kpartx/bsd.c @@ -1,7 +1,6 @@ #include "kpartx.h" #include -#define BSD_LABEL_OFFSET 64 #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ #define XBSD_MAXPARTITIONS 16 #define BSD_FS_UNUSED 0 @@ -61,19 +60,8 @@ read_bsd_pt(int fd, struct slice all, struct slice *sp, unsigned int ns) { return -1; l = (struct bsd_disklabel *) bp; - if (l->d_magic != BSD_DISKMAGIC) { - /* - * BSD disklabels can also start 64 bytes offset from the - * start of the first sector - */ - bp = getblock(fd, offset); - if (bp == NULL) - return -1; - - l = (struct bsd_disklabel *)(bp + 64); - if (l->d_magic != BSD_DISKMAGIC) - return -1; - } + if (l->d_magic != BSD_DISKMAGIC) + return -1; max_partitions = 16; if (l->d_npartitions < max_partitions) diff --git a/kpartx/dasd.c b/kpartx/dasd.c index f039864..14b9d3a 100644 --- a/kpartx/dasd.c +++ b/kpartx/dasd.c @@ -22,7 +22,6 @@ * along with this program. If not, see . */ -#define _GNU_SOURCE #include #include #include @@ -118,13 +117,13 @@ read_dasd_pt(int fd, __attribute__((unused)) struct slice all, sprintf(pathname, "/dev/.kpartx-node-%u-%u", (unsigned int)major(dev), (unsigned int)minor(dev)); - if ((fd_dasd = open(pathname, O_RDONLY | O_DIRECT)) == -1) { + if ((fd_dasd = open(pathname, O_RDONLY)) == -1) { /* Devicenode does not exist. Try to create one */ if (mknod(pathname, 0600 | S_IFBLK, dev) == -1) { /* Couldn't create a device node */ return -1; } - fd_dasd = open(pathname, O_RDONLY | O_DIRECT); + fd_dasd = open(pathname, O_RDONLY); /* * The file will vanish when the last process (we) * has ceased to access it. @@ -176,7 +175,7 @@ read_dasd_pt(int fd, __attribute__((unused)) struct slice all, * Get volume label, extract name and type. */ - if (aligned_malloc((void **)&data, blocksize, NULL)) + if (!(data = (unsigned char *)malloc(blocksize))) goto out; diff --git a/kpartx/gpt.c b/kpartx/gpt.c index f7fefb7..785b34e 100644 --- a/kpartx/gpt.c +++ b/kpartx/gpt.c @@ -243,7 +243,8 @@ alloc_read_gpt_entries(int fd, gpt_header * gpt) if (!count) return NULL; - if (aligned_malloc((void **)&pte, get_sector_size(fd), &count)) + pte = (gpt_entry *)malloc(count); + if (!pte) return NULL; memset(pte, 0, count); @@ -268,11 +269,12 @@ static gpt_header * alloc_read_gpt_header(int fd, uint64_t lba) { gpt_header *gpt; - size_t size = sizeof (gpt_header); - if (aligned_malloc((void **)&gpt, get_sector_size(fd), &size)) + gpt = (gpt_header *) + malloc(sizeof (gpt_header)); + if (!gpt) return NULL; - memset(gpt, 0, size); - if (!read_lba(fd, lba, gpt, size)) { + memset(gpt, 0, sizeof (*gpt)); + if (!read_lba(fd, lba, gpt, sizeof (gpt_header))) { free(gpt); return NULL; } @@ -496,7 +498,6 @@ find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes) gpt_header *pgpt = NULL, *agpt = NULL; gpt_entry *pptes = NULL, *aptes = NULL; legacy_mbr *legacymbr = NULL; - size_t size = sizeof(legacy_mbr); uint64_t lastlba; if (!gpt || !ptes) return 0; @@ -525,10 +526,11 @@ find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes) } /* This will be added to the EFI Spec. per Intel after v1.02. */ - if (aligned_malloc((void **)&legacymbr, get_sector_size(fd), - &size) == 0) { - memset(legacymbr, 0, size); - read_lba(fd, 0, (uint8_t *) legacymbr, size); + legacymbr = malloc(sizeof (*legacymbr)); + if (legacymbr) { + memset(legacymbr, 0, sizeof (*legacymbr)); + read_lba(fd, 0, (uint8_t *) legacymbr, + sizeof (*legacymbr)); good_pmbr = is_pmbr_valid(legacymbr); free(legacymbr); legacymbr=NULL; diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c index 653ce0c..d3620c5 100644 --- a/kpartx/kpartx.c +++ b/kpartx/kpartx.c @@ -19,7 +19,6 @@ * cva, 2002-10-26 */ -#define _GNU_SOURCE #include #include #include @@ -42,6 +41,7 @@ #define SIZE(a) (sizeof(a)/sizeof((a)[0])) +#define READ_SIZE 1024 #define MAXTYPES 64 #define MAXSLICES 256 #define DM_TARGET "linear" @@ -388,7 +388,7 @@ main(int argc, char **argv){ set_delimiter(mapname, delim); } - fd = open(device, O_RDONLY | O_DIRECT); + fd = open(device, O_RDONLY); if (fd == -1) { perror(device); @@ -690,9 +690,9 @@ xmalloc (size_t size) { */ static int -sseek(int fd, unsigned int secnr, int secsz) { +sseek(int fd, unsigned int secnr) { off64_t in, out; - in = ((off64_t) secnr * secsz); + in = ((off64_t) secnr << 9); out = 1; if ((out = lseek64(fd, in, SEEK_SET)) != in) @@ -703,31 +703,6 @@ sseek(int fd, unsigned int secnr, int secsz) { return 0; } -int -aligned_malloc(void **mem_p, size_t align, size_t *size_p) -{ - static size_t pgsize = 0; - size_t size; - int err; - - if (!mem_p || !align || (size_p && !*size_p)) - return EINVAL; - - if (!pgsize) - pgsize = getpagesize(); - - if (size_p) - size = ((*size_p + align - 1) / align) * align; - else - size = pgsize; - - err = posix_memalign(mem_p, pgsize, size); - if (!err && size_p) - *size_p = size; - return err; -} - -/* always in sector size blocks */ static struct block { unsigned int secnr; @@ -735,39 +710,30 @@ struct block { struct block *next; } *blockhead; -/* blknr is always in 512 byte blocks */ char * -getblock (int fd, unsigned int blknr) { - int secsz = get_sector_size(fd); - unsigned int blks_per_sec = secsz / 512; - unsigned int secnr = blknr / blks_per_sec; - unsigned int blk_off = (blknr % blks_per_sec) * 512; +getblock (int fd, unsigned int secnr) { struct block *bp; for (bp = blockhead; bp; bp = bp->next) if (bp->secnr == secnr) - return bp->block + blk_off; + return bp->block; - if (sseek(fd, secnr, secsz)) + if (sseek(fd, secnr)) return NULL; bp = xmalloc(sizeof(struct block)); bp->secnr = secnr; bp->next = blockhead; blockhead = bp; - if (aligned_malloc((void **)&bp->block, secsz, NULL)) { - fprintf(stderr, "aligned_malloc failed\n"); - exit(1); - } + bp->block = (char *) xmalloc(READ_SIZE); - if (read(fd, bp->block, secsz) != secsz) { + if (read(fd, bp->block, READ_SIZE) != READ_SIZE) { fprintf(stderr, "read error, sector %d\n", secnr); - blockhead = bp->next; - return NULL; + bp->block = NULL; } - return bp->block + blk_off; + return bp->block; } int diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h index 727632c..67edeb8 100644 --- a/kpartx/kpartx.h +++ b/kpartx/kpartx.h @@ -1,7 +1,6 @@ #ifndef _KPARTX_H #define _KPARTX_H -#include #include #include @@ -62,7 +61,6 @@ extern ptreader read_mac_pt; extern ptreader read_sun_pt; extern ptreader read_ps3_pt; -int aligned_malloc(void **mem_p, size_t align, size_t *size_p); char *getblock(int fd, unsigned int secnr); static inline unsigned int diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules index 8a3a171..8f99049 100644 --- a/kpartx/kpartx.rules +++ b/kpartx/kpartx.rules @@ -32,6 +32,6 @@ LABEL="mpath_kpartx_end" GOTO="kpartx_end" LABEL="run_kpartx" -RUN+="/sbin/kpartx -un /dev/$name" +RUN+="/sbin/kpartx -un -p -part /dev/$name" LABEL="kpartx_end" diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c index a01dfb0..3da7a6c 100644 --- a/libmpathpersist/mpath_persist.c +++ b/libmpathpersist/mpath_persist.c @@ -307,10 +307,9 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, memcpy(&prkey, paramp->sa_key, 8); if (mpp->prkey_source == PRKEY_SOURCE_FILE && prkey && - (rq_servact == MPATH_PROUT_REG_IGN_SA || - (rq_servact == MPATH_PROUT_REG_SA && - (!get_be64(mpp->reservation_key) || - memcmp(paramp->key, &mpp->reservation_key, 8) == 0)))) { + ((!get_be64(mpp->reservation_key) && + rq_servact == MPATH_PROUT_REG_SA) || + rq_servact == MPATH_PROUT_REG_IGN_SA)) { memcpy(&mpp->reservation_key, paramp->sa_key, 8); if (update_prkey_flags(alias, get_be64(mpp->reservation_key), paramp->sa_flags)) { @@ -322,8 +321,7 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, } if (memcmp(paramp->key, &mpp->reservation_key, 8) && - memcmp(paramp->sa_key, &mpp->reservation_key, 8) && - (prkey || rq_servact != MPATH_PROUT_REG_IGN_SA)) { + memcmp(paramp->sa_key, &mpp->reservation_key, 8)) { condlog(0, "%s: configured reservation key doesn't match: 0x%" PRIx64, alias, get_be64(mpp->reservation_key)); ret = MPATH_PR_SYNTAX_ERROR; goto out1; diff --git a/libmultipath/Makefile b/libmultipath/Makefile index ad690a4..e5651e4 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -36,10 +36,6 @@ ifneq ($(call check_func,dm_task_deferred_remove,/usr/include/libdevmapper.h),0) CFLAGS += -DLIBDM_API_DEFERRED endif -ifneq ($(call check_func,dm_hold_control_dev,/usr/include/libdevmapper.h),0) - CFLAGS += -DLIBDM_API_HOLD_CONTROL -endif - OBJS = memory.o parser.o vector.o devmapper.o callout.o \ hwtable.o blacklist.o util.o dmparser.o config.o \ structs.o discovery.o propsel.o dict.o \ diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c index 0c58aa3..00e8dbd 100644 --- a/libmultipath/blacklist.c +++ b/libmultipath/blacklist.c @@ -15,24 +15,9 @@ #include "structs_vec.h" #include "print.h" -char *check_invert(char *str, bool *invert) -{ - if (str[0] == '!') { - *invert = true; - return str + 1; - } - if (str[0] == '\\' && str[1] == '!') { - *invert = false; - return str + 1; - } - *invert = false; - return str; -} - int store_ble(vector blist, char * str, int origin) { struct blentry * ble; - char *regex_str; if (!str) return 0; @@ -45,8 +30,7 @@ int store_ble(vector blist, char * str, int origin) if (!ble) goto out; - regex_str = check_invert(str, &ble->invert); - if (regcomp(&ble->regex, regex_str, REG_EXTENDED|REG_NOSUB)) + if (regcomp(&ble->regex, str, REG_EXTENDED|REG_NOSUB)) goto out1; if (!vector_alloc_slot(blist)) @@ -82,7 +66,6 @@ int alloc_ble_device(vector blist) int set_ble_device(vector blist, char * vendor, char * product, int origin) { struct blentry_device * ble; - char *regex_str; if (!blist) return 1; @@ -93,8 +76,7 @@ int set_ble_device(vector blist, char * vendor, char * product, int origin) return 1; if (vendor) { - regex_str = check_invert(vendor, &ble->vendor_invert); - if (regcomp(&ble->vendor_reg, regex_str, + if (regcomp(&ble->vendor_reg, vendor, REG_EXTENDED|REG_NOSUB)) { FREE(vendor); if (product) @@ -104,8 +86,7 @@ int set_ble_device(vector blist, char * vendor, char * product, int origin) ble->vendor = vendor; } if (product) { - regex_str = check_invert(product, &ble->product_invert); - if (regcomp(&ble->product_reg, regex_str, + if (regcomp(&ble->product_reg, product, REG_EXTENDED|REG_NOSUB)) { FREE(product); if (vendor) { @@ -120,22 +101,54 @@ int set_ble_device(vector blist, char * vendor, char * product, int origin) return 0; } -static int -match_reglist (vector blist, const char * str) +int +_blacklist_exceptions (vector elist, const char * str) +{ + int i; + struct blentry * ele; + + vector_foreach_slot (elist, ele, i) { + if (!regexec(&ele->regex, str, 0, NULL, 0)) + return 1; + } + return 0; +} + +int +_blacklist (vector blist, const char * str) { int i; struct blentry * ble; vector_foreach_slot (blist, ble, i) { - if (!!regexec(&ble->regex, str, 0, NULL, 0) == ble->invert) + if (!regexec(&ble->regex, str, 0, NULL, 0)) return 1; } return 0; } -static int -match_reglist_device (const struct _vector *blist, const char * vendor, - const char * product) +int +_blacklist_exceptions_device(const struct _vector *elist, const char * vendor, + const char * product) +{ + int i; + struct blentry_device * ble; + + vector_foreach_slot (elist, ble, i) { + if (!ble->vendor && !ble->product) + continue; + if ((!ble->vendor || + !regexec(&ble->vendor_reg, vendor, 0, NULL, 0)) && + (!ble->product || + !regexec(&ble->product_reg, product, 0, NULL, 0))) + return 1; + } + return 0; +} + +int +_blacklist_device (const struct _vector *blist, const char * vendor, + const char * product) { int i; struct blentry_device * ble; @@ -144,11 +157,9 @@ match_reglist_device (const struct _vector *blist, const char * vendor, if (!ble->vendor && !ble->product) continue; if ((!ble->vendor || - !!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) == - ble->vendor_invert) && + !regexec(&ble->vendor_reg, vendor, 0, NULL, 0)) && (!ble->product || - !!regexec(&ble->product_reg, product, 0, NULL, 0) == - ble->product_invert)) + !regexec(&ble->product_reg, product, 0, NULL, 0))) return 1; } return 0; @@ -181,12 +192,24 @@ setup_default_blist (struct config * conf) char * str; int i; - str = STRDUP("!^(sd[a-z]|dasd[a-z]|nvme[0-9])"); + str = STRDUP("^(ram|zram|raw|loop|fd|md|dm-|sr|scd|st|dcssblk)[0-9]"); + if (!str) + return 1; + if (store_ble(conf->blist_devnode, str, ORIGIN_DEFAULT)) + return 1; + + str = STRDUP("^(td|hd|vd)[a-z]"); if (!str) return 1; if (store_ble(conf->blist_devnode, str, ORIGIN_DEFAULT)) return 1; + str = STRDUP("(SCSI_IDENT_|ID_WWN)"); + if (!str) + return 1; + if (store_ble(conf->elist_property, str, ORIGIN_DEFAULT)) + return 1; + vector_foreach_slot (conf->hwtable, hwe, i) { if (hwe->bl_product) { if (find_blacklist_device(conf->blist_device, @@ -277,9 +300,9 @@ filter_device (vector blist, vector elist, char * vendor, char * product, int r = MATCH_NOTHING; if (vendor && product) { - if (match_reglist_device(elist, vendor, product)) + if (_blacklist_exceptions_device(elist, vendor, product)) r = MATCH_DEVICE_BLIST_EXCEPT; - else if (match_reglist_device(blist, vendor, product)) + else if (_blacklist_device(blist, vendor, product)) r = MATCH_DEVICE_BLIST; } @@ -293,9 +316,9 @@ filter_devnode (vector blist, vector elist, char * dev) int r = MATCH_NOTHING; if (dev) { - if (match_reglist(elist, dev)) + if (_blacklist_exceptions(elist, dev)) r = MATCH_DEVNODE_BLIST_EXCEPT; - else if (match_reglist(blist, dev)) + else if (_blacklist(blist, dev)) r = MATCH_DEVNODE_BLIST; } @@ -309,9 +332,9 @@ filter_wwid (vector blist, vector elist, char * wwid, char * dev) int r = MATCH_NOTHING; if (wwid) { - if (match_reglist(elist, wwid)) + if (_blacklist_exceptions(elist, wwid)) r = MATCH_WWID_BLIST_EXCEPT; - else if (match_reglist(blist, wwid)) + else if (_blacklist(blist, wwid)) r = MATCH_WWID_BLIST; } @@ -328,9 +351,9 @@ filter_protocol(vector blist, vector elist, struct path * pp) if (pp) { snprint_path_protocol(buf, sizeof(buf), pp); - if (match_reglist(elist, buf)) + if (_blacklist_exceptions(elist, buf)) r = MATCH_PROTOCOL_BLIST_EXCEPT; - else if (match_reglist(blist, buf)) + else if (_blacklist(blist, buf)) r = MATCH_PROTOCOL_BLIST; } @@ -388,8 +411,7 @@ filter_property(struct config *conf, struct udev_device *udev, int lvl, *uid_attribute != '\0'; bool uid_attr_seen = false; - if (VECTOR_SIZE(conf->elist_property)) - r = MATCH_PROPERTY_BLIST_MISSING; + r = MATCH_PROPERTY_BLIST_MISSING; udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev)) { @@ -400,11 +422,11 @@ filter_property(struct config *conf, struct udev_device *udev, int lvl, if (check_missing_prop && !strcmp(env, uid_attribute)) uid_attr_seen = true; - if (match_reglist(conf->elist_property, env)) { + if (_blacklist_exceptions(conf->elist_property, env)) { r = MATCH_PROPERTY_BLIST_EXCEPT; break; } - if (match_reglist(conf->blist_property, env)) { + if (_blacklist(conf->blist_property, env)) { r = MATCH_PROPERTY_BLIST; break; } diff --git a/libmultipath/blacklist.h b/libmultipath/blacklist.h index 4305857..2d721f6 100644 --- a/libmultipath/blacklist.h +++ b/libmultipath/blacklist.h @@ -20,7 +20,6 @@ struct blentry { char * str; regex_t regex; - bool invert; int origin; }; @@ -29,8 +28,6 @@ struct blentry_device { char * product; regex_t vendor_reg; regex_t product_reg; - bool vendor_invert; - bool product_invert; int origin; }; diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 6359e5d..8d2be8a 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -21,7 +21,6 @@ struct checker_class { void (*reset)(void); /* to reset the global variables */ const char **msgtable; short msgtable_size; - int keep_dso; }; char *checker_state_names[] = { @@ -70,7 +69,7 @@ void free_checker_class(struct checker_class *c) list_del(&c->node); if (c->reset) c->reset(); - if (c->handle && !c->keep_dso) { + if (c->handle) { if (dlclose(c->handle) != 0) { condlog(0, "Cannot unload checker %s: %s", c->name, dlerror()); @@ -193,13 +192,6 @@ out: return NULL; } -void checker_keep_dso(struct checker * c) -{ - if (!c || !c->cls) - return; - c->cls->keep_dso = 1; -} - void checker_set_fd (struct checker * c, int fd) { if (!c) diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index f183cff..b458118 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -145,7 +145,6 @@ void checker_reset (struct checker *); void checker_set_sync (struct checker *); void checker_set_async (struct checker *); void checker_set_fd (struct checker *, int); -void checker_keep_dso(struct checker *c); void checker_enable (struct checker *); void checker_disable (struct checker *); int checker_check (struct checker *, int); diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index fd58d62..e886fcf 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -394,7 +394,6 @@ int libcheck_check(struct checker * c) uatomic_set(&ct->running, 1); tur_set_async_timeout(c); setup_thread_attr(&attr, 32 * 1024, 1); - checker_keep_dso(c); r = pthread_create(&ct->thread, &attr, tur_thread, ct); pthread_attr_destroy(&attr); if (r) { diff --git a/libmultipath/config.c b/libmultipath/config.c index dc81c99..b4d8768 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -26,7 +26,6 @@ #include "devmapper.h" #include "mpath_cmd.h" #include "propsel.h" -#include "version.h" static int hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2) @@ -359,7 +358,6 @@ merge_hwe (struct hwentry * dst, struct hwentry * src) merge_num(flush_on_last_del); merge_num(fast_io_fail); merge_num(dev_loss); - merge_num(eh_deadline); merge_num(user_friendly_names); merge_num(retain_hwhandler); merge_num(detect_prio); @@ -444,13 +442,6 @@ void merge_mptable(vector mptable) int i, j; vector_foreach_slot(mptable, mp1, i) { - /* drop invalid multipath configs */ - if (!mp1->wwid) { - condlog(0, "multipaths config section missing wwid"); - vector_del_slot(mptable, i--); - free_mpe(mp1); - continue; - } j = i + 1; vector_foreach_slot_after(mptable, mp2, j) { if (strcmp(mp1->wwid, mp2->wwid)) @@ -522,7 +513,6 @@ store_hwe (vector hwtable, struct hwentry * dhwe) hwe->flush_on_last_del = dhwe->flush_on_last_del; hwe->fast_io_fail = dhwe->fast_io_fail; hwe->dev_loss = dhwe->dev_loss; - hwe->eh_deadline = dhwe->eh_deadline; hwe->user_friendly_names = dhwe->user_friendly_names; hwe->retain_hwhandler = dhwe->retain_hwhandler; hwe->detect_prio = dhwe->detect_prio; @@ -788,22 +778,6 @@ load_config (char * file) goto out; } factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); - } else { - condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices."); - condlog(0, "You can run \"/sbin/mpathconf --enable\" to create"); - condlog(0, "/etc/multipath.conf. See man mpathconf(8) for more details"); - if (conf->blist_devnode == NULL) { - conf->blist_devnode = vector_alloc(); - if (!conf->blist_devnode) { - condlog(0, "cannot allocate blacklist\n"); - goto out; - } - } - if (store_ble(conf->blist_devnode, strdup(".*"), - ORIGIN_NO_CONFIG)) { - condlog(0, "cannot store default no-config blacklist\n"); - goto out; - } } conf->processed_main_config = 1; diff --git a/libmultipath/config.h b/libmultipath/config.h index a22c1b4..ceecff2 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -9,7 +9,14 @@ #define ORIGIN_DEFAULT 0 #define ORIGIN_CONFIG 1 -#define ORIGIN_NO_CONFIG 2 + +/* + * In kernel, fast_io_fail == 0 means immediate failure on rport delete. + * OTOH '0' means not-configured in various places in multipath-tools. + */ +#define MP_FAST_IO_FAIL_UNSET (0) +#define MP_FAST_IO_FAIL_OFF (-1) +#define MP_FAST_IO_FAIL_ZERO (-2) enum devtypes { DEV_NONE, @@ -31,8 +38,6 @@ enum mpath_cmds { CMD_ADD_WWID, CMD_USABLE_PATHS, CMD_DUMP_CONFIG, - CMD_FLUSH_ONE, - CMD_FLUSH_ALL, }; enum force_reload_types { @@ -64,7 +69,6 @@ struct hwentry { int flush_on_last_del; int fast_io_fail; unsigned int dev_loss; - int eh_deadline; int user_friendly_names; int retain_hwhandler; int detect_prio; @@ -138,6 +142,7 @@ struct config { unsigned int max_checkint; bool use_watchdog; int pgfailback; + int remove; int rr_weight; int no_path_retry; int user_friendly_names; @@ -150,7 +155,6 @@ struct config { int attribute_flags; int fast_io_fail; unsigned int dev_loss; - int eh_deadline; int log_checker_err; int allow_queueing; int find_multipaths; @@ -185,7 +189,6 @@ struct config { int ghost_delay; int find_multipaths_timeout; int marginal_pathgroups; - int skip_delegate; unsigned int version[3]; unsigned int sequence_nr; diff --git a/libmultipath/configure.c b/libmultipath/configure.c index b711329..c95848a 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -340,7 +340,6 @@ int setup_map(struct multipath *mpp, char *params, int params_size, select_gid(conf, mpp); select_fast_io_fail(conf, mpp); select_dev_loss(conf, mpp); - select_eh_deadline(conf, mpp); select_reservation_key(conf, mpp); select_deferred_remove(conf, mpp); select_marginal_path_err_sample_time(conf, mpp); @@ -711,6 +710,12 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) return; } + if (pathcount(mpp, PATH_UP) == 0) { + mpp->action = ACT_IMPOSSIBLE; + condlog(3, "%s: set ACT_IMPOSSIBLE (no usable path)", + mpp->alias); + return; + } if (force_reload) { mpp->force_udev_reload = 1; mpp->action = ACT_RELOAD; diff --git a/libmultipath/configure.h b/libmultipath/configure.h index 0e33bf4..d750900 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -45,6 +45,9 @@ enum { CP_RETRY, }; +#define FLUSH_ONE 1 +#define FLUSH_ALL 2 + struct vectors; int setup_map (struct multipath * mpp, char * params, int params_size, diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index 52fe05b..e5ee6af 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -22,7 +22,7 @@ #define DEFAULT_NO_PATH_RETRY NO_PATH_RETRY_UNDEF #define DEFAULT_VERBOSITY 2 #define DEFAULT_REASSIGN_MAPS 0 -#define DEFAULT_FIND_MULTIPATHS FIND_MULTIPATHS_OFF +#define DEFAULT_FIND_MULTIPATHS FIND_MULTIPATHS_STRICT #define DEFAULT_FAST_IO_FAIL 5 #define DEFAULT_DEV_LOSS_TMO 600 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_ON diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 3f70e57..bed8ddc 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -108,9 +108,7 @@ dm_lib_prereq (void) { char version[64]; int v[3]; -#if defined(LIBDM_API_HOLD_CONTROL) - int minv[3] = {1, 2, 111}; -#elif defined(LIBDM_API_DEFERRED) +#if defined(LIBDM_API_DEFERRED) int minv[3] = {1, 2, 89}; #elif defined(DM_SUBSYSTEM_UDEV_FLAG0) int minv[3] = {1, 2, 82}; @@ -256,9 +254,6 @@ void libmp_dm_init(void) memcpy(conf->version, version, sizeof(version)); put_multipath_config(conf); dm_init(verbosity); -#ifdef LIBDM_API_HOLD_CONTROL - dm_hold_control_dev(1); -#endif dm_udev_set_sync_support(libmp_dm_udev_sync); } @@ -408,8 +403,7 @@ static uint16_t build_udev_flags(const struct multipath *mpp, int reload) /* DM_UDEV_DISABLE_LIBRARY_FALLBACK is added in dm_addmap */ return (mpp->skip_kpartx == SKIP_KPARTX_ON ? MPATH_UDEV_NO_KPARTX_FLAG : 0) | - ((count_active_pending_paths(mpp) == 0 || - mpp->ghost_delay_tick > 0) ? + ((count_active_paths(mpp) == 0 || mpp->ghost_delay_tick > 0) ? MPATH_UDEV_NO_PATHS_FLAG : 0) | (reload && !mpp->force_udev_reload ? MPATH_UDEV_RELOAD_FLAG : 0); @@ -526,43 +520,36 @@ int dm_map_present(const char * str) int dm_get_map(const char *name, unsigned long long *size, char *outparams) { - int r = DMP_ERR; + int r = 1; struct dm_task *dmt; uint64_t start, length; char *target_type = NULL; char *params = NULL; if (!(dmt = libmp_dm_task_create(DM_DEVICE_TABLE))) - return r; + return 1; if (!dm_task_set_name(dmt, name)) goto out; dm_task_no_open_count(dmt); - errno = 0; - if (!dm_task_run(dmt)) { - if (dm_task_get_errno(dmt) == ENXIO) - r = DMP_NOT_FOUND; + if (!dm_task_run(dmt)) goto out; - } - r = DMP_NOT_FOUND; /* Fetch 1st target */ - if (dm_get_next_target(dmt, NULL, &start, &length, - &target_type, ¶ms) != NULL) - /* more than one target */ - goto out; + dm_get_next_target(dmt, NULL, &start, &length, + &target_type, ¶ms); if (size) *size = length; if (!outparams) { - r = DMP_OK; + r = 0; goto out; } if (snprintf(outparams, PARAMS_SIZE, "%s", params) <= PARAMS_SIZE) - r = DMP_OK; + r = 0; out: dm_task_destroy(dmt); return r; @@ -636,45 +623,35 @@ is_mpath_part(const char *part_name, const char *map_name) int dm_get_status(const char *name, char *outstatus) { - int r = DMP_ERR; + int r = 1; struct dm_task *dmt; uint64_t start, length; char *target_type = NULL; char *status = NULL; if (!(dmt = libmp_dm_task_create(DM_DEVICE_STATUS))) - return r; + return 1; if (!dm_task_set_name(dmt, name)) goto out; dm_task_no_open_count(dmt); - errno = 0; - if (!dm_task_run(dmt)) { - if (dm_task_get_errno(dmt) == ENXIO) - r = DMP_NOT_FOUND; + if (!dm_task_run(dmt)) goto out; - } - r = DMP_NOT_FOUND; /* Fetch 1st target */ - if (dm_get_next_target(dmt, NULL, &start, &length, - &target_type, &status) != NULL) - goto out; - - if (!target_type || strcmp(target_type, TGT_MPATH) != 0) - goto out; - + dm_get_next_target(dmt, NULL, &start, &length, + &target_type, &status); if (!status) { condlog(2, "get null status."); goto out; } if (snprintf(outstatus, PARAMS_SIZE, "%s", status) <= PARAMS_SIZE) - r = DMP_OK; + r = 0; out: - if (r != DMP_OK) + if (r) condlog(0, "%s: error getting map status string", name); dm_task_destroy(dmt); @@ -884,7 +861,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, return 1; if (need_suspend && - dm_get_map(mapname, &mapsize, params) == DMP_OK && + !dm_get_map(mapname, &mapsize, params) && strstr(params, "queue_if_no_path")) { if (!dm_queue_if_no_path(mapname, 0)) queue_if_no_path = 1; @@ -952,15 +929,15 @@ dm_flush_map_nopaths(const char * mapname, int deferred_remove) #endif -int dm_flush_maps (int need_suspend, int retries) +int dm_flush_maps (int retries) { - int r = 1; + int r = 0; struct dm_task *dmt; struct dm_names *names; unsigned next = 0; if (!(dmt = libmp_dm_task_create (DM_DEVICE_LIST))) - return r; + return 0; dm_task_no_open_count(dmt); @@ -970,15 +947,11 @@ int dm_flush_maps (int need_suspend, int retries) if (!(names = dm_task_get_names (dmt))) goto out; - r = 0; if (!names->dev) goto out; do { - if (need_suspend) - r |= dm_suspend_and_flush_map(names->name, retries); - else - r |= dm_flush_map(names->name); + r |= dm_suspend_and_flush_map(names->name, retries); next = names->next; names = (void *) names + next; } while (next); @@ -1097,7 +1070,7 @@ struct multipath *dm_get_multipath(const char *name) if (!mpp->alias) goto out; - if (dm_get_map(name, &mpp->size, NULL) != DMP_OK) + if (dm_get_map(name, &mpp->size, NULL)) goto out; dm_get_uuid(name, mpp->wwid, WWID_SIZE); @@ -1281,7 +1254,7 @@ do_foreach_partmaps (const char * mapname, /* * and we can fetch the map table from the kernel */ - dm_get_map(names->name, &size, ¶ms[0]) == DMP_OK && + !dm_get_map(names->name, &size, ¶ms[0]) && /* * and the table maps over the multipath map diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 7e8812a..7557a86 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -27,12 +27,6 @@ #define UUID_PREFIX "mpath-" #define UUID_PREFIX_LEN (sizeof(UUID_PREFIX) - 1) -enum { - DMP_ERR, - DMP_OK, - DMP_NOT_FOUND, -}; - void dm_init(int verbosity); void libmp_dm_init(void); void libmp_udev_set_sync_support(int on); @@ -55,7 +49,7 @@ int dm_flush_map_nopaths(const char * mapname, int deferred_remove); #define dm_suspend_and_flush_map(mapname, retries) \ _dm_flush_map(mapname, 1, 0, 1, retries) int dm_cancel_deferred_remove(struct multipath *mpp); -int dm_flush_maps (int need_suspend, int retries); +int dm_flush_maps (int retries); int dm_fail_path(const char * mapname, char * path); int dm_reinstate_path(const char * mapname, char * path); int dm_queue_if_no_path(const char *mapname, int enable); diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 8fd91d8..3e25e74 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -60,22 +60,19 @@ static int set_uint(vector strvec, void *ptr) { unsigned int *uint_ptr = (unsigned int *)ptr; - char *buff, *eptr, *p; - unsigned long res; + char *buff, *eptr; + long res; int rc; buff = set_value(strvec); if (!buff) return 1; - p = buff; - while (isspace(*p)) - p++; - res = strtoul(p, &eptr, 10); + res = strtol(buff, &eptr, 10); if (eptr > buff) while (isspace(*eptr)) eptr++; - if (*buff == '\0' || *eptr != '\0' || !isdigit(*p) || res > UINT_MAX) { + if (*buff == '\0' || *eptr != '\0' || res < 0 || res > UINT_MAX) { condlog(1, "%s: invalid value for %s: \"%s\"", __func__, (char*)VECTOR_SLOT(strvec, 0), buff); rc = 1; @@ -104,21 +101,6 @@ set_str(vector strvec, void *ptr) } static int -set_regex(vector strvec, void *ptr) -{ - char **str_ptr = (char **)ptr; - - if (*str_ptr) - FREE(*str_ptr); - *str_ptr = set_regex_value(strvec); - - if (!*str_ptr) - return 1; - - return 0; -} - -static int set_yes_no(vector strvec, void *ptr) { char * buff; @@ -834,7 +816,7 @@ declare_mp_attr_handler(gid, set_gid) declare_mp_attr_snprint(gid, print_gid) static int -set_undef_off_zero(vector strvec, void *ptr) +set_fast_io_fail(vector strvec, void *ptr) { char * buff; int *int_ptr = (int *)ptr; @@ -844,36 +826,36 @@ set_undef_off_zero(vector strvec, void *ptr) return 1; if (strcmp(buff, "off") == 0) - *int_ptr = UOZ_OFF; + *int_ptr = MP_FAST_IO_FAIL_OFF; else if (sscanf(buff, "%d", int_ptr) != 1 || - *int_ptr < UOZ_ZERO) - *int_ptr = UOZ_UNDEF; + *int_ptr < MP_FAST_IO_FAIL_ZERO) + *int_ptr = MP_FAST_IO_FAIL_UNSET; else if (*int_ptr == 0) - *int_ptr = UOZ_ZERO; + *int_ptr = MP_FAST_IO_FAIL_ZERO; FREE(buff); return 0; } int -print_undef_off_zero(char * buff, int len, long v) +print_fast_io_fail(char * buff, int len, long v) { - if (v == UOZ_UNDEF) + if (v == MP_FAST_IO_FAIL_UNSET) return 0; - if (v == UOZ_OFF) + if (v == MP_FAST_IO_FAIL_OFF) return snprintf(buff, len, "\"off\""); - if (v == UOZ_ZERO) + if (v == MP_FAST_IO_FAIL_ZERO) return snprintf(buff, len, "0"); return snprintf(buff, len, "%ld", v); } -declare_def_handler(fast_io_fail, set_undef_off_zero) -declare_def_snprint_defint(fast_io_fail, print_undef_off_zero, +declare_def_handler(fast_io_fail, set_fast_io_fail) +declare_def_snprint_defint(fast_io_fail, print_fast_io_fail, DEFAULT_FAST_IO_FAIL) -declare_ovr_handler(fast_io_fail, set_undef_off_zero) -declare_ovr_snprint(fast_io_fail, print_undef_off_zero) -declare_hw_handler(fast_io_fail, set_undef_off_zero) -declare_hw_snprint(fast_io_fail, print_undef_off_zero) +declare_ovr_handler(fast_io_fail, set_fast_io_fail) +declare_ovr_snprint(fast_io_fail, print_fast_io_fail) +declare_hw_handler(fast_io_fail, set_fast_io_fail) +declare_hw_snprint(fast_io_fail, print_fast_io_fail) static int set_dev_loss(vector strvec, void *ptr) @@ -911,13 +893,6 @@ declare_ovr_snprint(dev_loss, print_dev_loss) declare_hw_handler(dev_loss, set_dev_loss) declare_hw_snprint(dev_loss, print_dev_loss) -declare_def_handler(eh_deadline, set_undef_off_zero) -declare_def_snprint(eh_deadline, print_undef_off_zero) -declare_ovr_handler(eh_deadline, set_undef_off_zero) -declare_ovr_snprint(eh_deadline, print_undef_off_zero) -declare_hw_handler(eh_deadline, set_undef_off_zero) -declare_hw_snprint(eh_deadline, print_undef_off_zero) - static int set_pgpolicy(vector strvec, void *ptr) { @@ -1526,7 +1501,7 @@ ble_ ## option ## _handler (struct config *conf, vector strvec) \ if (!conf->option) \ return 1; \ \ - buff = set_regex_value(strvec); \ + buff = set_value(strvec); \ if (!buff) \ return 1; \ \ @@ -1542,7 +1517,7 @@ ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \ if (!conf->option) \ return 1; \ \ - buff = set_regex_value(strvec); \ + buff = set_value(strvec); \ if (!buff) \ return 1; \ \ @@ -1645,16 +1620,16 @@ device_handler(struct config *conf, vector strvec) return 0; } -declare_hw_handler(vendor, set_regex) +declare_hw_handler(vendor, set_str) declare_hw_snprint(vendor, print_str) -declare_hw_handler(product, set_regex) +declare_hw_handler(product, set_str) declare_hw_snprint(product, print_str) -declare_hw_handler(revision, set_regex) +declare_hw_handler(revision, set_str) declare_hw_snprint(revision, print_str) -declare_hw_handler(bl_product, set_regex) +declare_hw_handler(bl_product, set_str) declare_hw_snprint(bl_product, print_str) declare_hw_handler(hwhandler, set_str) @@ -1783,7 +1758,6 @@ init_keywords(vector keywords) install_keyword("gid", &def_gid_handler, &snprint_def_gid); install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail); install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss); - install_keyword("eh_deadline", &def_eh_deadline_handler, &snprint_def_eh_deadline); install_keyword("bindings_file", &def_bindings_file_handler, &snprint_def_bindings_file); install_keyword("wwids_file", &def_wwids_file_handler, &snprint_def_wwids_file); install_keyword("prkeys_file", &def_prkeys_file_handler, &snprint_def_prkeys_file); @@ -1893,7 +1867,6 @@ init_keywords(vector keywords) install_keyword("flush_on_last_del", &hw_flush_on_last_del_handler, &snprint_hw_flush_on_last_del); install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail); install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss); - install_keyword("eh_deadline", &hw_eh_deadline_handler, &snprint_hw_eh_deadline); install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names); install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler); install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio); @@ -1934,7 +1907,6 @@ init_keywords(vector keywords) install_keyword("flush_on_last_del", &ovr_flush_on_last_del_handler, &snprint_ovr_flush_on_last_del); install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail); install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss); - install_keyword("eh_deadline", &ovr_eh_deadline_handler, &snprint_ovr_eh_deadline); install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names); install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler); install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio); diff --git a/libmultipath/dict.h b/libmultipath/dict.h index a917e1c..a40ac66 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -13,7 +13,7 @@ int print_rr_weight(char *buff, int len, long v); int print_pgfailback(char *buff, int len, long v); int print_pgpolicy(char *buff, int len, long v); int print_no_path_retry(char *buff, int len, long v); -int print_undef_off_zero(char *buff, int len, long v); +int print_fast_io_fail(char *buff, int len, long v); int print_dev_loss(char *buff, int len, unsigned long v); int print_reservation_key(char * buff, int len, struct be64 key, uint8_t flags, int source); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index a328aaf..ee3290c 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -577,49 +577,13 @@ sysfs_get_asymmetric_access_state(struct path *pp, char *buff, int buflen) return !!preferred; } -static int -sysfs_set_eh_deadline(struct multipath *mpp, struct path *pp) -{ - struct udev_device *hostdev; - char host_name[HOST_NAME_LEN], value[16]; - int ret; - - if (mpp->eh_deadline == EH_DEADLINE_UNSET) - return 0; - - sprintf(host_name, "host%d", pp->sg_id.host_no); - hostdev = udev_device_new_from_subsystem_sysname(udev, - "scsi_host", host_name); - if (!hostdev) - return 1; - - if (mpp->eh_deadline == EH_DEADLINE_OFF) - sprintf(value, "off"); - else if (mpp->eh_deadline == EH_DEADLINE_ZERO) - sprintf(value, "0"); - else - snprintf(value, 16, "%u", mpp->eh_deadline); - - ret = sysfs_attr_set_value(hostdev, "eh_deadline", - value, strlen(value)); - /* - * not all scsi drivers support setting eh_deadline, so failing - * is totally reasonable - */ - if (ret <= 0) - condlog(4, "%s: failed to set eh_deadline to %s, error %d", udev_device_get_sysname(hostdev), value, -ret); - - udev_device_unref(hostdev); - return (ret <= 0); -} - static void sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) { struct udev_device *rport_dev = NULL; char value[16], *eptr; char rport_id[32]; - unsigned int tmo; + unsigned long long tmo = 0; int ret; sprintf(rport_id, "rport-%d:%d-%d", @@ -643,8 +607,8 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) "error %d", rport_id, -ret); goto out; } - tmo = strtoul(value, &eptr, 0); - if (value == eptr) { + tmo = strtoull(value, &eptr, 0); + if (value == eptr || tmo == ULLONG_MAX) { condlog(0, "%s: Cannot parse dev_loss_tmo " "attribute '%s'", rport_id, value); goto out; @@ -823,24 +787,16 @@ sysfs_set_scsi_tmo (struct multipath *mpp, unsigned int checkint) mpp->alias, mpp->fast_io_fail); mpp->fast_io_fail = MP_FAST_IO_FAIL_OFF; } - if (!mpp->dev_loss && mpp->fast_io_fail == MP_FAST_IO_FAIL_UNSET && - mpp->eh_deadline == EH_DEADLINE_UNSET) + if (!mpp->dev_loss && mpp->fast_io_fail == MP_FAST_IO_FAIL_UNSET) return 0; vector_foreach_slot(mpp->paths, pp, i) { - if (pp->bus != SYSFS_BUS_SCSI) - continue; - - if (mpp->dev_loss || - mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET) { - if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP) - sysfs_set_rport_tmo(mpp, pp); - else if (pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI) - sysfs_set_session_tmo(mpp, pp); - else if (pp->sg_id.proto_id == SCSI_PROTOCOL_SAS) - sysfs_set_nexus_loss_tmo(mpp, pp); - } - sysfs_set_eh_deadline(mpp, pp); + if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP) + sysfs_set_rport_tmo(mpp, pp); + if (pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI) + sysfs_set_session_tmo(mpp, pp); + if (pp->sg_id.proto_id == SCSI_PROTOCOL_SAS) + sysfs_set_nexus_loss_tmo(mpp, pp); } return 0; } @@ -931,12 +887,6 @@ detect_alua(struct path * pp) int tpgs; unsigned int timeout; - - if (pp->bus != SYSFS_BUS_SCSI) { - pp->tpgs = TPGS_NONE; - return; - } - if (sysfs_get_timeout(pp, &timeout) <= 0) timeout = DEF_TIMEOUT; @@ -1036,7 +986,7 @@ parse_vpd_pg80(const unsigned char *in, char *out, size_t out_len) } if (len >= out_len) { - condlog(2, "vpd pg80 overflow, %zu/%zu bytes required", + condlog(2, "vpd pg80 overflow, %lu/%lu bytes required", len + 1, out_len); len = out_len - 1; } @@ -1137,7 +1087,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, len = sprintf(out, "%d", vpd_type); if (2 * vpd_len >= out_len - len) { - condlog(1, "%s: WWID overflow, type %d, %zu/%zu bytes required", + condlog(1, "%s: WWID overflow, type %d, %lu/%lu bytes required", __func__, vpd_type, 2 * vpd_len + len + 1, out_len); vpd_len = (out_len - len - 1) / 2; @@ -1146,7 +1096,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, len += sprintf(out + len, "%02x", vpd[i]); } else if (vpd_type == 0x8 && vpd_len < 4) { - condlog(1, "%s: VPD length %zu too small for designator type 8", + condlog(1, "%s: VPD length %lu too small for designator type 8", __func__, vpd_len); return -EINVAL; } else if (vpd_type == 0x8) { @@ -1162,7 +1112,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, while (len > 2 && vpd[len - 2] == '\0') --len; if (len > out_len - 1) { - condlog(1, "%s: WWID overflow, type 8/%c, %zu/%zu bytes required", + condlog(1, "%s: WWID overflow, type 8/%c, %lu/%lu bytes required", __func__, out[0], len + 1, out_len); len = out_len - 1; } @@ -1186,7 +1136,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, while ((p = memchr(vpd, ' ', vpd_len))) { p_len = p - vpd; if (len + p_len > out_len - 1) { - condlog(1, "%s: WWID overflow, type 1, %zu/%zu bytes required", + condlog(1, "%s: WWID overflow, type 1, %lu/%lu bytes required", __func__, len + p_len, out_len); p_len = out_len - len - 1; } @@ -1212,7 +1162,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, p_len = vpd_len; if (p_len > 0 && len < out_len - 1) { if (len + p_len > out_len - 1) { - condlog(1, "%s: WWID overflow, type 1, %zu/%zu bytes required", + condlog(1, "%s: WWID overflow, type 1, %lu/%lu bytes required", __func__, len + p_len + 1, out_len); p_len = out_len - len - 1; } @@ -1236,14 +1186,14 @@ parse_vpd_c0_hp3par(const unsigned char *in, size_t in_len, memset(out, 0x0, out_len); if (in_len <= 4 || (in[4] > 3 && in_len < 44)) { - condlog(3, "HP/3PAR vendor specific VPD page length too short: %zu", in_len); + condlog(3, "HP/3PAR vendor specific VPD page length too short: %lu", in_len); return -EINVAL; } if (in[4] <= 3) /* revision must be > 3 to have Vomlume Name */ return -ENODATA; len = get_unaligned_be32(&in[40]); if (len > out_len || len + 44 > in_len) { - condlog(3, "HP/3PAR vendor specific Volume name too long: %zu", + condlog(3, "HP/3PAR vendor specific Volume name too long: %lu", len); return -EINVAL; } @@ -1283,10 +1233,11 @@ get_vpd_sysfs (struct udev_device *parent, int pg, char * str, int maxlen) return len; } -static int -fetch_vpd_page(int fd, int pg, unsigned char *buff) +int +get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen) { - int buff_len; + int len, buff_len; + unsigned char buff[4096]; memset(buff, 0x0, 4096); if (sgio_get_vpd(buff, 4096, fd, pg) < 0) { @@ -1307,43 +1258,6 @@ fetch_vpd_page(int fd, int pg, unsigned char *buff) condlog(3, "vpd pg%02x page truncated", pg); buff_len = 4096; } - return buff_len; -} - -/* heavily based on sg_inq.c from sg3_utils */ -bool -is_vpd_page_supported(int fd, int pg) -{ - int i, len, buff_len; - unsigned char buff[4096]; - - buff_len = fetch_vpd_page(fd, 0x00, buff); - if (buff_len < 0) - return false; - if (buff_len < 4) { - condlog(3, "VPD page 00h too short"); - return false; - } - - len = buff[3] + 4; - if (len > buff_len) - condlog(3, "vpd page 00h trucated, expected %d, have %d", - len, buff_len); - for (i = 4; i < len; ++i) - if (buff[i] == pg) - return true; - return false; -} - -int -get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen) -{ - int len, buff_len; - unsigned char buff[4096]; - - buff_len = fetch_vpd_page(fd, pg, buff); - if (buff_len < 0) - return buff_len; if (pg == 0x80) len = parse_vpd_pg80(buff, str, maxlen); else if (pg == 0x83) diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index d3193da..6444887 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -56,7 +56,6 @@ int sysfs_get_asymmetric_access_state(struct path *pp, char *buff, int buflen); int get_uid(struct path * pp, int path_state, struct udev_device *udev, int allow_fallback); -bool is_vpd_page_supported(int fd, int pg); /* * discovery bitmask diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c index d680bdf..d1fcfdb 100644 --- a/libmultipath/hwtable.c +++ b/libmultipath/hwtable.c @@ -428,22 +428,6 @@ static struct hwentry default_hw[] = { .pgpolicy = MULTIBUS, .no_path_retry = 10, }, - { - /* - * ETERNUS AB/HB - * Maintainer: NetApp RDAC team - */ - .vendor = "FUJITSU", - .product = "ETERNUS_AHB", - .bl_product = "Universal Xport", - .pgpolicy = GROUP_BY_PRIO, - .checker_name = RDAC, - .features = "2 pg_init_retries 50", - .hwhandler = "1 rdac", - .prio_name = PRIO_RDAC, - .pgfailback = -FAILBACK_IMMEDIATE, - .no_path_retry = 30, - }, /* * Hitachi Vantara * diff --git a/libmultipath/nvme/argconfig.h b/libmultipath/nvme/argconfig.h index bfd10ef..adb192b 100644 --- a/libmultipath/nvme/argconfig.h +++ b/libmultipath/nvme/argconfig.h @@ -76,7 +76,7 @@ struct argconfig_commandline_options { extern "C" { #endif -typedef void argconfig_help_func(void); +typedef void argconfig_help_func(); void argconfig_append_usage(const char *str); void argconfig_print_help(const char *program_desc, const struct argconfig_commandline_options *options); diff --git a/libmultipath/parser.c b/libmultipath/parser.c index 48b54e8..d478b17 100644 --- a/libmultipath/parser.c +++ b/libmultipath/parser.c @@ -300,10 +300,8 @@ alloc_strvec(char *string) (isspace((int) *cp) || !isascii((int) *cp))) && *cp != '\0') cp++; - if (*cp == '\0' || - (!in_string && (*cp == '!' || *cp == '#'))) { + if (*cp == '\0' || *cp == '!' || *cp == '#') return strvec; - } } out: vector_free(strvec); @@ -384,19 +382,6 @@ oom: return NULL; } -void * -set_regex_value(vector strvec) -{ - char *buff = set_value(strvec); - - if (buff && strcmp("*", buff) == 0) { - condlog(0, "Invalid regular expression \"*\" in multipath.conf. Using \".*\""); - FREE(buff); - return strdup(".*"); - } - return buff; -} - /* non-recursive configuration stream handler */ static int kw_level = 0; @@ -544,7 +529,7 @@ process_stream(struct config *conf, FILE *stream, vector keywords, char *file) if (!strcmp(str, EOB)) { if (kw_level > 0) { free_strvec(strvec); - goto out; + break; } condlog(0, "unmatched '%s' at line %d of %s", EOB, line_nr, file); @@ -583,8 +568,7 @@ process_stream(struct config *conf, FILE *stream, vector keywords, char *file) free_strvec(strvec); } - if (kw_level == 1) - condlog(1, "missing '%s' at end of %s", EOB, file); + out: FREE(buf); free_uniques(uniques); diff --git a/libmultipath/parser.h b/libmultipath/parser.h index b791705..62906e9 100644 --- a/libmultipath/parser.h +++ b/libmultipath/parser.h @@ -77,7 +77,6 @@ extern void dump_keywords(vector keydump, int level); extern void free_keywords(vector keywords); extern vector alloc_strvec(char *string); extern void *set_value(vector strvec); -extern void *set_regex_value(vector strvec); extern int process_file(struct config *conf, char *conf_file); extern struct keyword * find_keyword(vector keywords, vector v, char * name); int snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw, diff --git a/libmultipath/print.c b/libmultipath/print.c index 298b376..b944ef3 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -1958,25 +1958,25 @@ char *snprint_config(const struct config *conf, int *len, } c = reply + snprint_defaults(conf, reply, maxlen); - if (c == reply + maxlen) + if ((c - reply) == maxlen) continue; c += snprint_blacklist(conf, c, reply + maxlen - c); - if (c == reply + maxlen) + if ((c - reply) == maxlen) continue; c += snprint_blacklist_except(conf, c, reply + maxlen - c); - if (c == reply + maxlen) + if ((c - reply) == maxlen) continue; c += snprint_hwtable(conf, c, reply + maxlen - c, hwtable ? hwtable : conf->hwtable); - if (c == reply + maxlen) + if ((c - reply) == maxlen) continue; c += snprint_overrides(conf, c, reply + maxlen - c, conf->overrides); - if (c == reply + maxlen) + if ((c - reply) == maxlen) continue; if (VECTOR_SIZE(conf->mptable) > 0 || @@ -1984,7 +1984,7 @@ char *snprint_config(const struct config *conf, int *len, c += snprint_mptable(conf, c, reply + maxlen - c, mpvec); - if (c < reply + maxlen) { + if ((c - reply) < maxlen) { if (len) *len = c - reply; return reply; diff --git a/libmultipath/prioritizers/alua_spc3.h b/libmultipath/prioritizers/alua_spc3.h index 7ba2cf4..18b495e 100644 --- a/libmultipath/prioritizers/alua_spc3.h +++ b/libmultipath/prioritizers/alua_spc3.h @@ -284,7 +284,7 @@ struct rtpg_data { #define RTPG_FOR_EACH_PORT_GROUP(p, g) \ for( \ g = &(p->data[0]); \ - ((char *) g) < ((char *) p) + get_unaligned_be32(p->length); \ + (((char *) g) - ((char *) p)) < get_unaligned_be32(p->length); \ g = (struct rtpg_tpg_dscr *) ( \ ((char *) g) + \ sizeof(struct rtpg_tpg_dscr) + \ diff --git a/libmultipath/prioritizers/ana.c b/libmultipath/prioritizers/ana.c index e139360..b5c7873 100644 --- a/libmultipath/prioritizers/ana.c +++ b/libmultipath/prioritizers/ana.c @@ -24,7 +24,6 @@ #include "prio.h" #include "util.h" #include "structs.h" -#include "sysfs.h" enum { ANA_ERR_GETCTRL_FAILED = 1, @@ -37,7 +36,6 @@ enum { ANA_ERR_GETNS_FAILED, ANA_ERR_NO_MEMORY, ANA_ERR_NO_INFORMATION, - ANA_ERR_INVALID_STATE, }; static const char *ana_errmsg[] = { @@ -51,7 +49,6 @@ static const char *ana_errmsg[] = { [ANA_ERR_GETNS_FAILED] = "couldn't get namespace info", [ANA_ERR_NO_MEMORY] = "out of memory", [ANA_ERR_NO_INFORMATION] = "invalid fd", - [ANA_ERR_INVALID_STATE] = "invalid state", }; static const char *anas_string[] = { @@ -110,27 +107,6 @@ static int get_ana_state(__u32 nsid, __u32 anagrpid, void *ana_log, return -ANA_ERR_GETANAS_NOTFOUND; } -static int get_ana_info_sysfs(struct path *pp) -{ - char state[32]; - - if (!pp->udev || sysfs_attr_get_value(pp->udev, "ana_state", state, - sizeof(state)) <= 0) - return -ANA_ERR_NO_INFORMATION; - - if (strcmp(state, "optimized") == 0) - return NVME_ANA_OPTIMIZED; - if (strcmp(state, "non-optimized") == 0) - return NVME_ANA_NONOPTIMIZED; - if (strcmp(state, "inaccessible") == 0) - return NVME_ANA_INACCESSIBLE; - if (strcmp(state, "persistent-loss") == 0) - return NVME_ANA_PERSISTENT_LOSS; - if (strcmp(state, "change") == 0) - return NVME_ANA_CHANGE; - return -ANA_ERR_INVALID_STATE; -} - static int get_ana_info(struct path * pp) { int rc; @@ -234,11 +210,8 @@ int getprio(struct path *pp, __attribute__((unused)) char *args, if (pp->fd < 0) rc = -ANA_ERR_NO_INFORMATION; - else { - rc = get_ana_info_sysfs(pp); - if (rc < 0) - rc = get_ana_info(pp); - } + else + rc = get_ana_info(pp); switch (rc) { case NVME_ANA_OPTIMIZED: diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 1150cfe..897e48c 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -496,15 +496,13 @@ check_rdac(struct path * pp) { int len; char buff[44]; - const char *checker_name = NULL; + const char *checker_name; if (pp->bus != SYSFS_BUS_SCSI) return 0; - /* Avoid checking 0xc9 if this is likely not an RDAC array */ - if (!__do_set_from_hwe(checker_name, pp, checker_name) && - !is_vpd_page_supported(pp->fd, 0xC9)) - return 0; - if (checker_name && strcmp(checker_name, RDAC)) + /* Avoid ioctl if this is likely not an RDAC array */ + if (__do_set_from_hwe(checker_name, pp, checker_name) && + strcmp(checker_name, RDAC)) return 0; len = get_vpd_sgio(pp->fd, 0xC9, 0, buff, 44); if (len <= 0) @@ -523,9 +521,7 @@ int select_checker(struct config *conf, struct path *pp) if (check_rdac(pp)) { ckr_name = RDAC; goto out; - } - path_get_tpgs(pp); - if (pp->tpgs != TPGS_NONE && pp->tpgs != TPGS_UNDEF) { + } else if (path_get_tpgs(pp) != TPGS_NONE) { ckr_name = TUR; goto out; } @@ -755,7 +751,7 @@ int select_fast_io_fail(struct config *conf, struct multipath *mp) mp_set_conf(fast_io_fail); mp_set_default(fast_io_fail, DEFAULT_FAST_IO_FAIL); out: - print_undef_off_zero(buff, 12, mp->fast_io_fail); + print_fast_io_fail(buff, 12, mp->fast_io_fail); condlog(3, "%s: fast_io_fail_tmo = %s %s", mp->alias, buff, origin); return 0; } @@ -776,23 +772,6 @@ out: return 0; } -int select_eh_deadline(struct config *conf, struct multipath *mp) -{ - const char *origin; - char buff[12]; - - mp_set_ovr(eh_deadline); - mp_set_hwe(eh_deadline); - mp_set_conf(eh_deadline); - mp->eh_deadline = EH_DEADLINE_UNSET; - /* not changing sysfs in default cause, so don't print anything */ - return 0; -out: - print_undef_off_zero(buff, 12, mp->eh_deadline); - condlog(3, "%s: eh_deadline = %s %s", mp->alias, buff, origin); - return 0; -} - int select_flush_on_last_del(struct config *conf, struct multipath *mp) { const char *origin; diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h index a68bacf..3d6edd8 100644 --- a/libmultipath/propsel.h +++ b/libmultipath/propsel.h @@ -17,7 +17,6 @@ int select_uid(struct config *conf, struct multipath *mp); int select_gid(struct config *conf, struct multipath *mp); int select_fast_io_fail(struct config *conf, struct multipath *mp); int select_dev_loss(struct config *conf, struct multipath *mp); -int select_eh_deadline(struct config *conf, struct multipath *mp); int select_reservation_key(struct config *conf, struct multipath *mp); int select_retain_hwhandler (struct config *conf, struct multipath * mp); int select_detect_prio(struct config *conf, struct path * pp); diff --git a/libmultipath/structs.c b/libmultipath/structs.c index dda9884..2dd378c 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -500,26 +500,6 @@ int count_active_paths(const struct multipath *mpp) return count; } -int count_active_pending_paths(const struct multipath *mpp) -{ - struct pathgroup *pgp; - struct path *pp; - int count = 0; - int i, j; - - if (!mpp->pg) - return 0; - - vector_foreach_slot (mpp->pg, pgp, i) { - vector_foreach_slot (pgp->paths, pp, j) { - if (pp->state == PATH_UP || pp->state == PATH_GHOST || - pp->state == PATH_PENDING) - count++; - } - } - return count; -} - int pathcmp(const struct pathgroup *pgp, const struct pathgroup *cpgp) { int i, j; diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 65542de..9bd39eb 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -229,29 +229,6 @@ enum vpd_vendor_ids { VPD_VP_ARRAY_SIZE, /* This must remain the last entry */ }; -/* - * Multipath treats 0 as undefined for optional config parameters. - * Use this for cases where 0 is a valid option for systems multipath - * is communicating with - */ -enum undefined_off_zero { - UOZ_UNDEF = 0, - UOZ_OFF = -1, - UOZ_ZERO = -2, -}; - -enum fast_io_fail_states { - MP_FAST_IO_FAIL_UNSET = UOZ_UNDEF, - MP_FAST_IO_FAIL_OFF = UOZ_OFF, - MP_FAST_IO_FAIL_ZERO = UOZ_ZERO, -}; - -enum eh_deadline_states { - EH_DEADLINE_UNSET = UOZ_UNDEF, - EH_DEADLINE_OFF = UOZ_OFF, - EH_DEADLINE_ZERO = UOZ_ZERO, -}; - struct vpd_vendor_page { int pg; const char *name; @@ -372,7 +349,6 @@ struct multipath { int ghost_delay; int ghost_delay_tick; unsigned int dev_loss; - int eh_deadline; uid_t uid; gid_t gid; mode_t mode; @@ -489,7 +465,6 @@ struct path * first_path (const struct multipath *mpp); int pathcountgr (const struct pathgroup *, int); int pathcount (const struct multipath *, int); int count_active_paths(const struct multipath *); -int count_active_pending_paths(const struct multipath *); int pathcmp (const struct pathgroup *, const struct pathgroup *); int add_feature (char **, const char *); int remove_feature (char **, const char *); diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 8137ea2..3dbbaa0 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -196,47 +196,43 @@ extract_hwe_from_path(struct multipath * mpp) int update_multipath_table (struct multipath *mpp, vector pathvec, int is_daemon) { - int r = DMP_ERR; char params[PARAMS_SIZE] = {0}; if (!mpp) - return r; + return 1; - r = dm_get_map(mpp->alias, &mpp->size, params); - if (r != DMP_OK) { - condlog(3, "%s: %s", mpp->alias, (r == DMP_ERR)? "error getting table" : "map not present"); - return r; + if (dm_get_map(mpp->alias, &mpp->size, params)) { + condlog(3, "%s: cannot get map", mpp->alias); + return 1; } if (disassemble_map(pathvec, params, mpp, is_daemon)) { condlog(3, "%s: cannot disassemble map", mpp->alias); - return DMP_ERR; + return 1; } - return DMP_OK; + return 0; } int update_multipath_status (struct multipath *mpp) { - int r = DMP_ERR; char status[PARAMS_SIZE] = {0}; if (!mpp) - return r; + return 1; - r = dm_get_status(mpp->alias, status); - if (r != DMP_OK) { - condlog(3, "%s: %s", mpp->alias, (r == DMP_ERR)? "error getting status" : "map not present"); - return r; + if (dm_get_status(mpp->alias, status)) { + condlog(3, "%s: cannot get status", mpp->alias); + return 1; } if (disassemble_status(status, mpp)) { condlog(3, "%s: cannot disassemble status", mpp->alias); - return DMP_ERR; + return 1; } - return DMP_OK; + return 0; } void sync_paths(struct multipath *mpp, vector pathvec) @@ -268,10 +264,10 @@ int update_multipath_strings(struct multipath *mpp, vector pathvec, int is_daemon) { struct pathgroup *pgp; - int i, r = DMP_ERR; + int i; if (!mpp) - return r; + return 1; update_mpp_paths(mpp, pathvec); condlog(4, "%s: %s", mpp->alias, __FUNCTION__); @@ -280,21 +276,18 @@ update_multipath_strings(struct multipath *mpp, vector pathvec, int is_daemon) free_pgvec(mpp->pg, KEEP_PATHS); mpp->pg = NULL; - r = update_multipath_table(mpp, pathvec, is_daemon); - if (r != DMP_OK) - return r; - + if (update_multipath_table(mpp, pathvec, is_daemon)) + return 1; sync_paths(mpp, pathvec); - r = update_multipath_status(mpp); - if (r != DMP_OK) - return r; + if (update_multipath_status(mpp)) + return 1; vector_foreach_slot(mpp->pg, pgp, i) if (pgp->paths) path_group_prio_update(pgp); - return DMP_OK; + return 0; } static void enter_recovery_mode(struct multipath *mpp) @@ -343,7 +336,7 @@ static void leave_recovery_mode(struct multipath *mpp) void __set_no_path_retry(struct multipath *mpp, bool check_features) { - bool is_queueing = false; /* assign a value to make gcc happy */ + bool is_queueing; check_features = check_features && mpp->features != NULL; if (check_features) diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c index fab6fc8..28a2150 100644 --- a/libmultipath/wwids.c +++ b/libmultipath/wwids.c @@ -454,47 +454,3 @@ int op ## _wwid(const char *wwid) \ declare_failed_wwid_op(is_failed, false) declare_failed_wwid_op(mark_failed, true) declare_failed_wwid_op(unmark_failed, true) - -int remember_cmdline_wwid(void) -{ - FILE *f = NULL; - char buf[LINE_MAX], *next, *ptr; - int ret = 0; - - f = fopen("/proc/cmdline", "re"); - if (!f) { - condlog(0, "can't open /proc/cmdline : %s", strerror(errno)); - return -1; - } - - if (!fgets(buf, sizeof(buf), f)) { - if (ferror(f)) - condlog(0, "read of /proc/cmdline failed : %s", - strerror(errno)); - else - condlog(0, "couldn't read /proc/cmdline"); - fclose(f); - return -1; - } - fclose(f); - next = buf; - while((ptr = strstr(next, "mpath.wwid="))) { - ptr += 11; - next = strpbrk(ptr, " \t\n"); - if (next) { - *next = '\0'; - next++; - } - if (strlen(ptr)) { - if (remember_wwid(ptr) != 0) - ret = -1; - } - else { - condlog(0, "empty mpath.wwid kernel command line option"); - ret = -1; - } - if (!next) - break; - } - return ret; -} diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h index e32a0b0..0c6ee54 100644 --- a/libmultipath/wwids.h +++ b/libmultipath/wwids.h @@ -17,7 +17,6 @@ int remember_wwid(char *wwid); int check_wwids_file(char *wwid, int write_wwid); int remove_wwid(char *wwid); int replace_wwids(vector mp); -int remember_cmdline_wwid(void); enum { WWID_IS_NOT_FAILED = 0, diff --git a/multipath/11-dm-mpath.rules b/multipath/11-dm-mpath.rules index cd522e8..07320a1 100644 --- a/multipath/11-dm-mpath.rules +++ b/multipath/11-dm-mpath.rules @@ -75,7 +75,7 @@ ENV{MPATH_DEVICE_READY}=="0", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\ ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\ - ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" + ENV{DM_ACTIVATION}="1" # The code to check multipath state ends here. We need to set # properties and symlinks regardless whether the map is usable or diff --git a/multipath/Makefile b/multipath/Makefile index e720c7f..0828a8f 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -18,29 +18,24 @@ $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS) $(GZIP) $(EXEC).8 > $(EXEC).8.gz $(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz - $(GZIP) mpathconf.8 > mpathconf.8.gz install: $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ - $(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/ $(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) $(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) - $(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules + $(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules $(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir) $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir) $(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir) $(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir) - $(INSTALL_PROGRAM) -m 644 mpathconf.8.gz $(DESTDIR)$(man8dir) uninstall: $(RM) $(DESTDIR)$(bindir)/$(EXEC) $(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules - $(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules - $(RM) $(DESTDIR)$(bindir)/mpathconf + $(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules $(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz $(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz - $(RM) $(DESTDIR)$(man8dir)/mpathconf.8.gz clean: dep_clean $(RM) core *.o $(EXEC) *.gz diff --git a/multipath/main.c b/multipath/main.c index 607cada..cf9d2a2 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -138,7 +138,7 @@ usage (char * progname) fprintf (stderr, " %s [-v level] [-R retries] -F\n", progname); fprintf (stderr, " %s [-v level] [-l|-ll] [device]\n", progname); fprintf (stderr, " %s [-v level] [-a|-w] device\n", progname); - fprintf (stderr, " %s [-v level] [-A|-W]\n", progname); + fprintf (stderr, " %s [-v level] -W\n", progname); fprintf (stderr, " %s [-v level] [-i] [-c|-C] device\n", progname); fprintf (stderr, " %s [-v level] [-i] [-u|-U]\n", progname); fprintf (stderr, " %s [-h|-t|-T]\n", progname); @@ -151,8 +151,6 @@ usage (char * progname) " -f flush a multipath device map\n" " -F flush all multipath device maps\n" " -a add a device wwid to the wwids file\n" - " -A add devices from kernel command line mpath.wwids\n" - " parameters to wwids file\n" " -c check if a device should be a path in a multipath device\n" " -C check if a multipath device has usable paths\n" " -q allow queue_if_no_path when multipathd is not running\n" @@ -825,26 +823,9 @@ int delegate_to_multipathd(enum mpath_cmds cmd, *p = '\0'; n = sizeof(command); - if (conf->skip_delegate) - return NOT_DELEGATED; - if (cmd == CMD_CREATE && conf->force_reload == FORCE_RELOAD_YES) { p += snprintf(p, n, "reconfigure"); } - else if (cmd == CMD_FLUSH_ONE && dev && dev_type == DEV_DEVMAP) { - p += snprintf(p, n, "del map %s", dev); - /* multipathd doesn't try as hard, to avoid potentially - * hanging. If it fails, retry with the regular multipath - * command */ - r = NOT_DELEGATED; - } - else if (cmd == CMD_FLUSH_ALL) { - p += snprintf(p, n, "del maps"); - /* multipathd doesn't try as hard, to avoid potentially - * hanging. If it fails, retry with the regular multipath - * command */ - r = NOT_DELEGATED; - } /* Add other translations here */ if (strlen(command) == 0) @@ -869,12 +850,9 @@ int delegate_to_multipathd(enum mpath_cmds cmd, goto out; } - if (reply != NULL && *reply != '\0') { - if (strcmp(reply, "fail\n")) - r = DELEGATE_OK; - if (r != NOT_DELEGATED && strcmp(reply, "ok\n")) - printf("%s", reply); - } + if (reply != NULL && *reply != '\0' && strcmp(reply, "ok\n")) + printf("%s", reply); + r = DELEGATE_OK; out: FREE(reply); @@ -929,7 +907,7 @@ main (int argc, char *argv[]) multipath_conf = conf; conf->retrigger_tries = 0; conf->force_sync = 1; - while ((arg = getopt(argc, argv, ":aAdDcChl::FfM:v:p:b:BrR:itTquUwW")) != EOF ) { + while ((arg = getopt(argc, argv, ":adcChl::FfM:v:p:b:BrR:itTquUwW")) != EOF ) { switch(arg) { case 1: printf("optarg : %s\n",optarg); break; @@ -961,14 +939,11 @@ main (int argc, char *argv[]) if (cmd == CMD_CREATE) cmd = CMD_DRY_RUN; break; - case 'D': - conf->skip_delegate = 1; - break; case 'f': - cmd = CMD_FLUSH_ONE; + conf->remove = FLUSH_ONE; break; case 'F': - cmd = CMD_FLUSH_ALL; + conf->remove = FLUSH_ALL; break; case 'l': if (optarg && !strncmp(optarg, "l", 1)) @@ -1002,10 +977,6 @@ main (int argc, char *argv[]) case 'T': cmd = CMD_DUMP_CONFIG; break; - case 'A': - if (remember_cmdline_wwid() != 0) - exit(RTVL_FAIL); - exit(RTVL_OK); case 'h': usage(argv[0]); exit(RTVL_OK); @@ -1107,10 +1078,6 @@ main (int argc, char *argv[]) condlog(0, "the -w option requires a device"); goto out; } - if (cmd == CMD_FLUSH_ONE && dev_type != DEV_DEVMAP) { - condlog(0, "the -f option requires a map name to remove"); - goto out; - } switch(delegate_to_multipathd(cmd, dev, dev_type, conf)) { case DELEGATE_OK: @@ -1144,13 +1111,17 @@ main (int argc, char *argv[]) } if (retries < 0) retries = conf->remove_retries; - if (cmd == CMD_FLUSH_ONE) { - r = dm_suspend_and_flush_map(dev, retries) ? - RTVL_FAIL : RTVL_OK; + if (conf->remove == FLUSH_ONE) { + if (dev_type == DEV_DEVMAP) { + r = dm_suspend_and_flush_map(dev, retries) ? + RTVL_FAIL : RTVL_OK; + } else + condlog(0, "must provide a map name to remove"); + goto out; } - else if (cmd == CMD_FLUSH_ALL) { - r = dm_flush_maps(1, retries) ? RTVL_FAIL : RTVL_OK; + else if (conf->remove == FLUSH_ALL) { + r = dm_flush_maps(retries) ? RTVL_FAIL : RTVL_OK; goto out; } while ((r = configure(conf, cmd, dev_type, dev)) == RTVL_RETRY) diff --git a/multipath/mpathconf b/multipath/mpathconf deleted file mode 100644 index f34003c..0000000 --- a/multipath/mpathconf +++ /dev/null @@ -1,555 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This file is part of the device-mapper-multipath package. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# -# Simple editting of /etc/multipath.conf -# This program was largely ripped off from lvmconf -# - -unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST - -DEFAULT_CONFIG="# device-mapper-multipath configuration file - -# For a complete list of the default configuration values, run either: -# # multipath -t -# or -# # multipathd show config - -# For a list of configuration options with descriptions, see the -# multipath.conf man page. - -defaults { - user_friendly_names yes - find_multipaths yes - enable_foreign \"^$\" -} - -blacklist_exceptions { - property \"(SCSI_IDENT_|ID_WWN)\" -}" - -CONFIGFILE="/etc/multipath.conf" -OUTPUTFILE="/etc/multipath.conf" -MULTIPATHDIR="/etc/multipath" -TMPFILE="/etc/multipath/.multipath.conf.tmp" -WWIDS=0 - -function usage -{ - echo "usage: $0 " - echo "" - echo "Commands:" - echo "Enable: --enable " - echo "Disable: --disable" - echo "Only allow certain wwids (instead of enable): --allow " - echo "Set user_friendly_names (Default y): --user_friendly_names " - echo "Set find_multipaths (Default y): --find_multipaths " - echo "Set default property blacklist (Default y): --property_blacklist " - echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign " - echo "Load the dm-multipath modules on enable (Default y): --with_module " - echo "start/stop/reload multipathd (Default n): --with_multipathd " - echo "select output file (Default /etc/multipath.conf): --outfile " - echo "" -} - -function add_wwid -{ - INDEX=0 - while [ "$INDEX" -lt "$WWIDS" ] ; do - if [ "$1" = "${WWID_LIST[$INDEX]}" ] ; then - return - fi - ((INDEX++)) - done - WWID_LIST[$WWIDS]="$1" - ((WWIDS++)) -} - -function get_dm_deps -{ - shift 3 - while [ -n "$1" -a -n "$2" ]; do - MAJOR=$(echo $1 | tr -d '(,') - MINOR=$(echo $2 | tr -d ')') - UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null` - if [ -n "$UUID" ] ; then - set_dm_wwid $UUID - fi - shift 2 - done -} - -function set_dm_wwid -{ - if [[ "$1" =~ ^part[[:digit:]]+-mpath- ]] ; then - add_wwid "${1##part*-mpath-}" - elif [[ "$1" =~ ^mpath- ]] ; then - add_wwid "${1##mpath-}" - else - get_dm_deps `dmsetup deps -u $1` - fi -} - -function set_wwid -{ - UUID="" - if [[ "$1" =~ ^[[:digit:]]+:[[:digit:]]+$ ]] ; then - MAJOR=${1%%:*} - MINOR=${1##*:} - UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null` - else - UUID=`dmsetup info -c --noheadings -o uuid $1 2> /dev/null` - fi - if [ -n "$UUID" ] ; then - set_dm_wwid $UUID - else - add_wwid "$1" - fi -} - -function parse_args -{ - while [ -n "$1" ]; do - case $1 in - --enable) - ENABLE=1 - shift - ;; - --disable) - ENABLE=0 - shift - ;; - --allow) - ENABLE=2 - if [ -n "$2" ]; then - set_wwid $2 - shift 2 - else - usage - exit 1 - fi - ;; - --user_friendly_names) - if [ -n "$2" ]; then - FRIENDLY=$2 - shift 2 - else - usage - exit 1 - fi - ;; - --find_multipaths) - if [ -n "$2" ]; then - FIND=$2 - shift 2 - else - usage - exit 1 - fi - ;; - --property_blacklist) - if [ -n "$2" ]; then - PROPERTY=$2 - shift 2 - else - usage - exit 1 - fi - ;; - --enable_foreign) - if [ -n "$2" ]; then - FOREIGN=$2 - shift 2 - else - usage - exit 1 - fi - ;; - --with_module) - if [ -n "$2" ]; then - MODULE=$2 - shift 2 - else - usage - exit 1 - fi - ;; - --with_multipathd) - if [ -n "$2" ]; then - MULTIPATHD=$2 - shift 2 - else - usage - exit 1 - fi - ;; - --outfile) - if [ -n "$2" ]; then - OUTPUTFILE=$2 - HAVE_OUTFILE=1 - shift 2 - else - usage - exit 1 - fi - ;; - *) - usage - exit - esac - done -} - -function validate_args -{ - if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" ]; then - echo "ignoring extra parameters on disable" - FRIENDLY="" - FIND="" - PROPERTY="" - MODULE="" - fi - if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then - echo "--user_friendly_names must be either 'y' or 'n'" - exit 1 - fi - if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then - echo "--find_multipaths must be either 'y' or 'n'" - exit 1 - fi - if [ -n "$PROPERTY" ] && [ "$PROPERTY" != "y" -a "$PROPERTY" != "n" ]; then - echo "--property_blacklist must be either 'y' or 'n'" - exit 1 - fi - if [ -n "$FOREIGN" ] && [ "$FOREIGN" != "y" -a "$FOREIGN" != "n" ]; then - echo "--enable_foreign must be either 'y' or 'n'" - exit 1 - fi - if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" ]; then - SHOW_STATUS=1 - fi - if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then - echo "--with_module must be either 'y' or 'n'" - exit 1 - fi - if [ -n "$MULTIPATHD" ] && [ "$MULTIPATHD" != "y" -a "$MULTIPATHD" != "n" ]; then - echo "--with_multipathd must be either 'y' or 'n'" - exit 1 - fi - if [ "$ENABLE" = 2 -a -z "$HAVE_OUTFILE" ]; then - echo "Because --allow makes changes that cannot be automatically reversed," - echo "you must set --outfile when you set --allow" - exit 1 - fi -} - -function add_blacklist_exceptions -{ - INDEX=0 - while [ "$INDEX" -lt "$WWIDS" ] ; do - sed -i '/^blacklist_exceptions[[:space:]]*{/ a\ - wwid '"\"${WWID_LIST[$INDEX]}\""' -' $TMPFILE - ((INDEX++)) - done -} - -umask 0077 - -parse_args "$@" - -validate_args - -if [ ! -d "$MULTIPATHDIR" ]; then - echo "/etc/multipath/ does not exist. failing" - exit 1 -fi - -rm $TMPFILE 2> /dev/null -echo "$DEFAULT_CONFIG" > $TMPFILE -if [ -f "$CONFIGFILE" ]; then - cp $CONFIGFILE $TMPFILE -fi - -if grep -q "^blacklist[[:space:]]*{" $TMPFILE ; then - HAVE_BLACKLIST=1 -fi - -if grep -q "^blacklist_exceptions[[:space:]]*{" $TMPFILE ; then - HAVE_EXCEPTIONS=1 -fi - -if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then - HAVE_DEFAULTS=1 -fi - -if [ -z "$MODULE" -o "$MODULE" = "y" ]; then - if lsmod | grep -q "dm_multipath" ; then - HAVE_MODULE=1 - else - HAVE_MODULE=0 - fi -fi - -if [ "$MULTIPATHD" = "y" ]; then - if /bin/systemctl status multipathd.service > /dev/null 2>&1 ; then - HAVE_MULTIPATHD=1 - else - HAVE_MULTIPATHD=0 - fi -fi - -if [ "$HAVE_BLACKLIST" = "1" ]; then - if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then - HAVE_DISABLE=1 - elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"" ; then - HAVE_DISABLE=0 - fi -fi - -if [ "$HAVE_BLACKLIST" = "1" ]; then - if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*wwid \"\.\?\*\"" ; then - HAVE_WWID_DISABLE=1 - elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"" ; then - HAVE_WWID_DISABLE=0 - fi -fi - -if [ "$HAVE_DEFAULTS" = "1" ]; then - if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then - HAVE_FIND=1 - elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then - HAVE_FIND=0 - fi - if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then - HAVE_FRIENDLY=1 - elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then - HAVE_FRIENDLY=0 - fi - if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*enable_foreign" ; then - HAVE_FOREIGN=0 - elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]]*\"\^\$\"" ; then - HAVE_FOREIGN=1 - elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign" ; then - HAVE_FOREIGN=2 - fi -fi - -if [ "$HAVE_EXCEPTIONS" = "1" ]; then - if sed -n '/^blacklist_exceptions[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"" ; then - HAVE_PROPERTY=1 - elif sed -n '/^blacklist_exceptions[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"" ; then - HAVE_PROPERTY=0 - fi -fi - -if [ -n "$SHOW_STATUS" ]; then - if [ -z "$HAVE_DISABLE" -o "$HAVE_DISABLE" = 0 ]; then - echo "multipath is enabled" - else - echo "multipath is disabled" - fi - if [ -z "$HAVE_FIND" -o "$HAVE_FIND" = 0 ]; then - echo "find_multipaths is disabled" - else - echo "find_multipaths is enabled" - fi - if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then - echo "user_friendly_names is disabled" - else - echo "user_friendly_names is enabled" - fi - if [ -z "$HAVE_PROPERTY" -o "$HAVE_PROPERTY" = 0 ]; then - echo "default property blacklist is disabled" - else - echo "default property blacklist is enabled" - fi - if [ -z "$HAVE_FOREIGN" -o "$HAVE_FOREIGN" = 0 ]; then - echo "enable_foreign is not set (all foreign multipath devices will be shown)" - elif [ "$HAVE_FOREIGN" = 1 ]; then - echo "enable_foreign is set (no foreign multipath devices will be shown)" - else - echo "enable_foreign is set (foreign multipath devices may not be shown)" - fi - if [ -n "$HAVE_MODULE" ]; then - if [ "$HAVE_MODULE" = 1 ]; then - echo "dm_multipath module is loaded" - else - echo "dm_multipath module is not loaded" - fi - fi - if [ -z "$HAVE_MULTIPATHD" ]; then - if /bin/systemctl status multipathd.service > /dev/null 2>&1 ; then - HAVE_MULTIPATHD=1 - else - HAVE_MULTIPATHD=0 - fi - fi - if [ "$HAVE_MULTIPATHD" = 1 ]; then - echo "multipathd is running" - else - echo "multipathd is not running" - fi - exit 0 -fi - -if [ -z "$HAVE_BLACKLIST" ]; then - cat >> $TMPFILE <<- _EOF_ - -blacklist { -} -_EOF_ -fi - -if [ -z "$HAVE_DEFAULTS" ]; then - cat >> $TMPFILE <<- _EOF_ - -defaults { -} -_EOF_ -fi - -if [ "$ENABLE" = 2 ]; then - if [ "$HAVE_DISABLE" = 1 ]; then - sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE - fi - if [ -z "$HAVE_WWID_DISABLE" ]; then - sed -i '/^blacklist[[:space:]]*{/ a\ - wwid ".*" -' $TMPFILE - elif [ "$HAVE_WWID_DISABLE" = 0 ]; then - sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"/ wwid ".*"/' $TMPFILE - fi - if [ "$HAVE_EXCEPTIONS" = 1 ]; then - sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ {/^[[:space:]]*wwid/ d}' $TMPFILE - else - cat >> $TMPFILE <<- _EOF_ - -blacklist_exceptions { -} -_EOF_ - fi - add_blacklist_exceptions -elif [ "$ENABLE" = 1 ]; then - if [ "$HAVE_DISABLE" = 1 ]; then - sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE - fi -elif [ "$ENABLE" = 0 ]; then - if [ -z "$HAVE_DISABLE" ]; then - sed -i '/^blacklist[[:space:]]*{/ a\ - devnode ".*" -' $TMPFILE - elif [ "$HAVE_DISABLE" = 0 ]; then - sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE - fi -fi - -if [ "$FIND" = "n" ]; then - if [ "$HAVE_FIND" = 1 ]; then - sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/ find_multipaths no/' $TMPFILE - CHANGED_CONFIG=1 - fi -elif [ "$FIND" = "y" ]; then - if [ -z "$HAVE_FIND" ]; then - sed -i '/^defaults[[:space:]]*{/ a\ - find_multipaths yes -' $TMPFILE - CHANGED_CONFIG=1 - elif [ "$HAVE_FIND" = 0 ]; then - sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/ find_multipaths yes/' $TMPFILE - CHANGED_CONFIG=1 - fi -fi - -if [ "$FRIENDLY" = "n" ]; then - if [ "$HAVE_FRIENDLY" = 1 ]; then - sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/ user_friendly_names no/' $TMPFILE - CHANGED_CONFIG=1 - fi -elif [ "$FRIENDLY" = "y" ]; then - if [ -z "$HAVE_FRIENDLY" ]; then - sed -i '/^defaults[[:space:]]*{/ a\ - user_friendly_names yes -' $TMPFILE - CHANGED_CONFIG=1 - elif [ "$HAVE_FRIENDLY" = 0 ]; then - sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/ user_friendly_names yes/' $TMPFILE - CHANGED_CONFIG=1 - fi -fi - -if [ "$PROPERTY" = "n" ]; then - if [ "$HAVE_PROPERTY" = 1 ]; then - sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/# property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE - CHANGED_CONFIG=1 - fi -elif [ "$PROPERTY" = "y" ]; then - if [ -z "$HAVE_PROPERTY" ]; then - sed -i '/^blacklist_exceptions[[:space:]]*{/ a\ - property "(SCSI_IDENT_|ID_WWN)" -' $TMPFILE - CHANGED_CONFIG=1 - elif [ "$HAVE_PROPERTY" = 0 ]; then - sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/ property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE - CHANGED_CONFIG=1 - fi -fi - -if [ "$FOREIGN" = "y" ]; then - if [ "$HAVE_FOREIGN" = 1 -o "$HAVE_FOREIGN" = 2 ]; then - sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*enable_foreign/# enable_foreign/' $TMPFILE - CHANGED_CONFIG=1 - fi -elif [ "$FOREIGN" = "n" ]; then - if [ -z "$HAVE_FOREIGN" ]; then - sed -i '/^defaults[[:space:]]*{/ a\ - enable_foreign "^$" -' $TMPFILE - CHANGED_CONFIG=1 - elif [ "$HAVE_FOREIGN" = 0 -o "$HAVE_FOREIGN" = 2 ]; then - sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*#\?[[:space:]]*enable_foreign.*$/ enable_foreign "^$"/' $TMPFILE - CHANGED_CONFIG=1 - fi -fi - -if [ -f "$OUTPUTFILE" ]; then - cp $OUTPUTFILE $OUTPUTFILE.old - if [ $? != 0 ]; then - echo "failed to backup old config file, $OUTPUTFILE not updated" - exit 1 - fi -fi - -cp $TMPFILE $OUTPUTFILE -if [ $? != 0 ]; then - echo "failed to copy new config file into place, check $OUTPUTFILE is still OK" - exit 1 -fi - -rm -f $TMPFILE - -if [ "$ENABLE" = 1 ]; then - if [ "$HAVE_MODULE" = 0 ]; then - modprobe dm_multipath - fi - if [ "$HAVE_MULTIPATHD" = 0 ]; then - systemctl start multipathd.service - fi -elif [ "$ENABLE" = 0 ]; then - if [ "$HAVE_MULTIPATHD" = 1 ]; then - systemctl stop multipathd.service - fi -elif [ -n "$CHANGED_CONFIG" -a "$HAVE_MULTIPATHD" = 1 ]; then - systemctl reload multipathd.service -fi diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8 deleted file mode 100644 index b82961d..0000000 --- a/multipath/mpathconf.8 +++ /dev/null @@ -1,135 +0,0 @@ -.TH MPATHCONF 8 "June 2010" "" "Linux Administrator's Manual" -.SH NAME -mpathconf - A tool for configuring device-mapper-multipath -.SH SYNOPSIS -.B mpathconf -.RB [\| commands \|] -.RB [\| options \|] -.SH DESCRIPTION -.B mpathconf -is a utility that creates or modifies -.B /etc/multipath.conf. -It can enable or disable multipathing and configure some common options. -.B mpathconf -can also load the -.B dm_multipath -module, start and stop the -.B multipathd -daemon, and configure the -.B multipathd -service to start automatically or not. If -.B mpathconf -is called with no commands, it will display the current configuration, but -will not create of modify -.B /etc/multipath.conf - -The default options for mpathconf are -.B --with_module -The -.B --with_multipathd -option is not set by default. Enabling multipathing will load the -.B dm_multipath -module but it will not immediately start it. This is so -that users can manually edit their config file if necessary, before starting -.B multipathd. - -If -.B /etc/multipath.conf -already exists, mpathconf will edit it. If it does not exist, mpathconf will -create a default file with -.B user_friendly_names -and -.B find_multipaths -set. To disable these, use the -.B --user_friendly_names n -and -.B --find_multipaths n -options -.SH COMMANDS -.TP -.B --enable -Removes any line that blacklists all device nodes from the -.B /etc/multipath.conf -blacklist section. Also, creates -.B /etc/multipath.conf -if it doesn't exist. -.TP -.B --disable -Adds a line that blacklists all device nodes to the -.B /etc/multipath.conf -blacklist section. If no blacklist section exists, it will create one. -.TP -.B --allow \fB\fP -Modifies the \fB/etc/multipath/conf\fP blacklist to blacklist all -wwids and the blacklist_exceptions to whitelist \fB\fP. \fB\fP -can be in the form of MAJOR:MINOR, a wwid, or the name of a device-mapper -device, either a multipath device, or any device on stacked on top of one or -more multipath devices. This command can be used multiple times to allow -multiple devices. \fBNOTE:\fP This action will create a configuration file that -mpathconf will not be able to revert back to its previous state. Because -of this, \fB--outfile\fP is required when using \fB--allow\fP. -.TP -.B --user_friendly_names \fP { \fBy\fP | \fBn\fP } -If set to \fBy\fP, this adds the line -.B user_friendly_names yes -to the -.B /etc/multipath.conf -defaults section. If set to \fBn\fP, this removes the line, if present. This -command can be used along with any other command. -.TP -.B --find_multipaths\fP { \fBy\fP | \fBn\fP } -If set to \fBy\fP, this adds the line -.B find_multipaths yes -to the -.B /etc/multipath.conf -defaults section. If set to \fBn\fP, this removes the line, if present. This -command can be used along with any other command. -.TP -.B --property_blacklist \fP { \fBy\fP | \fBn\fP } -If set to \fBy\fP, this adds the line -.B property "(SCSI_IDENT_|ID_WWN)" -to the -.B /etc/multipath.conf -blacklist_exceptions section. If set to \fBn\fP, this removes the line, if -present. This command can be used along with any other command. -.TP -.B --enable_foreign\fP { \fBy\fP | \fBn\fP } -If set to \fBn\fP, this adds the line -.B enable_foreign "^$" -to the -.B /etc/multipath.conf -defaults section. if set to \fBy\fP, this removes the line, if present. This -command can be used along with any other command. -.TP -.B --outfile \fB\fP -Write the resulting multipath configuration to \fB\fP instead of -\fB/etc/multipath.conf\fP. -.SH OPTIONS -.TP -.B --with_module\fP { \fBy\fP | \fBn\fP } -If set to \fBy\fP, this runs -.B modprobe dm_multipath -to install the multipath modules. This option only works with the -.B --enable -command. This option is set to \fBy\fP by default. -.TP -.B --with_multipathd { \fBy\fP | \fBn\fP } -If set to \fBy\fP, this runs -.B service multipathd start -to start the multipathd daemon on \fB--enable\fP, -.B service multipathd stop -to stop the multipathd daemon on \fB--disable\fP, and -.B service multipathd reload -to reconfigure multipathd on \fB--user_frindly_names\fP and -\fB--find_multipaths\fP. -This option is set to \fBn\fP by default. -.SH FILES -.BR /etc/multipath.conf -.SH "SEE ALSO" -.BR multipath.conf (5), -.BR modprobe (8), -.BR multipath (8), -.BR multipathd (8), -.BR service (8), -.SH AUTHOR -Benjamin Marzinski diff --git a/multipath/multipath.8 b/multipath/multipath.8 index 47a33f9..9cdd05a 100644 --- a/multipath/multipath.8 +++ b/multipath/multipath.8 @@ -63,7 +63,7 @@ multipath \- Device mapper target autoconfig. .B multipath .RB [\| \-v\ \c .IR level \|] -.RB [\| \-A | \-W \|] +.B -W . .LP .B multipath @@ -125,11 +125,11 @@ the system. Other operation modes are chosen by using one of the following command line switches: .TP .B \-f -Flush (remove) a multipath device map specified as parameter, if unused. This operation is delegated to the multipathd daemon if it's running. +Flush (remove) a multipath device map specified as parameter, if unused. . .TP .B \-F -Flush (remove) all unused multipath device maps. This operation is delegated to the multipathd daemon if it's running. +Flush (remove) all unused multipath device maps. . .TP .B \-l @@ -145,11 +145,6 @@ device mapper, path checkers ...). Add the WWID for the specified device to the WWIDs file. . .TP -.B \-A -Add the WWIDs from any kernel command line \fImpath.wwid\fR parameters to the -WWIDs file. -. -.TP .B \-w Remove the WWID for the specified device from the WWIDs file. . diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index a568609..05a5e8f 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -634,13 +634,8 @@ The default is: \fBno\fR . .TP .B checker_timeout -Specify the timeout to use for path checkers and prioritizers, in seconds. -Only prioritizers that issue scsi commands use checker_timeout. Checkers -that support an asynchronous mode (\fItur\fR and \fIdirectio\fR), will -return shortly after being called by multipathd, regardless of whether the -storage array responds. If the storage array hasn't responded, mulitpathd will -check for a response every second, until \fIchecker_timeout\fR seconds have -elapsed. +Specify the timeout to use for path checkers and prioritizers that issue SCSI +commands with an explicit timeout, in seconds. .RS .TP The default is: in \fB/sys/block/sd/device/timeout\fR @@ -705,22 +700,6 @@ The default is: \fB600\fR . . .TP -.B eh_deadline -Specify the maximum number of seconds the SCSI layer will spend doing error -handling when scsi devices fail. After this timeout the scsi layer will perform -a full HBA reset. Setting this may be necessary in cases where the rport is -never lost, so \fIfast_io_fail_tmo\fR and \fIdev_loss_tmo\fR will never -trigger, but (frequently do to load) scsi commands still hang. \fBNote:\fR when -the scsi error handler performs the HBA reset, all target paths on that HBA -will be affected. eh_deadline should only be set in cases where all targets on -the affected HBAs are multipathed. -.RS -.TP -The default is: \fB\fR -.RE -. -. -.TP .B bindings_file The full pathname of the binding file to be used when the user_friendly_names option is set. @@ -1269,16 +1248,6 @@ being handled by multipath-tools. .LP . . -In the \fIblacklist\fR and \fIblacklist_exceptions\fR sections, starting a -quoted value with an exclamation mark \fB"!"\fR will invert the matching -of the rest of the regular expression. For instance, \fB"!^sd[a-z]"\fR will -match all values that do not start with \fB"sd[a-z]"\fR. The exclamation mark -can be escaped \fB"\\!"\fR to match a literal \fB!\fR at the start of a -regular expression. \fBNote:\fR The exclamation mark must be inside quotes, -otherwise it will be treated as starting a comment. -.LP -. -. The \fIblacklist_exceptions\fR section is used to revert the actions of the \fIblacklist\fR section. This allows one to selectively include ("whitelist") devices which would normally be excluded via the \fIblacklist\fR section. A common usage is @@ -1295,9 +1264,10 @@ unless explicitly stated. Regular expression matching the device nodes to be excluded/included. .RS .PP -The default \fIblacklist\fR consists of the regular expression -\fB"!^(sd[a-z]|dasd[a-z]|nvme[0-9])"\fR. This causes all device types other -than scsi, dasd, and nvme to be excluded from multipath handling by default. +The default \fIblacklist\fR consists of the regular expressions +"^(ram|zram|raw|loop|fd|md|dm-|sr|scd|st|dcssblk)[0-9]" and +"^(td|hd|vd)[a-z]". This causes virtual devices, non-disk devices, and some other +device types to be excluded from multipath handling by default. .RE .TP .B wwid @@ -1316,14 +1286,9 @@ keywords. Both are regular expressions. For a full description of these keywords Regular expression for an udev property. All devices that have matching udev properties will be excluded/included. The handling of the \fIproperty\fR keyword is special, -because if a property blacklist_exception is set, devices \fBmust\fR have at -least one whitelisted udev property; +because devices \fBmust\fR have at least one whitelisted udev property; otherwise they're treated as blacklisted, and the message "\fIblacklisted, udev property missing\fR" is displayed in the logs. -For example, setting the property blacklist_exception to -\fB(SCSI_IDENT_|ID_WWN)\fR, will cause well-behaved SCSI devices and devices -that provide a WWN (World Wide Number) to be included, and all others to be -excluded. This works to exclude most non-multipathable devices. . .RS .PP @@ -1334,6 +1299,10 @@ Blacklisting by missing properties is only applied to devices which do have the property specified by \fIuid_attribute\fR (e.g. \fIID_SERIAL\fR) set. Previously, it was applied to every device, possibly causing devices to be blacklisted because of temporary I/O error conditions. +.PP +The default \fIblacklist exception\fR is: \fB(SCSI_IDENT_|ID_WWN)\fR, causing +well-behaved SCSI devices and devices that provide a WWN (World Wide Number) +to be included, and all others to be excluded. .RE .TP .B protocol diff --git a/multipath/multipath.rules b/multipath/multipath.rules index 0486bf7..9df11a9 100644 --- a/multipath/multipath.rules +++ b/multipath/multipath.rules @@ -9,7 +9,6 @@ IMPORT{cmdline}="nompath" ENV{nompath}=="?*", GOTO="end_mpath" IMPORT{cmdline}="multipath" ENV{multipath}=="off", GOTO="end_mpath" -TEST!="/etc/multipath.conf", GOTO="end_mpath" ENV{DEVTYPE}!="partition", GOTO="test_dev" IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH" diff --git a/multipathd/cli.c b/multipathd/cli.c index bdc9fb1..800c0fb 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -568,7 +568,6 @@ cli_init (void) { add_handler(DEL+PATH, NULL); add_handler(ADD+MAP, NULL); add_handler(DEL+MAP, NULL); - add_handler(DEL+MAPS, NULL); add_handler(SWITCH+MAP+GROUP, NULL); add_handler(RECONFIGURE, NULL); add_handler(SUSPEND+MAP, NULL); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 782bb00..7d878c8 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -66,7 +66,7 @@ show_paths (char ** r, int * len, struct vectors * vecs, char * style, c += snprint_foreign_paths(c, reply + maxlen - c, style, pretty); - again = (c == reply + maxlen - 1); + again = ((c - reply) == (maxlen - 1)); REALLOC_REPLY(reply, again, maxlen); } @@ -102,7 +102,7 @@ show_path (char ** r, int * len, struct vectors * vecs, struct path *pp, c += snprint_path(c, reply + maxlen - c, style, pp, 0); - again = (c == reply + maxlen - 1); + again = ((c - reply) == (maxlen - 1)); REALLOC_REPLY(reply, again, maxlen); } @@ -131,7 +131,7 @@ show_map_topology (char ** r, int * len, struct multipath * mpp, c = reply; c += snprint_multipath_topology(c, reply + maxlen - c, mpp, 2); - again = (c == reply + maxlen - 1); + again = ((c - reply) == (maxlen - 1)); REALLOC_REPLY(reply, again, maxlen); } @@ -171,7 +171,7 @@ show_maps_topology (char ** r, int * len, struct vectors * vecs) } c += snprint_foreign_topology(c, reply + maxlen - c, 2); - again = (c == reply + maxlen - 1); + again = ((c - reply) == (maxlen - 1)); REALLOC_REPLY(reply, again, maxlen); } @@ -209,7 +209,7 @@ show_maps_json (char ** r, int * len, struct vectors * vecs) c = reply; c += snprint_multipath_topology_json(c, maxlen, vecs); - again = (c == reply + maxlen); + again = ((c - reply) == maxlen); REALLOC_REPLY(reply, again, maxlen); } @@ -238,7 +238,7 @@ show_map_json (char ** r, int * len, struct multipath * mpp, c = reply; c += snprint_multipath_map_json(c, maxlen, mpp); - again = (c == reply + maxlen); + again = ((c - reply) == maxlen); REALLOC_REPLY(reply, again, maxlen); } @@ -487,7 +487,7 @@ show_map (char ** r, int *len, struct multipath * mpp, char * style, c += snprint_multipath(c, reply + maxlen - c, style, mpp, pretty); - again = (c == reply + maxlen - 1); + again = ((c - reply) == (maxlen - 1)); REALLOC_REPLY(reply, again, maxlen); } @@ -533,7 +533,7 @@ show_maps (char ** r, int *len, struct vectors * vecs, char * style, } c += snprint_foreign_multipaths(c, reply + maxlen - c, style, pretty); - again = (c == reply + maxlen - 1); + again = ((c - reply) == (maxlen - 1)); REALLOC_REPLY(reply, again, maxlen); } @@ -853,25 +853,6 @@ cli_del_map (void * v, char ** reply, int * len, void * data) } int -cli_del_maps (void *v, char **reply, int *len, void *data) -{ - struct vectors * vecs = (struct vectors *)data; - struct multipath *mpp; - int i, ret = 0; - - condlog(2, "remove maps (operator)"); - vector_foreach_slot(vecs->mpvec, mpp, i) { - if (flush_map(mpp, vecs, 0)) - ret++; - else - i--; - } - /* flush any multipath maps that aren't currently known by multipathd */ - ret |= dm_flush_maps(0, 0); - return ret; -} - -int cli_reload(void *v, char **reply, int *len, void *data) { struct vectors * vecs = (struct vectors *)data; @@ -1316,7 +1297,7 @@ show_blacklist (char ** r, int * len) c = reply; c += snprint_blacklist_report(conf, c, maxlen); - again = (c == reply + maxlen); + again = ((c - reply) == maxlen); REALLOC_REPLY(reply, again, maxlen); } pthread_cleanup_pop(1); @@ -1358,7 +1339,7 @@ show_devices (char ** r, int * len, struct vectors *vecs) c = reply; c += snprint_devices(conf, c, maxlen, vecs); - again = (c == reply + maxlen); + again = ((c - reply) == maxlen); REALLOC_REPLY(reply, again, maxlen); } pthread_cleanup_pop(1); diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index 6f57b42..0f45106 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -26,7 +26,6 @@ int cli_add_path (void * v, char ** reply, int * len, void * data); int cli_del_path (void * v, char ** reply, int * len, void * data); int cli_add_map (void * v, char ** reply, int * len, void * data); int cli_del_map (void * v, char ** reply, int * len, void * data); -int cli_del_maps (void * v, char ** reply, int * len, void * data); int cli_switch_group(void * v, char ** reply, int * len, void * data); int cli_reconfigure(void * v, char ** reply, int * len, void * data); int cli_resize(void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index 1d0579e..8baf9ab 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -414,7 +414,7 @@ int __setup_multipath(struct vectors *vecs, struct multipath *mpp, goto out; } - if (update_multipath_strings(mpp, vecs->pathvec, 1) != DMP_OK) { + if (update_multipath_strings(mpp, vecs->pathvec, 1)) { condlog(0, "%s: failed to setup multipath", mpp->alias); goto out; } @@ -553,9 +553,9 @@ add_map_without_path (struct vectors *vecs, const char *alias) mpp->mpe = find_mpe(conf->mptable, mpp->wwid); put_multipath_config(conf); - if (update_multipath_table(mpp, vecs->pathvec, 1) != DMP_OK) + if (update_multipath_table(mpp, vecs->pathvec, 1)) goto out; - if (update_multipath_status(mpp) != DMP_OK) + if (update_multipath_status(mpp)) goto out; if (!vector_alloc_slot(vecs->mpvec)) @@ -631,7 +631,7 @@ sync_maps_state(vector mpvec) sync_map_state(mpp); } -int +static int flush_map(struct multipath * mpp, struct vectors * vecs, int nopaths) { int r; @@ -1346,8 +1346,8 @@ map_discovery (struct vectors * vecs) return 1; vector_foreach_slot (vecs->mpvec, mpp, i) - if (update_multipath_table(mpp, vecs->pathvec, 1) != DMP_OK || - update_multipath_status(mpp) != DMP_OK) { + if (update_multipath_table(mpp, vecs->pathvec, 1) || + update_multipath_status(mpp)) { remove_map(mpp, vecs, 1); i--; } @@ -1551,7 +1551,6 @@ uxlsnrloop (void * ap) set_handler_callback(DEL+PATH, cli_del_path); set_handler_callback(ADD+MAP, cli_add_map); set_handler_callback(DEL+MAP, cli_del_map); - set_handler_callback(DEL+MAPS, cli_del_maps); set_handler_callback(SWITCH+MAP+GROUP, cli_switch_group); set_unlocked_handler_callback(RECONFIGURE, cli_reconfigure); set_handler_callback(SUSPEND+MAP, cli_suspend); @@ -1612,18 +1611,22 @@ fail_path (struct path * pp, int del_active) /* * caller must have locked the path list before calling that function */ -static void +static int reinstate_path (struct path * pp) { + int ret = 0; + if (!pp->mpp) - return; + return 0; - if (dm_reinstate_path(pp->mpp->alias, pp->dev_t)) + if (dm_reinstate_path(pp->mpp->alias, pp->dev_t)) { condlog(0, "%s: reinstate failed", pp->dev_t); - else { + ret = 1; + } else { condlog(2, "%s: reinstated", pp->dev_t); update_queue_mode_add_path(pp->mpp); } + return ret; } static void @@ -2084,16 +2087,9 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) /* * Synchronize with kernel state */ - ret = update_multipath_strings(pp->mpp, vecs->pathvec, 1); - if (ret != DMP_OK) { - if (ret == DMP_NOT_FOUND) { - /* multipath device missing. Likely removed */ - condlog(1, "%s: multipath device '%s' not found", - pp->dev, pp->mpp->alias); - return 0; - } else - condlog(1, "%s: Couldn't synchronize with kernel state", - pp->dev); + if (update_multipath_strings(pp->mpp, vecs->pathvec, 1)) { + condlog(1, "%s: Could not synchronize with kernel state", + pp->dev); pp->dmstate = PSTATE_UNDEF; } /* if update_multipath_strings orphaned the path, quit early */ @@ -2183,8 +2179,12 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) /* * reinstate this path */ - if (!disable_reinstate) - reinstate_path(pp); + if (!disable_reinstate && reinstate_path(pp)) { + condlog(3, "%s: reload map", pp->dev); + ev_add_path(pp, vecs, 1); + pp->tick = 1; + return 0; + } new_path_up = 1; if (oldchkrstate != PATH_UP && oldchkrstate != PATH_GHOST) @@ -2200,10 +2200,15 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) else if (newstate == PATH_UP || newstate == PATH_GHOST) { if ((pp->dmstate == PSTATE_FAILED || pp->dmstate == PSTATE_UNDEF) && - !disable_reinstate) + !disable_reinstate) { /* Clear IO errors */ - reinstate_path(pp); - else { + if (reinstate_path(pp)) { + condlog(3, "%s: reload map", pp->dev); + ev_add_path(pp, vecs, 1); + pp->tick = 1; + return 0; + } + } else { LOG_MSG(4, verbosity, pp); if (pp->checkint != max_checkint) { /* @@ -2369,7 +2374,7 @@ checkerloop (void *ap) conf = get_multipath_config(); max_checkint = conf->max_checkint; put_multipath_config(conf); - if (diff_time.tv_sec > (time_t)max_checkint) + if (diff_time.tv_sec > max_checkint) condlog(1, "path checkers took longer " "than %lu seconds, consider " "increasing max_polling_interval", diff --git a/multipathd/main.h b/multipathd/main.h index 5dff17e..7bb8463 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -28,7 +28,6 @@ int ev_add_path (struct path *, struct vectors *, int); int ev_remove_path (struct path *, struct vectors *, int); int ev_add_map (char *, const char *, struct vectors *); int ev_remove_map (char *, char *, int, struct vectors *); -int flush_map(struct multipath *, struct vectors *, int); int set_config_state(enum daemon_status); void * mpath_alloc_prin_response(int prin_sa); int prin_do_scsi_ioctl(char *, int rq_servact, struct prin_resp * resp, diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 index 8bd47a8..048a838 100644 --- a/multipathd/multipathd.8 +++ b/multipathd/multipathd.8 @@ -39,8 +39,6 @@ map regains its maximum performance and redundancy. This daemon executes the external \fBmultipath\fR tool when events occur. In turn, the multipath tool signals the multipathd daemon when it is done with devmap reconfiguration, so that it can refresh its failed path list. - -In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists. . . .\" ---------------------------------------------------------------------------- diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service index bc8fa07..ba24983 100644 --- a/multipathd/multipathd.service +++ b/multipathd/multipathd.service @@ -2,9 +2,8 @@ Description=Device-Mapper Multipath Device Controller Wants=systemd-udev-trigger.service systemd-udev-settle.service Before=iscsi.service iscsid.service lvm2-activation-early.service -Before=local-fs-pre.target blk-availability.service shutdown.target +Before=local-fs-pre.target blk-availability.service After=multipathd.socket systemd-udev-trigger.service systemd-udev-settle.service -ConditionPathExists=/etc/multipath.conf DefaultDependencies=no Conflicts=shutdown.target ConditionKernelCommandLine=!nompath @@ -15,7 +14,6 @@ Type=notify NotifyAccess=main LimitCORE=infinity ExecStartPre=-/sbin/modprobe -a scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm-multipath -ExecStartPre=-/sbin/multipath -A ExecStart=/sbin/multipathd -d -s ExecReload=/sbin/multipathd reconfigure TasksMax=infinity diff --git a/tests/blacklist.c b/tests/blacklist.c index 401600d..6e7c186 100644 --- a/tests/blacklist.c +++ b/tests/blacklist.c @@ -60,46 +60,20 @@ __wrap_udev_list_entry_get_name(struct udev_list_entry *list_entry) return *(const char **)list_entry; } -vector elist_property_default; -vector blist_devnode_default; vector blist_devnode_sdb; -vector blist_devnode_sdb_inv; vector blist_all; vector blist_device_foo_bar; -vector blist_device_foo_inv_bar; -vector blist_device_foo_bar_inv; vector blist_device_all; vector blist_wwid_xyzzy; -vector blist_wwid_xyzzy_inv; vector blist_protocol_fcp; -vector blist_protocol_fcp_inv; vector blist_property_wwn; -vector blist_property_wwn_inv; static int setup(void **state) { - struct config conf; - - memset(&conf, 0, sizeof(conf)); - conf.blist_devnode = vector_alloc(); - if (!conf.blist_devnode) - return -1; - conf.elist_property = vector_alloc(); - if (!conf.elist_property) - return -1; - if (setup_default_blist(&conf) != 0) - return -1; - elist_property_default = conf.elist_property; - blist_devnode_default = conf.blist_devnode; - blist_devnode_sdb = vector_alloc(); if (!blist_devnode_sdb || store_ble(blist_devnode_sdb, strdup("sdb"), ORIGIN_CONFIG)) return -1; - blist_devnode_sdb_inv = vector_alloc(); - if (!blist_devnode_sdb_inv || - store_ble(blist_devnode_sdb_inv, strdup("!sdb"), ORIGIN_CONFIG)) - return -1; blist_all = vector_alloc(); if (!blist_all || store_ble(blist_all, strdup(".*"), ORIGIN_CONFIG)) @@ -110,18 +84,6 @@ static int setup(void **state) set_ble_device(blist_device_foo_bar, strdup("foo"), strdup("bar"), ORIGIN_CONFIG)) return -1; - blist_device_foo_inv_bar = vector_alloc(); - if (!blist_device_foo_inv_bar || - alloc_ble_device(blist_device_foo_inv_bar) || - set_ble_device(blist_device_foo_inv_bar, strdup("!foo"), - strdup("bar"), ORIGIN_CONFIG)) - return -1; - blist_device_foo_bar_inv = vector_alloc(); - if (!blist_device_foo_bar_inv || - alloc_ble_device(blist_device_foo_bar_inv) || - set_ble_device(blist_device_foo_bar_inv, strdup("foo"), - strdup("!bar"), ORIGIN_CONFIG)) - return -1; blist_device_all = vector_alloc(); if (!blist_device_all || alloc_ble_device(blist_device_all) || @@ -133,50 +95,29 @@ static int setup(void **state) if (!blist_wwid_xyzzy || store_ble(blist_wwid_xyzzy, strdup("xyzzy"), ORIGIN_CONFIG)) return -1; - blist_wwid_xyzzy_inv = vector_alloc(); - if (!blist_wwid_xyzzy_inv || - store_ble(blist_wwid_xyzzy_inv, strdup("!xyzzy"), ORIGIN_CONFIG)) - return -1; blist_protocol_fcp = vector_alloc(); if (!blist_protocol_fcp || store_ble(blist_protocol_fcp, strdup("scsi:fcp"), ORIGIN_CONFIG)) return -1; - blist_protocol_fcp_inv = vector_alloc(); - if (!blist_protocol_fcp_inv || - store_ble(blist_protocol_fcp_inv, strdup("!scsi:fcp"), - ORIGIN_CONFIG)) - return -1; blist_property_wwn = vector_alloc(); if (!blist_property_wwn || store_ble(blist_property_wwn, strdup("ID_WWN"), ORIGIN_CONFIG)) return -1; - blist_property_wwn_inv = vector_alloc(); - if (!blist_property_wwn_inv || - store_ble(blist_property_wwn_inv, strdup("!ID_WWN"), ORIGIN_CONFIG)) - return -1; return 0; } static int teardown(void **state) { - free_blacklist(elist_property_default); - free_blacklist(blist_devnode_default); free_blacklist(blist_devnode_sdb); - free_blacklist(blist_devnode_sdb_inv); free_blacklist(blist_all); free_blacklist_device(blist_device_foo_bar); - free_blacklist_device(blist_device_foo_inv_bar); - free_blacklist_device(blist_device_foo_bar_inv); free_blacklist_device(blist_device_all); free_blacklist(blist_wwid_xyzzy); - free_blacklist(blist_wwid_xyzzy_inv); free_blacklist(blist_protocol_fcp); - free_blacklist(blist_protocol_fcp_inv); free_blacklist(blist_property_wwn); - free_blacklist(blist_property_wwn_inv); return 0; } @@ -200,11 +141,6 @@ static void test_devnode_blacklist(void **state) expect_condlog(3, "sdb: device node name blacklisted\n"); assert_int_equal(filter_devnode(blist_devnode_sdb, NULL, "sdb"), MATCH_DEVNODE_BLIST); - assert_int_equal(filter_devnode(blist_devnode_sdb_inv, NULL, "sdb"), - MATCH_NOTHING); - expect_condlog(3, "sdc: device node name blacklisted\n"); - assert_int_equal(filter_devnode(blist_devnode_sdb_inv, NULL, "sdc"), - MATCH_DEVNODE_BLIST); } static void test_devnode_whitelist(void **state) @@ -223,39 +159,12 @@ static void test_devnode_missing(void **state) MATCH_NOTHING); } -static void test_devnode_default(void **state) -{ - assert_int_equal(filter_devnode(blist_devnode_default, NULL, "sdaa"), - MATCH_NOTHING); - assert_int_equal(filter_devnode(blist_devnode_default, NULL, "nvme0n1"), - MATCH_NOTHING); - assert_int_equal(filter_devnode(blist_devnode_default, NULL, "dasda"), - MATCH_NOTHING); - expect_condlog(3, "hda: device node name blacklisted\n"); - assert_int_equal(filter_devnode(blist_devnode_default, NULL, "hda"), - MATCH_DEVNODE_BLIST); -} - static void test_device_blacklist(void **state) { expect_condlog(3, "sdb: (foo:bar) vendor/product blacklisted\n"); assert_int_equal(filter_device(blist_device_foo_bar, NULL, "foo", "bar", "sdb"), MATCH_DEVICE_BLIST); - assert_int_equal(filter_device(blist_device_foo_inv_bar, NULL, "foo", - "bar", "sdb"), - MATCH_NOTHING); - assert_int_equal(filter_device(blist_device_foo_bar_inv, NULL, "foo", - "bar", "sdb"), - MATCH_NOTHING); - expect_condlog(3, "sdb: (baz:bar) vendor/product blacklisted\n"); - assert_int_equal(filter_device(blist_device_foo_inv_bar, NULL, "baz", - "bar", "sdb"), - MATCH_DEVICE_BLIST); - expect_condlog(3, "sdb: (foo:baz) vendor/product blacklisted\n"); - assert_int_equal(filter_device(blist_device_foo_bar_inv, NULL, "foo", - "baz", "sdb"), - MATCH_DEVICE_BLIST); } static void test_device_whitelist(void **state) @@ -282,11 +191,6 @@ static void test_wwid_blacklist(void **state) expect_condlog(3, "sdb: wwid xyzzy blacklisted\n"); assert_int_equal(filter_wwid(blist_wwid_xyzzy, NULL, "xyzzy", "sdb"), MATCH_WWID_BLIST); - assert_int_equal(filter_wwid(blist_wwid_xyzzy_inv, NULL, "xyzzy", - "sdb"), MATCH_NOTHING); - expect_condlog(3, "sdb: wwid plugh blacklisted\n"); - assert_int_equal(filter_wwid(blist_wwid_xyzzy_inv, NULL, "plugh", - "sdb"), MATCH_WWID_BLIST); } static void test_wwid_whitelist(void **state) @@ -314,12 +218,6 @@ static void test_protocol_blacklist(void **state) expect_condlog(3, "sdb: protocol scsi:fcp blacklisted\n"); assert_int_equal(filter_protocol(blist_protocol_fcp, NULL, &pp), MATCH_PROTOCOL_BLIST); - assert_int_equal(filter_protocol(blist_protocol_fcp_inv, NULL, &pp), - MATCH_NOTHING); - pp.sg_id.proto_id = SCSI_PROTOCOL_ATA; - expect_condlog(3, "sdb: protocol scsi:ata blacklisted\n"); - assert_int_equal(filter_protocol(blist_protocol_fcp_inv, NULL, &pp), - MATCH_PROTOCOL_BLIST); } static void test_protocol_whitelist(void **state) @@ -347,17 +245,10 @@ static void test_protocol_missing(void **state) static void test_property_blacklist(void **state) { static struct udev_device udev = { "sdb", { "ID_FOO", "ID_WWN", "ID_BAR", NULL } }; - static struct udev_device udev_inv = { "sdb", { "ID_WWN", NULL } }; conf.blist_property = blist_property_wwn; expect_condlog(3, "sdb: udev property ID_WWN blacklisted\n"); assert_int_equal(filter_property(&conf, &udev, 3, "ID_SERIAL"), MATCH_PROPERTY_BLIST); - conf.blist_property = blist_property_wwn_inv; - expect_condlog(3, "sdb: udev property ID_FOO blacklisted\n"); - assert_int_equal(filter_property(&conf, &udev, 3, "ID_SERIAL"), - MATCH_PROPERTY_BLIST); - assert_int_equal(filter_property(&conf, &udev_inv, 3, "ID_SERIAL"), - MATCH_NOTHING); } /* the property check works different in that you check all the property @@ -378,8 +269,9 @@ static void test_property_missing(void **state) { static struct udev_device udev = { "sdb", { "ID_FOO", "ID_BAZ", "ID_BAR", "ID_SERIAL", NULL } }; conf.blist_property = blist_property_wwn; + expect_condlog(3, "sdb: blacklisted, udev property missing\n"); assert_int_equal(filter_property(&conf, &udev, 3, "ID_SERIAL"), - MATCH_NOTHING); + MATCH_PROPERTY_BLIST_MISSING); assert_int_equal(filter_property(&conf, &udev, 3, "ID_BLAH"), MATCH_NOTHING); assert_int_equal(filter_property(&conf, &udev, 3, ""), @@ -471,7 +363,9 @@ static void test_filter_path_missing1(void **state) conf.blist_device = blist_device_foo_bar; conf.blist_protocol = blist_protocol_fcp; conf.blist_wwid = blist_wwid_xyzzy; - assert_int_equal(filter_path(&conf, &miss1_pp), MATCH_NOTHING); + expect_condlog(3, "sdb: blacklisted, udev property missing\n"); + assert_int_equal(filter_path(&conf, &miss1_pp), + MATCH_PROPERTY_BLIST_MISSING); } /* This one matches the property whitelist, to test the other missing @@ -590,7 +484,6 @@ int test_blacklist(void) cmocka_unit_test(test_devnode_blacklist), cmocka_unit_test(test_devnode_whitelist), cmocka_unit_test(test_devnode_missing), - cmocka_unit_test(test_devnode_default), cmocka_unit_test(test_device_blacklist), cmocka_unit_test(test_device_whitelist), cmocka_unit_test(test_device_missing), diff --git a/tests/parser.c b/tests/parser.c index 5772391..29859da 100644 --- a/tests/parser.c +++ b/tests/parser.c @@ -440,46 +440,6 @@ static void test18(void **state) free_strvec(v); } -static void test19(void **state) -{ -#define QUOTED19 "!value" - vector v = alloc_strvec("key \"" QUOTED19 "\""); - char *val; - - assert_int_equal(VECTOR_SIZE(v), 4); - assert_string_equal(VECTOR_SLOT(v, 0), "key"); - assert_true(is_quote(VECTOR_SLOT(v, 1))); - assert_string_equal(VECTOR_SLOT(v, 2), QUOTED19); - assert_true(is_quote(VECTOR_SLOT(v, 3))); - assert_int_equal(validate_config_strvec(v, test_file), 0); - - val = set_value(v); - assert_string_equal(val, QUOTED19); - - free(val); - free_strvec(v); -} - -static void test20(void **state) -{ -#define QUOTED20 "#value" - vector v = alloc_strvec("key \"" QUOTED20 "\""); - char *val; - - assert_int_equal(VECTOR_SIZE(v), 4); - assert_string_equal(VECTOR_SLOT(v, 0), "key"); - assert_true(is_quote(VECTOR_SLOT(v, 1))); - assert_string_equal(VECTOR_SLOT(v, 2), QUOTED20); - assert_true(is_quote(VECTOR_SLOT(v, 3))); - assert_int_equal(validate_config_strvec(v, test_file), 0); - - val = set_value(v); - assert_string_equal(val, QUOTED20); - - free(val); - free_strvec(v); -} - int test_config_parser(void) { const struct CMUnitTest tests[] = { @@ -501,8 +461,6 @@ int test_config_parser(void) cmocka_unit_test(test16), cmocka_unit_test(test17), cmocka_unit_test(test18), - cmocka_unit_test(test19), - cmocka_unit_test(test20), }; return cmocka_run_group_tests(tests, setup, teardown); } diff --git a/tests/test-lib.c b/tests/test-lib.c index 08ff2d8..5927516 100644 --- a/tests/test-lib.c +++ b/tests/test-lib.c @@ -15,7 +15,7 @@ #include "test-lib.h" const int default_mask = (DI_SYSFS|DI_BLACKLIST|DI_WWID|DI_CHECKER|DI_PRIO); -const char default_devnode[] = "sdxTEST"; +const char default_devnode[] = "sdTEST"; const char default_wwid[] = "TEST-WWID"; /* default_wwid should be a substring of default_wwid_1! */ const char default_wwid_1[] = "TEST-WWID-1";