multipath-tools/.git
3 days agoRevert "multipath-tools: arrange compilation options for binaries" master
Christophe Varoqui [Thu, 23 Mar 2017 09:07:44 +0000 (10:07 +0100)]
Revert "multipath-tools: arrange compilation options for binaries"

This reverts commit 324c3b960f361e2433874e5ed7f8f9125cce0b97.

If object or library AA needs a symbol from library BB, then AA
should come before library BB in the command-line invocation of the linker.

3 days agoRevert "multipath-tools: arrange compilation options for shared libs/objects"
Christophe Varoqui [Thu, 23 Mar 2017 09:07:09 +0000 (10:07 +0100)]
Revert "multipath-tools: arrange compilation options for shared libs/objects"

This reverts commit 2601add472837f9d0ba93271ac84c1ec8b4b4c43.

If object or library AA needs a symbol from library BB, then AA
should come before library BB in the command-line invocation of the linker.

3 days agomultipath-tools: arrange compilation options for shared libs/objects
Xose Vazquez Perez [Sat, 18 Mar 2017 17:45:00 +0000 (18:45 +0100)]
multipath-tools: arrange compilation options for shared libs/objects

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 days agomultipath-tools: arrange compilation options for binaries
Xose Vazquez Perez [Fri, 17 Mar 2017 22:40:02 +0000 (23:40 +0100)]
multipath-tools: arrange compilation options for binaries

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 days agomultipath-tools: build objects for libdmmp and libmpathpersist independently
Xose Vazquez Perez [Fri, 17 Mar 2017 15:21:46 +0000 (16:21 +0100)]
multipath-tools: build objects for libdmmp and libmpathpersist independently

libdmmp:
cc -c -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathpersist -I../libmpathcmd *.c
new:
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathpersist -I../libmpathcmd -c -o mpath_persist.o mpath_persist.c
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathpersist -I../libmpathcmd -c -o mpath_updatepr.o mpath_updatepr.c
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathpersist -I../libmpathcmd -c -o mpath_pr_ioctl.o mpath_pr_ioctl.c

libmpathpersist:
cc -c -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -fvisibility=hidden -I../libdmmp -I../libmpathcmd -I/usr/include/json-c -c *.c
new:
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -fvisibility=hidden -I../libdmmp -I../libmpathcmd -I/usr/include/json-c -c -o libdmmp.o libdmmp.c
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -fvisibility=hidden -I../libdmmp -I../libmpathcmd -I/usr/include/json-c -c -o libdmmp_mp.o libdmmp_mp.c
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -fvisibility=hidden -I../libdmmp -I../libmpathcmd -I/usr/include/json-c -c -o libdmmp_pg.o libdmmp_pg.c
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -fvisibility=hidden -I../libdmmp -I../libmpathcmd -I/usr/include/json-c -c -o libdmmp_path.o libdmmp_path.c
cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -fvisibility=hidden -I../libdmmp -I../libmpathcmd -I/usr/include/json-c -c -o libdmmp_misc.o libdmmp_misc.c

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 days agomultipath-tools: add missing "-l" flag for pthread in libdmmp/Makefile
Xose Vazquez Perez [Fri, 17 Mar 2017 14:15:23 +0000 (15:15 +0100)]
multipath-tools: add missing "-l" flag for pthread in libdmmp/Makefile

Cc: Gris Ge <fge@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>
3 days agomultipath-tools: Remove trailing whitespaces
Xose Vazquez Perez [Fri, 17 Mar 2017 00:35:03 +0000 (01:35 +0100)]
multipath-tools: Remove trailing 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>
3 days agoMake libdmmp build optional
Martin Wilck [Tue, 28 Feb 2017 16:23:29 +0000 (17:23 +0100)]
Make libdmmp build optional

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath/checkers: make RADOS checker optional
Martin Wilck [Tue, 28 Feb 2017 16:23:28 +0000 (17:23 +0100)]
libmultipath/checkers: make RADOS checker optional

Some distros lack the rados header files. Use
"make ENABLE_RADOS=0" on such distributions to build
multipath-tools in such cases. The default (to enable RADOS
support) remains unchanged.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agomultipathd: fixup check for new path states
Hannes Reinecke [Tue, 28 Feb 2017 16:23:27 +0000 (17:23 +0100)]
multipathd: fixup check for new path states

