multipath-tools/.git
11 hours agokpartx: don't keep creating recursive partitions master
Benjamin Marzinski [Wed, 15 Feb 2017 02:16:51 +0000 (20:16 -0600)]
kpartx: don't keep creating recursive partitions

If the dos partition table is corrupted, kpartx can just keep creating
the same partitions until it runs out of partition numbers. This check
catches the recursion.

Signed-off-by: Cedric Buissart <cbuissar@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
12 hours agomultipath-tools: Introducing multipath C API
Gris Ge [Fri, 24 Feb 2017 12:50:26 +0000 (20:50 +0800)]
multipath-tools: Introducing multipath C API

Features:

 * Use mpath_cmd.h for IPC connection and use output of 'show maps json'.
 * Library user guide will be 'man 3 libdmmp.h'.
 * Every public function has its own manpage in section 3 which is
   generated by linux 'kernel-doc' tool.

Usage:

    make -j5
    sudo make install \
            bindir=/usr/sbin/ \
            syslibdir=/usr/lib64/ \
            libdir=/usr/lib64/multipath \
            rcdir=/etc/rc.d/init.d \
            unitdir=/usr/lib/systemd/system \
            includedir=/usr/include
    make -C libdmmp check
    make -C libdmmp speed_test

    man libdmmp.h
    man dmmp_mpath_array_get
    man <dmmp function name>

Performance:

 * 10k scsi_debug sdX with 2 disks per mpath (i7-6820HQ 16GiB RAM):
   $ make -C libdmmp speed_test
   Got 5000 mpath
   real 3.22
   user 0.15
   sys 0.01

Misc:
 * Developer note is libdmmp/DEV_NOTES.

Changes since V4:

 * Add new function dmmp_mpath_kdev_name_get() to query the '/dev/dm-01' for
   mpath.
 * Updated manpages.
 * Rebased to current master ea4367159d32444e48a409a4f1c4f18324b737a9.

Signed-off-by: Gris Ge <fge@redhat.com>
12 hours agomultipath-tools: sync valgrind.h with 3.12 upstream
Xose Vazquez Perez [Mon, 20 Feb 2017 13:37:30 +0000 (14:37 +0100)]
multipath-tools: sync valgrind.h with 3.12 upstream

Cc: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
12 hours agomultipath-tools: add availability of service-time and queue-length to multipath.conf.5
Xose Vazquez Perez [Tue, 21 Feb 2017 21:31:08 +0000 (22:31 +0100)]
multipath-tools: add availability of service-time and queue-length to multipath.conf.5

https://kernelnewbies.org/Linux_2_6_31#head-7a4afa809f53cf9a2df884c745f4f8150e24645a

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
12 hours agomultipath-tools: add availability of service-time and queue-length to multipath.conf.5
Xose Vazquez Perez [Tue, 21 Feb 2017 20:18:40 +0000 (21:18 +0100)]
multipath-tools: add availability of service-time and queue-length to multipath.conf.5

https://kernelnewbies.org/Linux_2_6_31#head-7a4afa809f53cf9a2df884c745f4f8150e24645a

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
12 hours agoFill NVMe specific path info
Keith Busch [Tue, 21 Feb 2017 22:12:31 +0000 (17:12 -0500)]
Fill NVMe specific path info

Signed-off-by: Keith Busch <keith.busch@intel.com>
12 hours agoDon't blacklist nvme
Keith Busch [Tue, 14 Feb 2017 21:19:13 +0000 (16:19 -0500)]
Don't blacklist nvme

These devices are mulitpath capable, and have been able to stack with
dm-mpath since kernel 4.2.

Signed-off-by: Keith Busch <keith.busch@intel.com>
12 hours agomultipath-tools: fix misspellings
Xose Vazquez Perez [Thu, 16 Feb 2017 19:23:08 +0000 (20:23 +0100)]
multipath-tools: fix misspellings

debuging->debugging

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
12 hours agomultipath-tools: git should ignore rej and orig files
Xose Vazquez Perez [Thu, 16 Feb 2017 19:23:07 +0000 (20:23 +0100)]
multipath-tools: git should ignore rej and orig files

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 weeks agoInclude sys/sysmacros.h
Anthony Ryan [Wed, 4 Jan 2017 04:34:53 +0000 (23:34 -0500)]
Include sys/sysmacros.h

The major, minor & makedev macros are not supposed to be included
with sys/types.h but glibc has done this against POSIX standards.

Alternative libcs aren't able to be used because of this and glibc
has expressed interest in correcting this behaviour in a future
release.

2 weeks agoTolerate modprobe failures in multipathd.service
Anthony Ryan [Thu, 5 Jan 2017 13:33:10 +0000 (08:33 -0500)]
Tolerate modprobe failures in multipathd.service

When these modules are built statically into the kernel, modprobe
will fail and prevent the service from being started. By making this
line non-fatal, on such systems the service is still able to be
started.

2 weeks agomultipath-tools: Remove trailing and leading whitespaces
Xose Vazquez Perez [Fri, 10 Feb 2017 13:43:59 +0000 (14:43 +0100)]
multipath-tools: Remove trailing and leading whitespaces

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 weeks agomultipath-tools: Perform socket client uid check on IPC commands.
Gris Ge [Fri, 20 Jan 2017 13:39:02 +0000 (21:39 +0800)]
multipath-tools: Perform socket client uid check on IPC commands.

Problem:
    A non-root user could send and execute 'shutdown' IPC command to
    multipathd.

Fix:
    Use getsockopt() to find out socket client uid, only query (list or
    show) command are allowed for non-root(uid != 0) socket connection.
    An error message "permission deny: need to be root" will be sent
    otherwise.

Signed-off-by: Gris Ge <fge@redhat.com>
2 weeks agomultipath-tools: Set errno mpath_recv_reply() when failure
Gris Ge [Fri, 20 Jan 2017 13:39:01 +0000 (21:39 +0800)]
multipath-tools: Set errno mpath_recv_reply() when failure

Enforce what mpath_cmd.h states "-1 on failure (with errno set)" for
mpath_recv_reply() by set errno and return -1 on failure.