When testing for new path states we should be making sure to
always using the same path state mask. Otherwise we'll miss
out any states.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agotur: Add pthread_testcancel()
Hannes Reinecke [Tue, 28 Feb 2017 16:23:26 +0000 (17:23 +0100)]
tur: Add pthread_testcancel()

When the ioctl returns we need to check if a cancellation has
been requested; otherwise we'd be re-setting the state and
overwrite any pending values.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agokpartx: sanitize delete partitions
Hannes Reinecke [Tue, 28 Feb 2017 16:23:25 +0000 (17:23 +0100)]
kpartx: sanitize delete partitions

kpartx has a rather braindead method for deleting partitions;
generating 'possible' partition names and trying to remove all
of them.
With this patch kpartx looks at the device-mapper devices on top
of the referenced device, and removes them if they found to be
kpartx-generated devices.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agolibmultipath: coalesce_paths: trigger uevent if nothing done
Martin Wilck [Tue, 28 Feb 2017 16:23:24 +0000 (17:23 +0100)]
libmultipath: coalesce_paths: trigger uevent if nothing done

The previous patches skip RELOAD actions if there's nothing
to be done. I found a corner case where this may lead to imporperly
initialized device nodes (in my case a by-label link hadn't been
reset to the partition on the multipath device by udev).
Triggering an extra "change" event on the device fixes
this situation.

Signed-off-by: Martin Wilck <mwilck@suse.de>
3 days agolibmultipath: differentiate ACT_NOTHING and ACT_IMPOSSIBLE
Martin Wilck [Tue, 28 Feb 2017 16:23:23 +0000 (17:23 +0100)]
libmultipath: differentiate ACT_NOTHING and ACT_IMPOSSIBLE

select_action uses ACT_NOTHING for two different cases,
1) if changes can't be applied for some reason, and
2) if nothing needs to be done. Introduce ACT_IMPOSSIBLE
for case 1).

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: reload map if not known to udev
Martin Wilck [Tue, 28 Feb 2017 16:23:22 +0000 (17:23 +0100)]
libmultipath: reload map if not known to udev

The previous changes skip map reload if the existing kernel
state appears correct. Sometimes, boot time race conditions
may cause a device to be correctly set up in the kernel but
not in udev. Check this condition, and reload map in this case.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: sysfs_attr_set_value: use const char*
Martin Wilck [Tue, 28 Feb 2017 16:23:21 +0000 (17:23 +0100)]
libmultipath: sysfs_attr_set_value: use const char*

The value argument in syfs_attr_set_value should be const char*.

Signed-off-by: Martin Wilck <mwilck@suse.de>
3 days agolibmultipath: select_action: check special features separately
Martin Wilck [Tue, 28 Feb 2017 16:23:20 +0000 (17:23 +0100)]
libmultipath: select_action: check special features separately

The features queue_if_no_path and retain_attached_hw_handler are
treated separately in libmultipath. Compare these features by looking
at the respective flags, and ignore them when comparing the "features"
string. assemble_map() does the ssame thing when constructing the
features string for device mapper.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: disassemble_map: treat minio like assemble_map does
Martin Wilck [Tue, 28 Feb 2017 16:23:19 +0000 (17:23 +0100)]
libmultipath: disassemble_map: treat minio like assemble_map does

Rather than using 0 for everything except round-robin, read back
the actual minio value from DM.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: disassemble_map: skip no_path_retry check
Martin Wilck [Tue, 28 Feb 2017 16:23:18 +0000 (17:23 +0100)]
libmultipath: disassemble_map: skip no_path_retry check

mpp->no_path_retry is already checked in setup_feature() itself,
no need to do it here as well. This allows using setup_feature()
for other features except queue_if_no_path.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: setup_feature: handle "retain_attached_hw_handler"
Martin Wilck [Tue, 28 Feb 2017 16:23:17 +0000 (17:23 +0100)]
libmultipath: setup_feature: handle "retain_attached_hw_handler"

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: setup_feature: print log msg if no_path_retry cant be set
Martin Wilck [Tue, 28 Feb 2017 16:23:16 +0000 (17:23 +0100)]
libmultipath: setup_feature: print log msg if no_path_retry cant be set

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agolibmultipath: setup_features: log msg if queue_if_no_path is ignored
Martin Wilck [Tue, 28 Feb 2017 16:23:15 +0000 (17:23 +0100)]
libmultipath: setup_features: log msg if queue_if_no_path is ignored

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipathd: use weaker "force_reload" at startup
Martin Wilck [Tue, 28 Feb 2017 16:23:14 +0000 (17:23 +0100)]
multipathd: use weaker "force_reload" at startup