Signed-off-by: Gris Ge <fge@redhat.com>
2 weeks agomultipath-tools: New way to limit the IPC command length.
Gris Ge [Fri, 20 Jan 2017 13:39:00 +0000 (21:39 +0800)]
multipath-tools: New way to limit the IPC command length.

Problem:

    mpath_recv_reply() from libmpathcmd return -EINVAL on command 'show
    maps json' with 2k paths.  No error will be triggered for command
    `multipathd -k'show maps json` as multipathd is using their own
    implementation on recv_packet() which does not have size limitation.

Root cause:

    Commit 174e717d351789a3cb29e1417f8e910baabcdb16 introduced the
    limitation on max bytes(65535) of reply string from multipathd.
    With 2k paths(1k mpaths) simulated by scsi_debug, the 'show maps json'
    requires 2066784 bytes which trigged the EINVAL error.

Fix:
    * Remove the limitation of MAX_REPLY_LEN in libmpathcmd.

    * New functions `recv_packet_from_client()` in uxsock.h of libmultipath
      which enforce the limitation of buffer size to 512(_MAX_CMD_LEN).

    * Change multipathd socket listener to use
      `recv_packet_from_client()`.

Signed-off-by: Gris Ge <fge@redhat.com>
2 weeks agomultipath-tools: libmultipath: Removed unused functions.
Gris Ge [Fri, 20 Jan 2017 13:38:59 +0000 (21:38 +0800)]
multipath-tools: libmultipath: Removed unused functions.

 * Removed these unused functions from libmultipath:
    * write_all()
    * read_all()

Signed-off-by: Gris Ge <fge@redhat.com>
2 weeks agomultipath-tools: libmultipath: fix gcc link failure on rcu_register_thread_mb.
Gris Ge [Fri, 20 Jan 2017 13:38:58 +0000 (21:38 +0800)]
multipath-tools: libmultipath: fix gcc link failure on rcu_register_thread_mb.

Error:
    ../libmultipath/libmultipath.so: undefined reference to
    `rcu_register_thread_mb'
    ../libmultipath/libmultipath.so: undefined reference to
    `rcu_unregister_thread_mb'

Fix:
    Link the libmultipath with -lurcu

Signed-off-by: Gris Ge <fge@redhat.com>
2 weeks agomultipath-tools: multipathd: Fix memory leak on load_config().
Gris Ge [Sun, 22 Jan 2017 07:14:55 +0000 (15:14 +0800)]
multipath-tools: multipathd: Fix memory leak on load_config().

 * Just free_config() before exit.

Signed-off-by: Gris Ge <fge@redhat.com>
2 weeks ago[multipathd] Remove trailing whitespaces
Christophe Varoqui [Fri, 10 Feb 2017 08:54:01 +0000 (09:54 +0100)]
[multipathd] Remove trailing whitespaces

2 weeks agomultipathd: deterministic io throughput in multipath
Muneendra Kumar M [Mon, 6 Feb 2017 06:21:37 +0000 (06:21 +0000)]
multipathd: deterministic io throughput in multipath

This patch adds three configuration parameters, "san_path_err_threshold",
"san_path_err_recovery_time" and "san_path_err_forget_rate".
multipathd will watch paths and check how many times a path has been failed due
to errors.If the number of failures on a particular path is greater then the
san_path_err_threshold then the path will not  reinstante till
san_path_err_recovery_time.These path failures should occur within a
san_path_err_forget_rate checks, if not we will consider the path is good enough
to reinstate.If it is the only available path, it will immediately be
reintegrated.

This helps us to place the path in failed state if we hit lot of errors on a particular path
due to network /target issues and allow the admin to rectify the errors on a path.

Signed-off-by: M Muneendra Kumar <mmandala@brocade.com>
2 months agomultipath-tools: remove old multipath/{01_udev,02_multipath} scripts
Xose Vazquez Perez [Thu, 15 Dec 2016 14:47:44 +0000 (15:47 +0100)]
multipath-tools: remove old multipath/{01_udev,02_multipath} scripts

Irrelevant nowadays.

2 months agolibmultipath: move filter_property|devnode() from path_discover() into pathinfo()
Mauricio Faria de Oliveira [Wed, 14 Dec 2016 13:05:30 +0000 (11:05 -0200)]
libmultipath: move filter_property|devnode() from path_discover() into pathinfo()

The udev property blacklisting is ignored on 'add' uevents
because uev_add_path() calls pathinfo() directly - but the
filter_property() check is only performed in path_discover().

So, move the call out from path_discover() into pathinfo().
While in there, do that for filter_devnode() too.

Since path_discover() always calls pathinfo() to return,
either directly or via store_pathinfo(), the change is
equivalent for callers of path_discover(), which turns
out to be only path_discovery().

Interestingly, multipathd calls path_discovery() without
DI_BLACKLIST and then calls filter_path() to remove paths.
Thus, in order to guarantee equivalency (and prevent lots
of more debug messages for discovery of devices that will
be removed afterward), perform filter_property|devnode()
without checking for DI_BLACKLIST; and make sure that
filter_path() checks filter_property() (it already checks
filter_devnode()).

Test-case:

  # cat /etc/multipath.conf
  blacklist {
      property "ID_SERIAL"
  }

  # multipathd -d -s -v3 &
  ...
  sdb: udev property ID_SERIAL blacklisted
  ...

  # echo add > /sys/block/sdb/uevent

Before:

  uevent 'add' from '/devices/.../block/sdb'
  Forwarding 1 uevents
  sdb: add path (uevent)
  ...
  0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1: load table [0 4194304 multipath 1
  retain_attached_hw_handler 0 1 1 service-time 0 1 1 8:16 1]
  ...
  sdb [8:16]: path added to devmap 0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1

After:

  uevent 'add' from '/devices/.../block/sdb'
  Forwarding 1 uevents
  sdb: add path (uevent)
  sdb: udev property ID_SERIAL blacklisted

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Reported-by: Benjamin Marzinski <bmarzins@redhat.com>
Reported-by: Hannes Reinecke <hare@suse.de>
2 months agolibmultipath: prevent memory leak in alloc_path_with_pathinfo() if pp_ptr is NULL
Mauricio Faria de Oliveira [Wed, 14 Dec 2016 13:05:29 +0000 (11:05 -0200)]
libmultipath: prevent memory leak in alloc_path_with_pathinfo() if pp_ptr is NULL