"force_reload" has originally been created to support multipath -r
(admin triggered reload). multipathd also uses this parameter
in DAEMON_CONFIGURE state, too. But this is causes unnecessary
device-mapper ioctls when multipathd is first started, if existing
maps have been discovered (perhaps set up by previous instance of
multipathd, e.g. in the initrd).

This patch introduces a weaker form of the force_reload parameter
to coalesce_paths(). The parameter can now take three values:
 * FORCE_RELOAD_NONE: existing maps aren't touched at all
 * FORCE_RELOAD_YES: all maps are rebuilt from scratch and (re)loaded in DM
 * FORCE_RELOAD_WEAK: existing maps are compared to the current conf and only
   reloaded in DM if there's a difference. This is useful during startup.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipathd: imply -n if find_multipaths is set
Martin Wilck [Tue, 28 Feb 2017 16:23:13 +0000 (17:23 +0100)]
multipathd: imply -n if find_multipaths is set

Automatic detection of new devices with find_multipaths
doesn't work correctly currently. Therefore, for now,
imply ignore_new_devs if find_multipaths is seen.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipath: ignore -i if find_multipaths is set
Martin Wilck [Tue, 28 Feb 2017 16:23:12 +0000 (17:23 +0100)]
multipath: ignore -i if find_multipaths is set

multipath's logic for detecing new multipath devices with find_multipaths
currently doesn't work reliably. If paths for a new device are added
sequentially, the first one will be classified as non-multpath (and passed on
to systemd for further processing) while subsequent ones will be seen as
multipath devices. If the paths are added simultaneously (such as at udev
trigger time after switching from the initrd to the rootfs, if device
detection is already finished), whether or not additional paths will be seen
when the udev rules for a given paths are processed is random.
A proper implementation of this device detection would require some sort of
information passing between multipathd and multipath, timeouts waiting for
additional paths to appear when a single one is detected, retriggering of
uevents if the status of a given paths changes, and more fine-grained
treatment of "orphaned" paths in multipathd. All of that is currently
non-existent.

Currently, our only option is to rely on the wwids file for device setup with
find_multipaths. In practice, that means that multipath maps will only be
set up for such devices that have been set up manually by the user before.
This is the behavior of multipath [-c|-u] without the "-i" option.

But "-i" is useful for the !find_multipaths case, where the expectation is
that all non-blacklisted devices are multipathed by default. Because we
can't change the multipath invocation in the udev rules file
depending on the find_multipaths setting, just ignore "-i" if find_multipaths
is set.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agolibmultipath: move suspend logic to _dm_flush_map
Martin Wilck [Tue, 28 Feb 2017 16:23:11 +0000 (17:23 +0100)]
libmultipath: move suspend logic to _dm_flush_map

The function dm_suspend_and_flush() introduced in 9a4ff93
tries to remove child maps (partitions) after suspending
the mpath device. This may lock up if removing the partitions
requires I/O. It's better to use the following sequence
of actions: 1) clear queue_if_no_path; 2) remove partitions;
3) suspend; 4) remove (or resume and restore queue_if_no_path
in case of failure).

This patch modifies the implementation by moving the
queue_if_no_path/suspend logic into _dm_flush_map().
A call to _dm_flush_map() with need_suspend=1 replaces
the previous call to dm_suspend_and_flush().

With this change, the mpath device is only suspended after
removing partmaps, avoiding the deadlock.

Fixes: 9a4ff93 "Switch off 'queue_if_no_path' before removing maps"
Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipath -ll: set DI_SERIAL
Martin Wilck [Tue, 28 Feb 2017 16:23:10 +0000 (17:23 +0100)]
multipath -ll: set DI_SERIAL

Without DI_SERIAL, multipath -ll will not be able to obtain correct
PG priorities in certain configurations (e.g. prio "weightedpath",
prio_args "serial..."). We do not set DI_SERIAL for the multipath -l
case, where information is supposed to come from sysfs+device mapper
only.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agolibmultipath: use existing alias from bindings file
Hannes Reinecke [Tue, 28 Feb 2017 16:23:09 +0000 (17:23 +0100)]
libmultipath: use existing alias from bindings file

If the bindings file has been edited by hand not all entries conform
to the user_friendly_prefix setting. So if we don't find a matching
alias we need to check if the wwid is set to a different alias; if
so we need to use that.
Otherwise we'll end up with duplicate entries in the bindings file.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agolibmultipath/discovery: do not cache 'access_state' sysfs attribute
Hannes Reinecke [Tue, 28 Feb 2017 16:23:08 +0000 (17:23 +0100)]
libmultipath/discovery: do not cache 'access_state' sysfs attribute

When reading the 'access_state' sysfs attribute we should not be
using libudev as this will cache the value, causing us to lose
any update to the attribute.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipathd: issue systemd READY after initial configuration
Hannes Reinecke [Tue, 28 Feb 2017 16:23:07 +0000 (17:23 +0100)]
multipathd: issue systemd READY after initial configuration

We should be issueing systemd READY only after the initial
configuration has been completed, otherwise systemd might
continue while the multipath devices are not setup up properly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipath: avoid crash when using modified configuration
Hannes Reinecke [Tue, 28 Feb 2017 16:23:06 +0000 (17:23 +0100)]
multipath: avoid crash when using modified configuration

Occasionally multipath would crash when using a modified configuration.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipathd: Set CLI timeout correctly
Hannes Reinecke [Tue, 28 Feb 2017 16:23:05 +0000 (17:23 +0100)]
multipathd: Set CLI timeout correctly

When calling 'multipathd cmd' the CLI timeout isn't set correctly;
calling "multipathd -k'cmd'" uses the correct timeout.
And the default timeout should be increased to 4 seconds to ensure
multipath runs correctly on large installations.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agolibmultipath: Do not crash on empty features
Hannes Reinecke [Tue, 28 Feb 2017 16:23:04 +0000 (17:23 +0100)]
libmultipath: Do not crash on empty features

When adding to an otherwise empty feature list multipath would
crash as it doesn't check for an empty feature list.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agolibmultipath: fall back to search paths by devt
Hannes Reinecke [Tue, 28 Feb 2017 16:23:03 +0000 (17:23 +0100)]
libmultipath: fall back to search paths by devt

When removing path the device might already be gone from sysfs,
so we cannot lookup the device name. However, we still should
have the path vector available, so we should be trying to look
it up by using the device number.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipathd: set timeout for CLI commands correctly
Hannes Reinecke [Tue, 28 Feb 2017 16:23:02 +0000 (17:23 +0100)]
multipathd: set timeout for CLI commands correctly

The CLI command timeout wasn't set correctly for CLI commands,
causing it to timeout prematurely before the CLI response
could be received.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agoInvalid error code when using multipathd CLI
Hannes Reinecke [Tue, 28 Feb 2017 16:23:01 +0000 (17:23 +0100)]
Invalid error code when using multipathd CLI

When calling the multipathd CLI we're getting the message

error -1 receiving packet

instead of the actual error number.
Problem is a confusion about the return values between
libmpathcmd and uxsock.c.
uxsock.c is assuming a negative return value to be the errno,
but libmpathcmd is returning -1 on error and setting errno.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipath: do not check daemon from udev rules
Hannes Reinecke [Tue, 28 Feb 2017 16:23:00 +0000 (17:23 +0100)]
multipath: do not check daemon from udev rules

As stated previously, multipathd needs to start after udev trigger
has run as otherwise it won't be able to find any devices.
However, this also means that during udevadm trigger the daemon
wouldn't run, and consequently the check in the udev rules will
always be false, causing the device not to be marked as multipath
capable.

As it turns out, calling 'multipath' from udev rules has quite some
challenges. It _should_ check if a device is eligible for multipathing.
But it needs to work under all circumstances, even if the daemon isn't
running yet, as the program will be called from uevents which might
(and will) come in before the daemon is running.
To check if the daemon _should_ be run I'm checking the various
'.wants' directories from systemd, which carries links to the services
systemd will enable eventually. So if the multipathd.service is
listed in there it will be started, even if it isn't started yet.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agoAdd support for "multipath=off" and "nompath" on kernel cmdline
Martin Wilck [Tue, 28 Feb 2017 16:22:59 +0000 (17:22 +0100)]
Add support for "multipath=off" and "nompath" on kernel cmdline

Add support for disabling multipathd startup from the kernel command line.
This is useful for debugging purposes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipathd: start daemon after udev trigger
Hannes Reinecke [Tue, 28 Feb 2017 16:22:58 +0000 (17:22 +0100)]
multipathd: start daemon after udev trigger