In alloc_path_with_pathinfo(), if the 'pp_ptr' argument is NULL
(which is acceptable and checked in the function in two places)
the 'pp' pointer is lost as it is not referenced anywhere else;
thus the memory allocated for it is leaked.

So, call free_path() in the case 'pp_ptr' is NULL too.

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
2 months agomultipathd: skip spurious event message for blacklisted paths
Mauricio Faria de Oliveira [Wed, 14 Dec 2016 13:05:31 +0000 (11:05 -0200)]
multipathd: skip spurious event message for blacklisted paths

Currently, multipath still prints the 'spurious uevent, path not found'
message if a path is blacklisted by something different than a devnode
in the 'change' uevent handling. (uev_trigger() calls filter_devnode()).

Thus blacklisting by vendor/product, wwid, and udev property still get
that message in the system log for paths that are explicitly marked to
be ignored (since it's verbosity level 0).

This problem happens on common scenarios such as creating filesystems
on a blacklisted device (e.g., mkfs.* /dev/sdX), which is usually run
several times on test environments, and the error message may mislead
the error checker/monitor tools with false negatives.

This patch resolves it by checking alloc_path_with_pathinfo()/pathinfo()
for PATHINFO_SKIPPED with just enough device information flags for
blacklist verification -- and it prints a debug message (verbosity
level 3) instead of an error message since this case is not an error.

Even though this introduces a bit of overhead (to get the path info),
it only happens in a corner case of an error path; so, not a problem.

Test-cases (on QEMU):
----------

Several versions of /etc/multipath.conf:

  blacklist {
      devnode "sdb"
  }

  blacklist {
      property "ID_SERIAL"
  }

  blacklist {
      wwid "0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1"
  }

  blacklist {
      device {
          vendor "QEMU"
      }
  }

Either command can be used to generate a 'change' uevent:

  # echo change > /sys/block/sdb/uevent

  # mkfs.ext3 -F /dev/sdb

The output of multipathd is monitored with:

  # multipathd -d -s
  ...

Without the patch, only the devnode blacklisting is silent;
all other cases (property, wwid, device) print the message:

  sdb: spurious uevent, path not found

With the patch applied, no message is printed by default
(that is, verbosity level 2) in any case.

With verbosity level 3 (debug), the following messages
are printed, according to the performed test-case:

  uevent 'change' from '/devices/.../block/sdb'
  Forwarding 1 uevents
  < and either of >

  sdb: device node name blacklisted

  sdb: udev property ID_SERIAL blacklisted
  sdb: spurious uevent, path is blacklisted

  sdb: wwid 0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1 blacklisted
  sdb: spurious uevent, path is blacklisted

  (null): (QEMU:QEMU HARDDISK) vendor/product blacklisted
  sdb: spurious uevent, path is blacklisted

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Reported-by: Yueh Chyong (Ida) Jackson <idaj@us.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
2 months agomultipath-tools: add .skip_kpartx and .max_sectors_kb to template in hwtable
Xose Vazquez Perez [Thu, 8 Dec 2016 21:45:00 +0000 (22:45 +0100)]
multipath-tools: add .skip_kpartx and .max_sectors_kb to template in hwtable

Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: replace multipath configuration output
Xose Vazquez Perez [Thu, 24 Nov 2016 22:44:27 +0000 (23:44 +0100)]
multipath-tools: replace multipath configuration output

sysfs setting           -> setting: kernel sysfs

detected setting        -> setting: array autodetected

controller setting      -> setting: array configuration

internal default        -> setting: multipath internal

overrides setting       -> setting: multipath.conf overrides section

LUN setting             -> setting: multipath.conf multipaths section

config file default
config file setting     -> setting: multipath.conf defaults/devices section

Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: Add -Werror compilation flags
Xose Vazquez Perez [Tue, 6 Dec 2016 01:26:27 +0000 (02:26 +0100)]
multipath-tools: Add -Werror compilation flags

Add -Werror=format-security: GCC will refuse to compile code that could be
vulnerable to a string format security flaw. At present, this warns about
calls to "printf" and "scanf" from untrusted input and contains %n.

Add -Werror=implicit-function-declaration: Implicit function declarations
allows a programmer to call functions without declaring them (or including the
relevant header files). The official C language specification has not supported
implicit function declarations for almost two decades now. GCC still supports
them as a GNU extension. Implicit function declarations introduce bugs because
these functions use a different calling convention and have a fixed return type
of int. Resulting issues are pointer truncation (on 64-bit architectures),
exposure of padding bits (particular for bool-returning functions on x86_64),
and unexpected lack of hardening. Implicit function declarations are not part of
C++ (with or without GNU extensions), and adjusting C code accordingly
simplifies reuse in C++ projects.

Add -Werror=implicit-int: Implicit ints were removed from the C programming
language at the same time as implicit function definitions, and were also
retained as a GNU extension. Implicit ints are usually source code bugs, and the
presence of such code may interfere with future C language directions (for
example, consider how C++ reused the auto keyword and an omitted type
specifier).

These flags are used by default in Fedora. More info:
https://fedoraproject.org/wiki/Changes/FormatSecurity
https://fedoraproject.org/wiki/Format-Security-FAQ
https://fedoraproject.org/wiki/Changes/Fedora26CFlags

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: Replace -fstack-protector with -fstack-protector-strong
Xose Vazquez Perez [Tue, 6 Dec 2016 01:26:26 +0000 (02:26 +0100)]
multipath-tools: Replace -fstack-protector with -fstack-protector-strong

-fstack-protector-strong
    Like -fstack-protector but includes additional functions to be protected
    --- those that have local array definitions, or have references to local
    frame addresses.

gcc-4.9.0(April 22, 2014) required.

This flag is used by default in Fedora:
https://pagure.io/fesco/issue/1128

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: remove CFLAGS from shared libs compilation options
Xose Vazquez Perez [Mon, 5 Dec 2016 22:39:08 +0000 (23:39 +0100)]
multipath-tools: remove CFLAGS from shared libs compilation options

Changed from:
cc  -shared -Wl,-soname=libmpathcmd.so.0 -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -o libmpathcmd.so.0 mpath_cmd.o
cc  -shared -Wl,-soname=libmultipath.so.0 -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmpathcmd -DUSE_SYSTEMD=231 -DLIBDM_API_FLUSH -D_GNU_SOURCE -DLIBDM_API_COOKIE -DLIBUDEV_API_RECVBUF -DLIBDM_API_DEFERRED -o libmultipath.so.0 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 pgpolicies.o debug.o defaults.o uevent.o time-util.o switchgroup.o uxsock.o print.o alias.o log_pthread.o log.o configure.o structs_vec.o sysfs.o prio.o checkers.o lock.o waiter.o file.o wwids.o prioritizers/alua_rtpg.o -lpthread -ldl -ldevmapper -ludev -L../libmpathcmd -lmpathcmd -lsystemd
cc  -shared -lpthread -ldevmapper -ldl -L../libmultipath -lmultipath -L../libmpathcmd -lmpathcmd -Wl,-soname=libmpathpersist.so.0 -O2 -g -pipe -Wall -Wextra -Wformat=2 -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathpersist -I../libmpathcmd -o libmpathpersist.so.0 mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o

To:
cc  -shared -Wl,-soname=libmpathcmd.so.0 -o libmpathcmd.so.0 mpath_cmd.o
cc  -shared -Wl,-soname=libmultipath.so.0 -o libmultipath.so.0 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 pgpolicies.o debug.o defaults.o uevent.o time-util.o switchgroup.o uxsock.o print.o alias.o log_pthread.o log.o configure.o structs_vec.o sysfs.o prio.o checkers.o lock.o waiter.o file.o wwids.o prioritizers/alua_rtpg.o -lpthread -ldl -ldevmapper -ludev -L../libmpathcmd -lmpathcmd -lsystemd
cc  -shared -lpthread -ldevmapper -ldl -L../libmultipath -lmultipath -L../libmpathcmd -lmpathcmd -Wl,-soname=libmpathpersist.so.0 -o libmpathpersist.so.0 mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o

Cc: Bart Van Assche <Bart.VanAssche@sandisk.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: minor edition of multipath/multipath.conf.5
Xose Vazquez Perez [Sun, 27 Nov 2016 16:23:42 +0000 (17:23 +0100)]
multipath-tools: minor edition of multipath/multipath.conf.5

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: document exclusive_pref_bit for sysfs
Xose Vazquez Perez [Sun, 27 Nov 2016 14:13:06 +0000 (15:13 +0100)]
multipath-tools: document exclusive_pref_bit for sysfs

Cc: Hannes Reinecke <hare@suse.de>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: replace "Default value" with "The default" in multipath/multipath...
Xose Vazquez Perez [Sun, 27 Nov 2016 14:07:51 +0000 (15:07 +0100)]
multipath-tools: replace "Default value" with "The default" in multipath/multipath.conf.5

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: add Nexsan NST and UNITY families to hwtable
Xose Vazquez Perez [Sat, 26 Nov 2016 02:37:58 +0000 (03:37 +0100)]
multipath-tools: add Nexsan NST and UNITY families to hwtable

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: fix misspellings
Xose Vazquez Perez [Sat, 26 Nov 2016 01:33:49 +0000 (02:33 +0100)]
multipath-tools: fix misspellings

Done with https://github.com/lucasdemarchi/codespell

multipath-tools/kpartx/dasd.c:263: formated  ==> formatted
multipath-tools/libmultipath/discovery.c:1808: unuseable  ==> unusable
multipath-tools/libmultipath/discovery.h:20: exerpt  ==> excerpt
multipath-tools/libmultipath/memory.c:150: formated  ==> formatted
multipath-tools/libmultipath/checkers/directio.c:84: Sucessfully  ==> Successfully
multipath-tools/libmultipath/prioritizers/hds.c:9: pathes  ==> paths
multipath-tools/libmultipath/prioritizers/hds.c:14: pathes  ==> paths
multipath-tools/libmultipath/prioritizers/ontap.c:119: Retuns  ==> Returns
multipath-tools/third-party/valgrind/valgrind.h:6828: arbitary  ==> arbitrary
multipath-tools/multipath/02_multipath:11: dynamicaly  ==> dynamically
multipath-tools/multipath/multipath.conf.5:793: remeber  ==> remember
multipath-tools/libmpathpersist/mpath_persist.h:15: lenght  ==> length

-------8<-------
SUMMARY:
arbitary      1
dynamicaly    1
exerpt        1
formated      2
lenght        1
pathes        2
remeber       1
retuns        1
sucessfully   1
unuseable     1

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agolibmultipath: ensure dev_loss_tmo will be update to MAX_DEV_LOSS_TMO if no_path_retry...
PengLiang [Fri, 25 Nov 2016 06:36:04 +0000 (14:36 +0800)]
libmultipath: ensure dev_loss_tmo will be update to MAX_DEV_LOSS_TMO if no_path_retry set to queue

If no_path_retry set to queue, we should make sure dev_loss_tmo update to MAX_DEV_LOSS_TMO.
But, it will be limit to 600 if fast_io_fail_tmo set to off or 0 meanwhile.

Signed-off-by: PengLiang <peng.liang5@zte.com.cn>
3 months agomultipath-tools: identify DataCore SANsymphony in hwtable
Xose Vazquez Perez [Tue, 22 Nov 2016 20:05:16 +0000 (21:05 +0100)]
multipath-tools: identify DataCore SANsymphony in hwtable

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: convert Promise/VTrak to ALUA
Xose Vazquez Perez [Mon, 21 Nov 2016 22:17:26 +0000 (23:17 +0100)]
multipath-tools: convert Promise/VTrak to ALUA

It's also supported.

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: add Promise/Vess to hwtable
Xose Vazquez Perez [Mon, 21 Nov 2016 22:17:25 +0000 (23:17 +0100)]
multipath-tools: add Promise/Vess to hwtable

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: remove NO_PATH_RETRY_FAIL from hwtable
Xose Vazquez Perez [Mon, 21 Nov 2016 11:39:31 +0000 (12:39 +0100)]
multipath-tools: remove NO_PATH_RETRY_FAIL from hwtable

It's the default value.

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: enable exec bit for kpartx/kpartx_id script
Xose Vazquez Perez [Sun, 20 Nov 2016 20:56:01 +0000 (21:56 +0100)]
multipath-tools: enable exec bit for kpartx/kpartx_id script

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agoMakefiles: Fix function availability checks
Bart Van Assche [Fri, 18 Nov 2016 19:52:31 +0000 (11:52 -0800)]
Makefiles: Fix function availability checks

The current implementation of the code that checks for function
presence is not correct because it checks for a prefix match only.
Introduce a function that checks for the exact function name.
Additionally, report whether or not the function has been found.
An example of the output produced by this function if 'make' is
run:

Checking for dm_task_no_flush in /usr/include/libdevmapper.h ... yes
Checking for dm_task_set_cookie in /usr/include/libdevmapper.h ... yes
Checking for udev_monitor_set_receive_buffer_size in /usr/include/libudev.h ... yes
Checking for dm_task_deferred_remove in /usr/include/libdevmapper.h ... yes

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: remove unnecessary condition in checker_repair
PengLiang [Mon, 7 Nov 2016 08:57:35 +0000 (16:57 +0800)]
libmultipath: remove unnecessary condition in checker_repair

The checker's validity is an unnecessary checking. It will be checked in checker_selected.

Signed-off-by: PengLiang <peng.liang5@zte.com.cn>
3 months agolibmultipath: fix missing dm_task_destroy() in dm_reassign()
zhou.guichun [Mon, 7 Nov 2016 02:01:17 +0000 (10:01 +0800)]
libmultipath: fix missing dm_task_destroy() in dm_reassign()

dm_task should be destoryed before going out of dm_reassign()

Signed-off-by: zhou.guichun <zhou.guichun@zte.com.cn>
3 months agoRemove 2 more "extern" in libmultipath/devmapper.c
Christophe Varoqui [Sun, 20 Nov 2016 13:31:16 +0000 (14:31 +0100)]
Remove 2 more "extern" in libmultipath/devmapper.c

Those two were rejected by Bart's previous patch merge.

3 months agoRemove superfluous instances of the "extern" keyword
Bart Van Assche [Fri, 18 Nov 2016 20:50:37 +0000 (12:50 -0800)]
Remove superfluous instances of the "extern" keyword

This avoids that the sparse static analyzer complains about
the "extern" keyword.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agomultipath-tools: update bl info for nvme in multipath.conf.5
Xose Vazquez Perez [Wed, 16 Nov 2016 16:20:21 +0000 (17:20 +0100)]
multipath-tools: update bl info for nvme in multipath.conf.5

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: merge nvme in similar blacklist regex
Xose Vazquez Perez [Wed, 16 Nov 2016 16:13:25 +0000 (17:13 +0100)]
multipath-tools: merge nvme in similar blacklist regex

Similar patterns, /dev/nvme[0-9] .

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agoadd "max_sectors_kb" config parameter
Benjamin Marzinski [Fri, 11 Nov 2016 22:58:23 +0000 (16:58 -0600)]
add "max_sectors_kb" config parameter

This patch adds the "max_sectors_kb" parameter to all multipath.conf
sections. Setting this will cause multipath to set the max_sectors_kb
queue parameter to the specified value on all of the paths before
creating the multipath device, which will inherit the value from the
paths.

If max_sectors_kb is out of sync between the multipath device and the
path devices, it's possible for multpiath to send down a request that is
too large for the path to handle.  When devices are discovered,
multipathd automatically sets up multipath devices on top of them. LVM
and filesystems can get mounted on top of that.  This means that users
who what to modify max_sectors_kb manually, may have to do it after
these devices are already in use.  This config option lets them simply
have multipath set up the values before creating the device.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agoallow multipath to retry removes of in-use devices
Benjamin Marzinski [Fri, 11 Nov 2016 22:58:22 +0000 (16:58 -0600)]
allow multipath to retry removes of in-use devices

Occasionally, a multipath device is temporarily opened by things like
udev. This can cause the multipath flush commands to fail. While it is
possible to simply rerun the command, it can be very annoying for
scripts that are working with multipath devices. To deal with that,
it is now possible to tell multipath to retry failed removes. Either
running multipath with "-R <num>" or setting "remove_retries <num>"
in /etc/multipath.conf will make multipath retry failed removes
the specified number of times, with a 1 second delay between tries.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agodocument "disable_changed_wwids" config parameter
Benjamin Marzinski [Fri, 11 Nov 2016 22:58:21 +0000 (16:58 -0600)]
document "disable_changed_wwids" config parameter

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agomultipath-tools: increase the print length of the multipath fields
tang.wenji [Thu, 10 Nov 2016 12:32:01 +0000 (20:32 +0800)]
multipath-tools: increase the print length of the multipath fields

The maximum field length is set to 64, which may be truncated when
displayed.
E.g:the multipath's 'features' field sets as "6 queue_if_no_path
pg_init_retries 3 pg_init_delay_msecs 30 retain_attached_hw_handler",  but
it shows as "6 queue_if_no_path pg_init_retries 3 pg_init_delay_msecs 30 ret" .

Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
3 months agomultipath-tools: remove Pure modifications
Xose Vazquez Perez [Mon, 7 Nov 2016 14:40:32 +0000 (15:40 +0100)]
multipath-tools: remove Pure modifications

There is no reason to deviate from standard values.

Default:
 .fast_io_fail = 5
 .dev_loss  = 600

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agompathpersistent: segment faulty occured in mpath_persistent_reserve_in()
tang.wenji [Mon, 7 Nov 2016 06:35:16 +0000 (14:35 +0800)]
mpathpersistent: segment faulty occured in mpath_persistent_reserve_in()

Segment faulty occured when executing "mpathpersist -i -k
    /dev/mapper/mpath1" command.The reason is that an uninitialized global
    variable conf is used in mpath_persistent_reserve_in(). The same
    problem also exists in mpath_persistent_reserve_out().

Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
3 months agomultipath-tools: Remove trailing whitespace
Xose Vazquez Perez [Sat, 5 Nov 2016 16:58:32 +0000 (17:58 +0100)]
multipath-tools: Remove trailing whitespace

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: fix indent and replace spaces with tab
Xose Vazquez Perez [Sat, 5 Nov 2016 10:50:46 +0000 (11:50 +0100)]
multipath-tools: fix indent and replace spaces with tab

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: remove getuid/usb_id
Xose Vazquez Perez [Fri, 4 Nov 2016 23:24:14 +0000 (00:24 +0100)]
multipath-tools: remove getuid/usb_id

Unnecessary, because getuid_callout was superseded by uid_attribute.

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agolibmultipath/checkers/rbd: fix free in libcheck_init
PengLiang [Fri, 4 Nov 2016 07:54:29 +0000 (15:54 +0800)]
libmultipath/checkers/rbd: fix free in libcheck_init

There is an incorrect free maybe causing memory leak.

Signed-off-by: PengLiang <peng.liang5@zte.com.cn>
3 months agomultipath-tools:replace the "strict_timinig" with "strict_timing"
li.minghui [Fri, 4 Nov 2016 03:26:54 +0000 (11:26 +0800)]
multipath-tools:replace the "strict_timinig" with "strict_timing"

multipath-tools:replace the "strict_timinig" with "strict_timing"

3 months agoBump version to 0.6.4 0.6.4
Christophe Varoqui [Thu, 3 Nov 2016 13:54:38 +0000 (14:54 +0100)]
Bump version to 0.6.4

3 months agoFix trailing whitespace in mpathpersist/main.c
Christophe Varoqui [Thu, 3 Nov 2016 13:47:03 +0000 (14:47 +0100)]
Fix trailing whitespace in mpathpersist/main.c

3 months agompathpersist:check variable 'conf' before using it
tang.wenji [Thu, 3 Nov 2016 03:32:15 +0000 (11:32 +0800)]
mpathpersist:check variable 'conf' before using it

If the variable 'conf' is NULL, the program should exit.

Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
3 months agomultipathd: remove unnecessary condition in check_path
PengLiang [Tue, 1 Nov 2016 08:14:31 +0000 (16:14 +0800)]
multipathd: remove unnecessary condition in check_path

The pp->mpp is an unnecessary condition. It will be return before this condition
if pp->mpp is NULL.

Signed-off-by: PengLiang <peng.liang5@zte.com.cn>
3 months agohwe_regmatch: match error
wei.huang [Fri, 14 Oct 2016 02:03:51 +0000 (10:03 +0800)]
hwe_regmatch: match error

Problem:
when we configure a device like vendor, product, revision all null in multipath.conf, hwe_regmatch always return 0.

Reasons:
\!hwe2->vendor, \!hwe2->product and \!hwe2->revision are all true.

Signed-off-by: wei.huang <huang.wei56@zte.com.cn>
3 months agoFix trailing whitespace in structs.c
Christophe Varoqui [Thu, 3 Nov 2016 13:42:48 +0000 (14:42 +0100)]
Fix trailing whitespace in structs.c

3 months agosegment faulty occured in add_feature()
wei huang [Tue, 1 Nov 2016 00:44:49 +0000 (08:44 +0800)]
segment faulty occured in add_feature()

Problem:
Multipathd segment faulty occured when device policy was configured in multipath.conf as follow:
#This is a device configuration just for COMPELNT device
devices {
       device {
               vendor                  COMPELNT
               dev_loss_tmo            120
               scheduler               deadline
       }
}

The call trace is:
Program received signal SIGSEGV, Segmentation fault.
0x00007f4eaaf49251 in __strstr_sse2 () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4eaaf49251 in __strstr_sse2 () from /lib64/libc.so.6
#1  0x00007f4eabba879c in add_feature (f=f@entry=0x211b248, n=n@entry=0x7f4eabbc530a queue_if_no_path)
    at structs.c:524
#2  0x00007f4eabba6993 in merge_hwe (src=0x2148c70, dst=0x211b220) at config.c:359
#3  factorize_hwtable (hw=0x214b800, n=n@entry=77) at config.c:452
#4  0x00007f4eabba7850 in load_config (file=file@entry=0x4144c8 /etc/multipath.conf) at config.c:651
#5  0x0000000000408959 in reconfigure (vecs=vecs@entry=0x2128ae0) at main.c:2078
#6  0x00000000004063c6 in child (param=0x0) at main.c:2483
#7  main (argc=<optimized out>, argv=<optimized out>) at main.c:2725
(gdb) up
#1  0x00007f4eabba879c in add_feature (f=f@entry=0x211b248, n=n@entry=0x7f4eabbc530a queue_if_no_path)
    at structs.c:524
524             if (strstr(*f, n))
(gdb) p *f
 = 0x0

Reasons:
When multipathd loads config, it will call merge_hwe() to merge the features between default_hw[] and config.
If the vender is not configured features in default_hw[], dst->features's value will be null. So strstr()'s first
parameter *f is null in add_feature(),too.

Signed-off-by: wei huang <huang.wei56@zte.com.cn>
3 months agokpartx: Move the declaration of a global variable from .c to .h
Bart Van Assche [Fri, 21 Oct 2016 18:46:58 +0000 (11:46 -0700)]
kpartx: Move the declaration of a global variable from .c to .h

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath/checkers: Make the compiler check the checker function prototypes
Bart Van Assche [Fri, 21 Oct 2016 18:46:36 +0000 (11:46 -0700)]
libmultipath/checkers: Make the compiler check the checker function prototypes

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath/prioritizers: Make getprio() prototypes consistent
Bart Van Assche [Fri, 21 Oct 2016 18:46:19 +0000 (11:46 -0700)]
libmultipath/prioritizers: Make getprio() prototypes consistent

Additionally, ensure that the compiler checks the getprio()
prototype.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agoUse NULL instead of 0 where a pointer is expected
Bart Van Assche [Fri, 21 Oct 2016 18:45:54 +0000 (11:45 -0700)]
Use NULL instead of 0 where a pointer is expected

This was detected by sparse.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmpathpersist: Move the definition of a global variable from .h to .c
Bart Van Assche [Fri, 21 Oct 2016 18:45:32 +0000 (11:45 -0700)]
libmpathpersist: Move the definition of a global variable from .h to .c

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Move the definition of a global variable from .h to .c
Bart Van Assche [Fri, 21 Oct 2016 18:44:58 +0000 (11:44 -0700)]
libmultipath: Move the definition of a global variable from .h to .c

This change does not change the semantics of the code but makes
it easier for sparse to analyze the source code.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath/checkers/rbd: Use unsigned int for one-bit bitfields
Bart Van Assche [Fri, 21 Oct 2016 18:44:31 +0000 (11:44 -0700)]
libmultipath/checkers/rbd: Use unsigned int for one-bit bitfields

Avoid that this bitfield is sign-extended. Detected by sparse.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Remove an unused variable
Bart Van Assche [Fri, 21 Oct 2016 18:44:08 +0000 (11:44 -0700)]
libmultipath: Remove an unused variable

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmpathpersist: Remove an unused function
Bart Van Assche [Fri, 21 Oct 2016 18:43:50 +0000 (11:43 -0700)]
libmpathpersist: Remove an unused function

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Remove an unused function
Bart Van Assche [Fri, 21 Oct 2016 18:43:31 +0000 (11:43 -0700)]
libmultipath: Remove an unused function

The function snprint_config() is not used. Hence remove it.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Fix POLLIN checks
Bart Van Assche [Fri, 21 Oct 2016 18:43:11 +0000 (11:43 -0700)]
libmultipath: Fix POLLIN checks

Instead of testing (pfd.revents == 0) & 1, test whether
(pfd.revents & 1) == 0.

This has been detected by the sparse static analyzer.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Move setup_thread_attr() from uevent.c into util.c
Bart Van Assche [Fri, 21 Oct 2016 18:42:42 +0000 (11:42 -0700)]
libmultipath: Move setup_thread_attr() from uevent.c into util.c

The setup_thread_attr() is not called by any code in source file
uevent.c. Hence move that function to source file util.c.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Remove an incorrect comment
Bart Van Assche [Fri, 21 Oct 2016 18:42:19 +0000 (11:42 -0700)]
libmultipath: Remove an incorrect comment

It is easy to see that uevq_lockp is not held while service_uevq()
is called. Since no other code accesses the list that is processed
by this function calling service_uevq() without holding uevq_lockp
is safe. Hence remove the comment about locking above service_uevq().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Avoid that thread cancellation causes a hang
Bart Van Assche [Fri, 21 Oct 2016 18:41:56 +0000 (11:41 -0700)]
libmultipath: Avoid that thread cancellation causes a hang

Apparently uevq_stop() hangs every now and then in pthread_mutex_lock()
if the udev listener thread is canceled. Avoid this hang by removing
code from uevq_stop(). This is safe because uevq_stop() is only called
just before uevent_listen() returns and in that case neither clearing
my_uev_trigger nor signaling uev_condp is needed. Additionally, rename
uevq_stop() into uevent_cleanup() to make clear that its purpose is to
clean up resources and not to stop the uevent listener.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Make building against musl-libc again possible
Bart Van Assche [Fri, 21 Oct 2016 18:41:12 +0000 (11:41 -0700)]
libmultipath: Make building against musl-libc again possible

musl-libc does not support PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP.

This patch reverts commit 7884bde302ad ("multipathd: Avoid that a
deadlock is triggered sporadically during shutdown").

Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agomultipathd: "show map mpathx json" would cause realloc error possibly
10144149 [Wed, 2 Nov 2016 01:41:17 +0000 (09:41 +0800)]
multipathd: "show map mpathx json" would cause realloc error possibly

Problem: multipathd dead when we run "show map mpathx json" command with
system messages as follows:
Oct 13 11:37:30 rhel7-1 multipathd: *** Error in `/sbin/multipathd': realloc(): invalid next size: 0x00007f8cf8004210 ***
Oct 13 11:37:30 rhel7-1 multipathd: ======= Backtrace: =========
Oct 13 11:37:30 rhel7-1 multipathd: /lib64/libc.so.6(+0x7bc67)[0x7f8d06171c67]
Oct 13 11:37:30 rhel7-1 multipathd: /lib64/libc.so.6(+0x7fb17)[0x7f8d06175b17]
Oct 13 11:37:30 rhel7-1 multipathd: /lib64/libc.so.6(realloc+0xd2)[0x7f8d06176702]

Reasons: in function snprint_multipath_fields_json
vector_foreach_slot (pgp->paths, pp, j) {
       fwd += snprint_path(buff + fwd, len - fwd, PRINT_JSON_PATH, pp, 0);
       if (fwd > len)
            return fwd;

       fwd += snprint_json_elem_footer(buff + fwd,
                len - fwd, 3, j + 1 == VECTOR_SIZE(pgp->paths));
       if (fwd > len)
           return fwd;
}

snprint_path (char * line, int len, char * format, struct path * pp, int pad)

when len - fwd = 0 , The len is not restricted in snprint_path,and the Memory of line is
rewritten in snprint_path, it cause realloc() failed , so fwd > len modify
fwd >= len.

consider of ben’s advice, It would probably also be smart to change all the
          if (!TAIL)
lines to
  if (TAIL <= 0)
just as an extra precaution.

Other commands also have this type of risk.

Signed-off-by: 10144149 <tang.wenjun3@zte.com.cn>
3 months agomultipath-tools: clean up and organize libmpathpersist/mpath_persistent_reserve_...
Xose Vazquez Perez [Tue, 1 Nov 2016 12:48:56 +0000 (13:48 +0100)]
multipath-tools: clean up and organize libmpathpersist/mpath_persistent_reserve_{out,in}.3

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: clean up and organize mpathpersist/mpathpersist.8
Xose Vazquez Perez [Mon, 31 Oct 2016 17:18:28 +0000 (18:18 +0100)]
multipath-tools: clean up and organize mpathpersist/mpathpersist.8

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agoRemove duplicated code in mpath_alloc_prin_response()
ding.yemin [Mon, 31 Oct 2016 02:55:07 +0000 (10:55 +0800)]
Remove duplicated code in mpath_alloc_prin_response()

Remove duplicated code in mpath_alloc_prin_response().

Signed-off-by: ding.yemin <ding.yemin@zte.com.cn>
3 months agoset retrigger_tries to 0 for multipath
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:26 +0000 (21:55 -0500)]
set retrigger_tries to 0 for multipath

Multipathd uses retrigger_tries to give udev more chances to to fill in
the uid_attribute, so that the path device is correctly set up in the
udev database. However the multipath command can't do this, so it should
just immediately give up on udev, and try to get the wwid directly.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agoadd disable_changed_wwids option
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:25 +0000 (21:55 -0500)]
add disable_changed_wwids option

If a LUN on a storage device gets remapped while in-use by multipath,
it's possible that the multipath device will continue writing to this
new LUN, causing corruption.  This is not multipath's fault (users
should go remapping in-use LUNs), but it's possible for multipath to
detect this and disable IO to the device. If disable_changed_wwids
is set to "yes", multipathd will detect when a LUN changes wwids when it
receives the uevent for this, and will disable access to the device
until the LUN is mapped back.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agofix INIT_REQUESTED_UDEV code
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:24 +0000 (21:55 -0500)]
fix INIT_REQUESTED_UDEV code

uev_update_path was not checking pp->initialized to see if multipathd
had requested that the path be reinitialized unless the path's read-only
state had changed.  This kept the reinitialization code from running in
most cases where it was supposed to. This patch reorders the function to
move that check outside the read-only status change code block. This
does mean that uev_update_path now always grabs the vecs lock, where
before it would only be grabbed if the read-only status had changed. If
people are worried about this, I can add some code to limit this so that
uev_update_path will only grab it if there is a chance that it needs to
reinitialize the path.

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agorecover from errors in multipathd startup
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:23 +0000 (21:55 -0500)]
recover from errors in multipathd startup

When multipathd does it's initial configuration during startup, it fails
the daemon for many errors that it would simply recover from if they
occured when adding paths or maps later.  It should recover from these
errors during startup as well.  Also, if multipathd hits a
nonrecoverable error, it should log a message before quitting.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agomultipath: set cookie before using it.
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:22 +0000 (21:55 -0500)]
multipath: set cookie before using it.

dm_task_set_cookie() expects the cookie to be initialized when it is
called, but dm_rename() didn't initialized it, causing renames to fail
some of the time.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agompath: don't wait for udev if all paths are down
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:21 +0000 (21:55 -0500)]
mpath: don't wait for udev if all paths are down

Normally multipath waits for udev to create a device before adding
more paths, which could trigger a reload. But, if the first path
discovered is not usable, you should add the next path right away.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agomultipathd: add "map failures" format wildcard
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:20 +0000 (21:55 -0500)]
multipathd: add "map failures" format wildcard

This patch adds a new wildcard, 'x', for the "show maps format" command.
This wildcard show the number of map failures that have occurred. A map
failure is any time that the multipath device enters a state where it
has no paths and is not set to queue_if_no_paths. It can be used to see
if a multipath device was ever in a state were it could fail IO errors
up.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agodo not allow in-use path to change wwid
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:19 +0000 (21:55 -0500)]
do not allow in-use path to change wwid

When a path is part of a multipath device, it must not change it's wwid.
If it can, when multipathd is reconfigured, you can end up with two
multipath devices owning the same path, eventually leading to a crash.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agokpartx.rules: respect skip_kpartx flag
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:18 +0000 (21:55 -0500)]
kpartx.rules: respect skip_kpartx flag

Check if DM_SUBSYSTEM_UDEV_FLAG1 is set, and if so, don't run kpartx.
If the event was not generated by device-mapper, just use the existing
value of DM_SUBSYSTEM_UDEV_FLAG1.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agoFix a "space before tab in indent" warning
Christophe Varoqui [Thu, 3 Nov 2016 13:21:41 +0000 (14:21 +0100)]
Fix a "space before tab in indent" warning

3 months agolibmultipath: add skip_kpartx option
Benjamin Marzinski [Sat, 29 Oct 2016 02:55:17 +0000 (21:55 -0500)]
libmultipath: add skip_kpartx option

This option gives multipath the ability to stop kpartx from running. The
previous idea, the "no_partitions" feature, was not accepted in the
upstream kernel. This method uses one of the dm cookie subsystem flags
DM_SUBSYSTEM_UDEV_FLAG1, which can be checked by udev to skip running
kpartx when processing the event. This patch does most of the work
necessary to make this work.  It doesn't change kpartx.rules, however.

Also, if dm_suspend_and_flush_map fails, multipath doesn't know how the
device is configured. so, it simply checks if the device has any
partitions before attempting the remove, and if not, sets the
DM_SUBSYSTEM_UDEV_FLAG1 on the resume after failure, so that no
partitions will be generated.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agomultipath-tools: clean up and organize kpartx/kpartx.8
Xose Vazquez Perez [Fri, 28 Oct 2016 14:47:52 +0000 (16:47 +0200)]
multipath-tools: clean up and organize kpartx/kpartx.8

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: clean up and organize multipathd/multipathd.8
Xose Vazquez Perez [Fri, 28 Oct 2016 13:48:46 +0000 (15:48 +0200)]
multipath-tools: clean up and organize multipathd/multipathd.8

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: alua: replace lba state message
Xose Vazquez Perez [Thu, 27 Oct 2016 14:00:22 +0000 (16:00 +0200)]
multipath-tools: alua: replace lba state message

Change to "logical block dependent" as in spec.

Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: alua: add prefix with device name for asymmetric access state and...
Xose Vazquez Perez [Thu, 27 Oct 2016 13:21:10 +0000 (15:21 +0200)]
multipath-tools: alua: add prefix with device name for asymmetric access state and reported target port group messages

Before:
Oct 27 15:11:21 | reported target port group is 2
Oct 27 15:11:21 | aas = 01 [active/non-optimized]

After:
Oct 27 15:11:47 | sda: reported target port group is 2
Oct 27 15:11:47 | sda: aas = 01 [active/non-optimized]

Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: clean up and organize multipath/multipath.8
Xose Vazquez Perez [Thu, 27 Oct 2016 10:22:41 +0000 (12:22 +0200)]
multipath-tools: clean up and organize multipath/multipath.8

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>