As multipath now relies on udev for device enumeration it needs
to be started after udev trigger has finished sending all events.
Otherwise the daemon will not find any devices during startup
(as udev trigger hasn't been called yet and the udev database is empty).
But after switchover from the initrd there will already be some
multipath device-mapper tables, for which the daemon cannot find
any device. Consequently the daemon will be removing these tables,
only to recreate them later on once udev trigger has run.
This induces a short window during which the device mapper devices
won't be present, causing systemd to umount devices or drop into
emergency mode.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipathd.service: fixup Wants= and Before= statements
Hannes Reinecke [Tue, 28 Feb 2017 16:22:57 +0000 (17:22 +0100)]
multipathd.service: fixup Wants= and Before= statements

With the latest LVM2 update we now have the 'lvm2-lvmetad.service'.
Also we need to specify 'blk-availability.service' in the 'Before='
statement, as just adding it to 'Wants=' assumes the multipathd
service should be running after the blk-availability service.

Signed-off-by: Hannes Reinecke <hare@suse.com>
10 days agomultipath-tools: libdmmp: Fix incorrect use of __attribute__
Gris Ge [Sat, 11 Mar 2017 14:12:14 +0000 (22:12 +0800)]
multipath-tools: libdmmp: Fix incorrect use of __attribute__

According to https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html ,
type attributes should be placed immediately after the struct, union or
enum keyword.

Signed-off-by: Gris Ge <fge@redhat.com>
10 days agomultipath-tools: clean up libdmmp/Makefile
Xose Vazquez Perez [Mon, 13 Mar 2017 16:47:31 +0000 (17:47 +0100)]
multipath-tools: clean up libdmmp/Makefile

Replace LDFLAGS with LIBDEPS, build libdmmp shared library without CFLAGS

Cc: Gris Ge <fge@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>
10 days agomultipathd: fix SIGUSR2 handling
tang.junhui [Thu, 29 Dec 2016 07:56:14 +0000 (15:56 +0800)]
multipathd: fix SIGUSR2 handling

SIGUSR2 is not blocked by default, it would cause bellow conflict
in removing of the last path:
-------------------------------------------------------------
uevent processing thread                 | waiter thread
-----------------------------------------|-------------------
uev_remove_path()                        |   waiteventloop()
  lock(&vecs->lock)                      |
  ev_remove_path()                       |
    dm_queue_if_no_path()----------------|----> dm_task_run()
    flush_map()                          |      |
      remove_map_and_stop_waiter()       |      -> pthread_cleanup_push(cleanup_lock, &waiter->vecs->lock);
        _remove_map()                    |         lock(&waiter->vecs->lock)//wait for the locker
          stop_waiter_thread()           |
            pthread_cancel(thread)       |
            pthread_kill(thread,SIGUSR2)-|------> sigusr2 (int sig)
                                         |          condlog()
                                         |          fprintf() //it has test cancel point
                                         |          cleanup_lock() //thread cancel, and pop, which unlock the
                                         |                           locker of uevent processing thread
--------------------------------------------------------------
Since SIGUSR2 is only needed when waiter thread running in dm_task_run(),
and it has already been unblocked before dm_task_run(), so this patch block
SIGUSR2 for other times.

Change-Id: I8c46292dc954415764ebbe054498b4f7ea53c1c6
Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
10 days agouevent_can_discard: optimize devpath check
Martin Wilck [Wed, 1 Mar 2017 17:22:19 +0000 (18:22 +0100)]
uevent_can_discard: optimize devpath check

This uses roughly 10% cycles of the sscanf-based implementation.

Improves: ee8888f0 "multipath-tools: improve processing efficiency..."
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 weeks agomultipath-tools: improve processing efficiency for addition and deletion of multipath...
tang.junhui [Tue, 28 Feb 2017 07:05:49 +0000 (15:05 +0800)]
multipath-tools: improve processing efficiency for addition and deletion of multipath devices

This patch used to improve processing efficiency for addition and deletion
of multipath devices.

This patch is tested pass by ZTE multipath automatic testing system.
The modification reduces the system consumption(such as CPU) and shortens
the processing time obviously in scene of massive multipath devices
addition or deletion.

The main processing flow of code is:
1) add uid_attrs configuration in the defaults section:
   It is configured udev attribute which providing a unique path identifier
   for corresponding type of path devices. If this field is configured and
   matched with type of device, it would override any other methods
   providing for device unique identifier in config file, and it would
   activate merging uevents according to the identifier to promote effiecncy
   in processing uevents. Tt has no default value, so defaultly only uevents
   filtering works, and uevents merging does not works, if users want to
   identify path by udev attribute and to activate merging uevents for SCSI
   and DAS device, they can set it's value as:
   "sd:ID_SERIAL dasd:ID_UID"
2) uevents accumulation in uevents burst scene:
   wait one seconds for more uevents in uevent_listen() in uevents burst
   situations
3) uevents preparing, filtering and merging:
   discard unuse uevents and fetch path idendifier from uevents;
   filter uevents;
   merge uevents.
4) uevents proccessing:
   proccess the merged uevents in uev->merge_node list without calling
   domap();
   proccess the last uevents uev with calling domap().

Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
3 weeks agoAvoid that reloading a map sporadically triggers I/O errors
Bart Van Assche [Fri, 18 Nov 2016 21:33:44 +0000 (13:33 -0800)]
Avoid that reloading a map sporadically triggers I/O errors

Avoid that reloading a map while there are no paths triggers a flush
and hence unwanted I/O errors if 'queue_if_no_path' is enabled.

Fixes: commit d569988e7528 ("libmultipath: Fixup 'DM_DEVICE_RELOAD' handling")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Hannes Reinecke <hare@suse.de>
3 weeks agofix udev rules for failed multipath devices
Benjamin Marzinski [Mon, 27 Feb 2017 18:26:43 +0000 (12:26 -0600)]
fix udev rules for failed multipath devices

11-dm-mpath.rules was only correctly dealing with the case where the
multipath device was unusable because the last path had failed.  If
instead, the last working path was removed from the device on a table
reload, it was not correctly marking the device as unusable. One problem
with fixing this is that when the device table is reloaded,
device-mapper doesn't know if the path devices are usable or not.  To
deal with this, multipath now flags reloads with no usable paths with
DM_SUBSYSTEM_UDEV_FLAG2.

11-dm-mpath.rules now checks for both PATH_FAILED events and reloads
with no valid paths. and disables the other rules.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 weeks agomultipathd: allow resetting stats
Benjamin Marzinski [Mon, 27 Feb 2017 18:26:42 +0000 (12:26 -0600)]
multipathd: allow resetting stats

This patch adds two multipathd interactive commands:

multipathd reset maps stats

and

multipathd reset map <map> stats

to reset the statistics that are shown with the "show stats" commands.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 weeks agomultipathd: add messages on delayed path addition
Benjamin Marzinski [Mon, 27 Feb 2017 18:26:41 +0000 (12:26 -0600)]
multipathd: add messages on delayed path addition

When multipath delays adding a path because the device is waiting for
udev to finish initialization, it now logs a message, so the users
know what happened to the path.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 weeks agomultipathd: don't update priority of failed paths
Benjamin Marzinski [Mon, 27 Feb 2017 18:26:40 +0000 (12:26 -0600)]
multipathd: don't update priority of failed paths

Multipathd shouldn't be updating the priority of failed paths in the
checkerloop. The current avoids this in almost all cases, but not all.
Close the loophole.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 weeks agolibmultipath: cleanup orphan device states
Benjamin Marzinski [Mon, 27 Feb 2017 18:26:39 +0000 (12:26 -0600)]
libmultipath: cleanup orphan device states

After a path device is orphaned, multipathd stops checking its state.
However, multipathd show state still shows its old state. It should
display "undef unknown" instead.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 weeks agolibmultipath: add detect_checker option
Benjamin Marzinski [Mon, 27 Feb 2017 18:26:38 +0000 (12:26 -0600)]
libmultipath: add detect_checker option

This patch adds a detect_checker option that works just like the
detect_prio option.  It currently only detects ALUA devices, and
if it finds ALUA support, it sets the priortizier to TUR. This is
useful for devices like the VNX2, where it should be using the
TUR checker when in ALUA mode (or so I have been told). It is set on by
default just like detect_prio and retain_attached_hw_handler.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 weeks agokpartx: don't keep creating recursive partitions
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>
3 weeks 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>
3 weeks 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>
3 weeks 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>
3 weeks 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>
3 weeks 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>
3 weeks 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>
3 weeks 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>
3 weeks 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>
6 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.

6 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.

6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 weeks ago[multipathd] Remove trailing whitespaces
Christophe Varoqui [Fri, 10 Feb 2017 08:54:01 +0000 (09:54 +0100)]
[multipathd] Remove trailing whitespaces

6 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>
3 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.

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
4 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>
4 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>
4 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>
4 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.

4 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>
4 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>
4 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>
4 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>