multipath-tools/.git
2 months agomultipathd: staticify uxlsnr variables/functions
Benjamin Marzinski [Wed, 19 Feb 2020 06:48:24 +0000 (00:48 -0600)]
multipathd: staticify uxlsnr variables/functions

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipathd: warn when configuration has been changed.
Benjamin Marzinski [Wed, 19 Feb 2020 06:48:23 +0000 (00:48 -0600)]
multipathd: warn when configuration has been changed.

It would be helpful if multipathd could log a message when
multipath.conf or files in the config_dir have been written to, both so
that it can be used to send a notification to users, and to help with
determining after the fact if multipathd was running with an older
config, when the logs of multipathd's behaviour don't match with the
current multipath.conf.

To do this, the multipathd uxlsnr thread now sets up inotify watches on
both /etc/multipath.conf and the config_dir to watch if the files are
deleted or closed after being opened for writing.  In order to keep
uxlsnr from polling repeatedly if the multipath.conf or the config_dir
aren't present, it will only set up the watches once per reconfigure.
However, since multipath.conf is far more likely to be replaced by a
text editor than modified in place, if it gets removed, multipathd will
immediately try to restart the watch on it (which will succeed if the
file was simply replaced by a new copy).  This does mean that if
multipath.conf or the config_dir are actually removed and then later
re-added, multipathd won't log any more messages for changes until the
next reconfigure. But that seems like a fair trade-off to avoid
repeatedly polling for files that aren't likely to appear.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath-tools: Makefile.inc: test for -Wno-clobbered support
Martin Wilck [Sat, 12 Oct 2019 21:29:07 +0000 (21:29 +0000)]
multipath-tools: Makefile.inc: test for -Wno-clobbered support

clang doesn't support this option.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: Makefile.inc: enable -Werror
Martin Wilck [Sat, 12 Oct 2019 21:29:06 +0000 (21:29 +0000)]
multipath-tools: Makefile.inc: enable -Werror

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: Makefile: avoid gcc 4.8 missing initializers failure
Martin Wilck [Sat, 12 Oct 2019 21:29:04 +0000 (21:29 +0000)]
multipath tests: Makefile: avoid gcc 4.8 missing initializers failure

With -Wmissing-field-initializers (implied by our current compiler flags),
gcc 4.8 errors out if nested initializers are missing:

struct A {
       int a, b;
};

struct B {
       struct A a;
       int c;
} b = { .a.a = 1; }

Later gcc versions and clang accept it just fine.
Add a test to tests/Makefile and use -Wno-missing-initializers if gcc 4.8
behavior is detected.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: Makefile: fix "clean" target
Martin Wilck [Sat, 12 Oct 2019 21:29:03 +0000 (21:29 +0000)]
multipath tests: Makefile: fix "clean" target

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: Makefile: use proper directory recursion
Martin Wilck [Sat, 12 Oct 2019 21:29:02 +0000 (21:29 +0000)]
multipath-tools: Makefile: use proper directory recursion

"make -k" didn't work with the Makefile's subdirectory handling.
Do it the proper "make" way.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: Makefile.inc: use -Wp,... for compiling only
Martin Wilck [Sat, 12 Oct 2019 21:29:01 +0000 (21:29 +0000)]
multipath-tools: Makefile.inc: use -Wp,... for compiling only

clang-3.9 errors out if -Wp,... preprocessor flags are used in the
linking stage.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: util: fix clang strlcpy warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:57 +0000 (21:28 +0000)]
multipath tests: util: fix clang strlcpy warnings

clang erroneously thought that we were using the size of the source
for the destination, while they are equal. Trick it into accepting
the code.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: fix -Wformat-literal warning
Martin Wilck [Sat, 12 Oct 2019 21:28:56 +0000 (21:28 +0000)]
multipath tests: fix -Wformat-literal warning

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: hwtable: fix strncat() invocation
Martin Wilck [Sat, 12 Oct 2019 21:28:54 +0000 (21:28 +0000)]
multipath tests: hwtable: fix strncat() invocation

clang detected this error.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: blacklist: remove always-true condition
Martin Wilck [Sat, 12 Oct 2019 21:28:53 +0000 (21:28 +0000)]
multipath tests: blacklist: remove always-true condition

clang warns about this (udev_device->property_list can't be NULL).

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: fix clang -Wformat-literal warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:52 +0000 (21:28 +0000)]
libmultipath: fix clang -Wformat-literal warnings

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibdmmp: fix clang -Wformat-nonliteral warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:50 +0000 (21:28 +0000)]
libdmmp: fix clang -Wformat-nonliteral warnings

clang enables -Wformat-nonliteral with our compiler flags, and
thus needs these format(printf, ...) attributes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: Makefile.inc: enable -Wsign-compare
Martin Wilck [Sat, 12 Oct 2019 21:28:49 +0000 (21:28 +0000)]
multipath-tools: Makefile.inc: enable -Wsign-compare

With the previous patches, there are no signedness warnings any more.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agokpartx: use unsigned int for "ns" argument of ptreader
Martin Wilck [Sat, 12 Oct 2019 21:28:48 +0000 (21:28 +0000)]
kpartx: use unsigned int for "ns" argument of ptreader

ns, the number of slices, should be positive.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agokpartx: use unsigned arguments in dm_devn() and dm_prereq()
Martin Wilck [Sat, 12 Oct 2019 21:28:46 +0000 (21:28 +0000)]
kpartx: use unsigned arguments in dm_devn() and dm_prereq()

In both cases, the corresponding libdevmapper values are unsigned.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmpathpersist: fix -Wsign-compare warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:45 +0000 (21:28 +0000)]
libmpathpersist: fix -Wsign-compare warnings

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmpathcmd: fix -Wsign-compare warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:44 +0000 (21:28 +0000)]
libmpathcmd: fix -Wsign-compare warnings

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath, kpartx: byteorder: always use unsigned types
Martin Wilck [Sat, 12 Oct 2019 21:28:42 +0000 (21:28 +0000)]
libmultipath, kpartx: byteorder: always use unsigned types

The swapped results are unsigned, so the non-swapped ones should
be unsigned, too.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: use unsigned blksize in directio context
Martin Wilck [Sat, 12 Oct 2019 21:28:41 +0000 (21:28 +0000)]
libmultipath: use unsigned blksize in directio context

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: make "checkint" unsigned
Martin Wilck [Sat, 12 Oct 2019 21:28:40 +0000 (21:28 +0000)]
libmultipath: make "checkint" unsigned

path->checkint was unsigned already, now use this type everywhere.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: set_int(): add error check and set_uint()
Martin Wilck [Sat, 12 Oct 2019 21:28:39 +0000 (21:28 +0000)]
libmultipath: set_int(): add error check and set_uint()

Use strtol() to check for valid input, but don't return error
as that would cause config file parsing to fail because of a
single typo. Also, add set_uint() to parse an unsigned parameter.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: vector_for_each_slot: fix -Wsign-compare warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:38 +0000 (21:28 +0000)]
libmultipath: vector_for_each_slot: fix -Wsign-compare warnings

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: print: use unsigned int for "width" field
Martin Wilck [Sat, 12 Oct 2019 21:28:36 +0000 (21:28 +0000)]
libmultipath: print: use unsigned int for "width" field

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: parse_vpd_pg83(): fix -Wsign-compare warnings
Martin Wilck [Sat, 12 Oct 2019 21:28:35 +0000 (21:28 +0000)]
libmultipath: parse_vpd_pg83(): fix -Wsign-compare warnings

Most of this is trivial. Changes are: return early if there
is obviously not enough space. Check vpd_len for designator
type 8.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: parse_vpd_pg83(): sanitize indentation
Martin Wilck [Sat, 12 Oct 2019 21:28:34 +0000 (21:28 +0000)]
libmultipath: parse_vpd_pg83(): sanitize indentation

This just moves a lot of code to the left. No functional change.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: trivial changes for -Wsign-compare
Martin Wilck [Sat, 12 Oct 2019 21:28:32 +0000 (21:28 +0000)]
libmultipath: trivial changes for -Wsign-compare

All these are obious fixes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: dev_loss_tmo is unsigned
Martin Wilck [Sat, 12 Oct 2019 21:28:31 +0000 (21:28 +0000)]
libmultipath: dev_loss_tmo is unsigned

Make MAX_DEV_LOSS_TMO reflect the fact that the kernel supports
timeouts up to UINT_MAX, and fix comparisons in discovery.c.

Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: Makefile.inc: remove -Wno-unused-parameter
Martin Wilck [Sat, 12 Oct 2019 21:28:29 +0000 (21:28 +0000)]
multipath-tools: Makefile.inc: remove -Wno-unused-parameter

All warnings have been eliminated now.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools tests: add -Wno-unused-parameter
Martin Wilck [Sat, 12 Oct 2019 21:28:28 +0000 (21:28 +0000)]
multipath-tools tests: add -Wno-unused-parameter

Too many unused "void **state" parameters unders tests.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmpathpersist: fix copy-paste error in mpath_format_readresv()
Martin Wilck [Sat, 12 Oct 2019 21:28:27 +0000 (21:28 +0000)]
libmpathpersist: fix copy-paste error in mpath_format_readresv()

This would swap bytes for the wrong field.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmpathpersist: remove unused "noisy" argument in various functions
Martin Wilck [Sat, 12 Oct 2019 21:28:25 +0000 (21:28 +0000)]
libmpathpersist: remove unused "noisy" argument in various functions

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipathd: use -Wno-unused-parameter for cli_handlers.c
Martin Wilck [Sat, 12 Oct 2019 21:28:24 +0000 (21:28 +0000)]
multipathd: use -Wno-unused-parameter for cli_handlers.c

This file contains many handlers that don't use all their arguments.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: use -Wno-unused-parameter for dict.c
Martin Wilck [Sat, 12 Oct 2019 21:28:23 +0000 (21:28 +0000)]
libmultipath: use -Wno-unused-parameter for dict.c

This file contains just too many "handler" and "snprintf" methods
which don't use every argument.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath: delegate_to_multipathd: mark unused arguments
Martin Wilck [Sat, 12 Oct 2019 21:28:22 +0000 (21:28 +0000)]
multipath: delegate_to_multipathd: mark unused arguments

... for now.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: snprint_multipath_map_json(): remove unused argument
Martin Wilck [Sat, 12 Oct 2019 21:28:20 +0000 (21:28 +0000)]
libmultipath: snprint_multipath_map_json(): remove unused argument

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: get_pgpolicy_name(): use "len" parameter
Martin Wilck [Sat, 12 Oct 2019 21:28:19 +0000 (21:28 +0000)]
libmultipath: get_pgpolicy_name(): use "len" parameter

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: mark missing arguments in functions matching prototypes
Martin Wilck [Sat, 12 Oct 2019 21:28:18 +0000 (21:28 +0000)]
libmultipath: mark missing arguments in functions matching prototypes

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agokpartx: mark unused arguments in ptreader methods
Martin Wilck [Sat, 12 Oct 2019 21:28:17 +0000 (21:28 +0000)]
kpartx: mark unused arguments in ptreader methods

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agokpartx: gpt: remove unused arg in read_lastoddsector()
Martin Wilck [Sat, 12 Oct 2019 21:28:16 +0000 (21:28 +0000)]
kpartx: gpt: remove unused arg in read_lastoddsector()

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tools: mark unused arguments in thread routines
Martin Wilck [Sat, 12 Oct 2019 21:28:14 +0000 (21:28 +0000)]
multipath tools: mark unused arguments in thread routines

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipathd: stop_waiter_thread(): removed unused parameter
Martin Wilck [Sat, 12 Oct 2019 21:28:13 +0000 (21:28 +0000)]
multipathd: stop_waiter_thread(): removed unused parameter

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: checkers: mark unused arguments in methods
Martin Wilck [Sat, 12 Oct 2019 21:28:12 +0000 (21:28 +0000)]
libmultipath: checkers: mark unused arguments in methods

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: hp_sw: remove usused argument in do_inq()
Martin Wilck [Sat, 12 Oct 2019 21:28:11 +0000 (21:28 +0000)]
libmultipath: hp_sw: remove usused argument in do_inq()

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: mark unused params in getprio() methods
Martin Wilck [Sat, 12 Oct 2019 21:28:09 +0000 (21:28 +0000)]
libmultipath: mark unused params in getprio() methods

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: get_ana_info(): remove unused parameter
Martin Wilck [Sat, 12 Oct 2019 21:28:08 +0000 (21:28 +0000)]
libmultipath: get_ana_info(): remove unused parameter

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: mark unused params in signal and cleanup handlers
Martin Wilck [Sat, 12 Oct 2019 21:28:07 +0000 (21:28 +0000)]
multipath-tools: mark unused params in signal and cleanup handlers

These parameters are all rightfully unused, yet need to be declared
because of the function prototypes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: scsi_ioctl_pathinfo(): remove unused argument
Martin Wilck [Sat, 12 Oct 2019 21:28:06 +0000 (21:28 +0000)]
libmultipath: scsi_ioctl_pathinfo(): remove unused argument

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: mark unused arguments in partmap functions
Martin Wilck [Sat, 12 Oct 2019 21:28:04 +0000 (21:28 +0000)]
libmultipath: mark unused arguments in partmap functions

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: process_config_dir(): remove unused argument
Martin Wilck [Sat, 12 Oct 2019 21:28:03 +0000 (21:28 +0000)]
libmultipath: process_config_dir(): remove unused argument

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: _init_foreign(): fix possible memory leak
Martin Wilck [Sat, 12 Oct 2019 21:28:02 +0000 (21:28 +0000)]
libmultipath: _init_foreign(): fix possible memory leak

free_pre() wasn't called if scandir() failed. Fix it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: remove_wwids(): fix possible leaks
Martin Wilck [Sat, 12 Oct 2019 21:28:00 +0000 (21:28 +0000)]
libmultipath: remove_wwids(): fix possible leaks

... of fd and memory.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: replace_wwids(): fix possible fd leak
Martin Wilck [Sat, 12 Oct 2019 21:27:59 +0000 (21:27 +0000)]
libmultipath: replace_wwids(): fix possible fd leak

... in case the thread is cancelled.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: uevent_listen(): fix poll() retval check
Martin Wilck [Sat, 12 Oct 2019 21:27:58 +0000 (21:27 +0000)]
libmultipath: uevent_listen(): fix poll() retval check

Only check revents if poll() returns a positive value.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: make path_discovery() pthread_cancel()-safe
Martin Wilck [Sat, 12 Oct 2019 21:27:57 +0000 (21:27 +0000)]
libmultipath: make path_discovery() pthread_cancel()-safe

The udev_enumerate and udev_device refs wouldn't be released
if the thread was cancelled. Fix it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: path_discovery: handle libudev errors
Martin Wilck [Sat, 12 Oct 2019 21:27:55 +0000 (21:27 +0000)]
libmultipath: path_discovery: handle libudev errors

pass out if any libudev helpers return an error code.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: use -lpthread for alias test
Martin Wilck [Sat, 12 Oct 2019 21:27:54 +0000 (21:27 +0000)]
multipath tests: use -lpthread for alias test

This becomes necessary because of the previous patch.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: alias.c: prepare for cancel-safe allocation
Martin Wilck [Sat, 12 Oct 2019 21:27:53 +0000 (21:27 +0000)]
libmultipath: alias.c: prepare for cancel-safe allocation

In functions that return newly allocated memory, avoid cancellation
points before returning, and if that's not possible, guard the code
that contains cancellation points with a cleanup function calling
free(), and immediately before returning, call pthread_cleanup_pop(0).

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: alias: add format/scan test
Martin Wilck [Sat, 12 Oct 2019 21:27:52 +0000 (21:27 +0000)]
multipath tests: alias: add format/scan test

Test scan_devname(format_devname(id)) == id.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: alias: add tests for allocate_binding()
Martin Wilck [Sat, 12 Oct 2019 21:27:50 +0000 (21:27 +0000)]
multipath tests: alias: add tests for allocate_binding()

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: allocate_binding(): detect line overflow
Martin Wilck [Sat, 12 Oct 2019 21:27:49 +0000 (21:27 +0000)]
libmultipath: allocate_binding(): detect line overflow

Be sure not to truncate the WWID. This shouldn't happen under
normal circumstances, but play it safe.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: allocate_binding(): error out for id=0
Martin Wilck [Sat, 12 Oct 2019 21:27:48 +0000 (21:27 +0000)]
libmultipath: allocate_binding(): error out for id=0

Only for positive id can we allocate a binding. All current
callers make sure the id is positive. Yet, fix the implementation
in allocate_binding(), too.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: rlookup_binding(): removed unused parameter
Martin Wilck [Sat, 12 Oct 2019 21:27:46 +0000 (21:27 +0000)]
libmultipath: rlookup_binding(): removed unused parameter

The parameter "prefix" is unused in this function.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: lookup_binding(): don't rely on int overflow
Martin Wilck [Sat, 12 Oct 2019 21:27:45 +0000 (21:27 +0000)]
libmultipath: lookup_binding(): don't rely on int overflow

lookup_binding() would return a negative result and issue an error
message if variable "id" became negative. But id is only incremented,
starting from 1. Relying on an int overflow is wrong, because the result
is undefined behavior in C. Also, an overflow might as well (actually, more
likely) occur if biggest_id == INT_MAX.

Also, lookup_binding() would return 0 both in an error case and if a
matching wwid was found. While the two cases could be distinguished
by checking if *map_alias was NULL after return, this is highly
non-standard and confusing. Return -1 in error case.

Because of the semantics of lookup_binding(), the test for "id" before calling
allocate_binding() in get_user_friendly_alias() is redundant.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: scan_devname: fix int overflow detection
Martin Wilck [Sat, 12 Oct 2019 21:27:44 +0000 (21:27 +0000)]
libmultipath: scan_devname: fix int overflow detection

For an int n, it's possible that n > 0 and (26 * n) > 0, but
and still 26 * n overflows the int.
E.g. n = 0x0ec4ec4e; 26 * n = 0x17fffffec, truncated to 32 bit
yields 0x7fffffec, which is > 0.

And anyway, relying on a signed int overflow to detect a problem
is wrong, as the result of such operations is undefined in C.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: format_devname: avoid buffer overflow
Martin Wilck [Sat, 12 Oct 2019 21:27:43 +0000 (21:27 +0000)]
libmultipath: format_devname: avoid buffer overflow

If the buffer was too short, the current code could write
the terminating 0 byte after the actual buffer.

Also, assert sufficient buffer length, and positive id.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: alias.c: use strlcpy(), and 2 minor fixes
Martin Wilck [Sat, 12 Oct 2019 21:27:41 +0000 (21:27 +0000)]
libmultipath: alias.c: use strlcpy(), and 2 minor fixes

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: alias.c: constify function arguments
Martin Wilck [Sat, 12 Oct 2019 21:27:40 +0000 (21:27 +0000)]
libmultipath: alias.c: constify function arguments

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: add tests for alias handling
Martin Wilck [Sat, 12 Oct 2019 21:27:39 +0000 (21:27 +0000)]
multipath tests: add tests for alias handling

Some of these tests fail with the current code base.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath tests: move condlog test wrappers to separate file
Martin Wilck [Sat, 12 Oct 2019 21:27:38 +0000 (21:27 +0000)]
multipath tests: move condlog test wrappers to separate file

These helpers can be useful in other tests.

Signed-off-by: Martin Wilck <mwilck@suse.com>
7 months agoBump version to 0.8.3 0.8.3
Christophe Varoqui [Wed, 2 Oct 2019 07:15:03 +0000 (09:15 +0200)]
Bump version to 0.8.3

7 months agomultipath-tools: cosmetic changes in hwtable
Xose Vazquez Perez [Sat, 21 Sep 2019 23:40:39 +0000 (01:40 +0200)]
multipath-tools: cosmetic changes in hwtable

Tegile IntelliFlash was acquired by DDN, from WD.

HPE Primera is also identified as 3PARdata/VV

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
7 months agomultipathd: "san_path_err" failure optimization
Chongyun Wu [Wed, 2 Oct 2019 06:48:07 +0000 (06:48 +0000)]
multipathd: "san_path_err" failure optimization

Let san_path_err_recovery_time path unstable can be
detected and not reinstate it until this path keep up in
san_path_err_recovery_time. It will fix heavy IO delay
caused by parts of paths state shaky in multipath device.

Test and result:
Run up eth1 30s and down eth1 30s with 100 loops script to
make some paths shaky in each multipath devices.
Using below multipath.conf configure in defaults section:
    san_path_err_recovery_time 30
    san_path_err_threshold 2
    san_path_err_forget_rate 6
After test, not found any IO delay logs except several logs in the very
beginning which before san_path_err filter shaky path works .
If without above config and this patch there will be lots of IO delay
in syslog and some paths state change from up to down again and again.

Signed-off-by: Chongyun Wu <wu.chongyun@h3c.com>
7 months agomultipath.conf.5: document foreign library support
Martin Wilck [Wed, 2 Oct 2019 06:48:05 +0000 (06:48 +0000)]
multipath.conf.5: document foreign library support

Add documentation for foreign library support, and for the
"enable_foreign" parameter.

Signed-off-by: Martin Wilck <mwilck@suse.com>
7 months agomultipath.conf: add "enable_foreign" parameter
Martin Wilck [Wed, 2 Oct 2019 06:48:04 +0000 (06:48 +0000)]
multipath.conf: add "enable_foreign" parameter

This new configuration parameter can be used to selectively
enable foreign libraries. The value is a regular expression,
against which foreign library names such as "nvme" are matched.
By setting this to a value that matches no foreign library
(e.g. "^$" or "NONE"), foreign code is completely disabled.
By default, all available foreign libraries are loaded.

Signed-off-by: Martin Wilck <mwilck@suse.com>
7 months agomultipath-tools (coverity): assert availability of CLOCK_MONOTONIC
Martin Wilck [Tue, 9 Jul 2019 07:40:03 +0000 (07:40 +0000)]
multipath-tools (coverity): assert availability of CLOCK_MONOTONIC

clock_gettime() fails only if either an invalid pointer is passed,
or if the requested clock ID is not available. While availability of
CLOCK_REALTIME is guaranteed, CLOCK_MONOTONIC is not, at least not
by POSIX (Linux seems to have it, always). Provide a wrapper that
can be called without error checking, and which aborts in the highly
unlikely case that the monotonic clock can't be obtained. That saves
us from checking the error code of clock_gettime() at every invocation
(handling this sort of error "correctly" is almost impossible anyway),
and should still satisfy coverity.

Not doing this for libdmmp here, as it has it's own error checking
and doesn't use headers from libmultipath.

----
v2: Fix mistake that with -DNDEBUG, clock_gettime wouldn't be called
at all (Bart van Assche).

Signed-off-by: Martin Wilck <mwilck@suse.com>
7 months agokpartx: recognize DASD on loop devices again
Martin Wilck [Tue, 9 Jul 2019 07:40:02 +0000 (07:40 +0000)]
kpartx: recognize DASD on loop devices again

Since 4d57b868, DASD partition tables are only recognized on
DASD hardware. This turns out to break certain software that works
e.g. with DASD partition tables on loop devices. The problem that
4d57b868 attempted to fix was that "unlabeled disk" format has
no signature at all and is detected on any volume, including
empty ones.

With this patch, DASD partition table formats other than "unlabeled
disk" are detected on non-DASD devices again.

Fixes: 4d57b868 "kpartx: only recognize dasd part table on DASD"
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
7 months agomultipath-tools: reorder vendor in hwtable
Xose Vazquez Perez [Fri, 26 Jul 2019 19:19:30 +0000 (21:19 +0200)]
multipath-tools: reorder vendor in hwtable

Nexenta was acquired by DDN.

Cc: Yacine Kheddache <yacine@alyseo.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
7 months agomultipath-tools: delete examples from mpathpersist output
Xose Vazquez Perez [Fri, 26 Jul 2019 19:19:29 +0000 (21:19 +0200)]
multipath-tools: delete examples from mpathpersist output

The manual page is more complete and detailed.

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
7 months agomultipath-tools: delete outdated comment at multipath/multipath.conf.5
Xose Vazquez Perez [Fri, 26 Jul 2019 19:19:28 +0000 (21:19 +0200)]
multipath-tools: delete outdated comment at multipath/multipath.conf.5

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
7 months agolibmultipath: fix mpcontext initialization
Benjamin Marzinski [Fri, 13 Sep 2019 22:04:04 +0000 (17:04 -0500)]
libmultipath: fix mpcontext initialization

If a path is discovered before there is a multipath device for it to
belong to, the checker will not have its mpcontext initialized, even if
that path later belongs to a multipath device. A checker's mpcontext is
only set when the checker is selected, and is set to NULL if there is no
multipath device associated with the path. This only impacts the emc
checker. However, it makes the emc checker unable to determine if a
passive path is connected to an inactive snapshot or not.

This can be solved by adding a new checker class function, mp_init().
This is called when the checker is first initialized, and whenever the
checker is called, if the checker's mpcontext hasn't been initialized.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agompathpersist: fix leaks
Benjamin Marzinski [Fri, 13 Sep 2019 22:04:03 +0000 (17:04 -0500)]
mpathpersist: fix leaks

If handle_args() fails while looping through the argument list, it needs
to free batch_fn, if it has been set. Also handle_args() needs to make
sure to free the file descriptor after it has been opened.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: EMC PowerMax NVMe device config
Benjamin Marzinski [Fri, 13 Sep 2019 22:04:02 +0000 (17:04 -0500)]
libmultipath: EMC PowerMax NVMe device config

Got this config from Dell.

Cc: heyi <yi.he@dell.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agompathpersist: remove broken/unused code
Benjamin Marzinski [Fri, 13 Sep 2019 22:04:01 +0000 (17:04 -0500)]
mpathpersist: remove broken/unused code

The test for an empty pp->dev in updatepaths() dates back to when
disassemble_map() didn't fill in pp->dev for newly added paths, and it
was meant to catch paths that got added by disassemble_map().  With the
mpathpersist speedup code, all paths get added by disassemble_map().
However, disassemble_map() now calls devt2devname() to set pp->dev if
possible.  This means that there is no point in calling devt2devname()
again in updatepaths(). If for some reason it did return success, the
current code would still fail, since it doesn't set pp->udev in this
code path. The best thing to do if disassemble_map() couldn't set
pp->dev is simply to fail the path.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agomultipath: update man pages
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:58 +0000 (12:48 -0500)]
multipath: update man pages

Add documentation for the marginal_pathgroups option and the
(un)setmarginal commands.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agomultipathd: use marginal_pathgroups
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:57 +0000 (12:48 -0500)]
multipathd: use marginal_pathgroups

This commit makes the marginal_pathgroups option work with the
existing methods for determining marginal paths.  It also merges the
code for the marginal_path and sand_path_err methods. This has the
side effect of making the marginal_path code set a marginal path's state
to "delayed" instead of "shaky" like it previously did.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmutipath: deprecate delay_*_checks
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:56 +0000 (12:48 -0500)]
libmutipath: deprecate delay_*_checks

The delay_checks shaky paths detection method works the same way as the
san_path_err method, but not as well, with less configurability, and
with the code spread all over check_path(). The only real difference is
that marks the path as marginal for a certain number of path checks
instead of for a specific time. This patch deprecates the delay_checks
method and maps it to the the san_path_err method.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: add marginal_pathgroups config option
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:55 +0000 (12:48 -0500)]
libmultipath: add marginal_pathgroups config option

group_paths now gets passed this to determine whether to enable
marginal pathgroups. The unit tests have also been updated.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agotests: add tests for grouping marginal paths.
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:54 +0000 (12:48 -0500)]
tests: add tests for grouping marginal paths.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: make group_paths handle marginal paths
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:53 +0000 (12:48 -0500)]
libmultipath: make group_paths handle marginal paths

group_paths() will now create seperate path groups for marginal and
normal paths, and place all of the marginal path groups after the normal
ones, in order by priority.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: make pgpolicyfn take a paths vector
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:52 +0000 (12:48 -0500)]
libmultipath: make pgpolicyfn take a paths vector

To enable future changes, mp->pgpolicyfn() now takes a vector of
paths instead of always using mp->paths.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: consolidate group_by_* functions
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:51 +0000 (12:48 -0500)]
libmultipath: consolidate group_by_* functions

group_by_node_name() and group_by_serial() are exactly the same except
for how the paths are compared. group_by_prio() is different but its
pathvec solves the same issue as the bitmap from the other two
functions, and since we are always running sort_pathgroups() after
calling pgpriorityfn, there is no need to sort the pathgroups in
group_by_prio(). This means that all three functions can be replaced
with one function, group_by_match() that takes a match function as an
argument.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: fix double free in pgpolicyfn error paths
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:50 +0000 (12:48 -0500)]
libmultipath: fix double free in pgpolicyfn error paths

In the pgpolicy functions, if an error is encountered after
alloc_pathgroup() is called, but before the path group is added to a
multipath device with add_pathgroup(), the pathgroup needs to be cleaned
up by calling free_pathgroup(). However, after the pathgroup has been
added to the multipath device, calling free_pgvec() will clean it up. In
this case, if free_pathgroup() is called first, the recently added
pathgroup will be freed twice.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agotests: update pgpolicy tests to work with group_paths()
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:49 +0000 (12:48 -0500)]
tests: update pgpolicy tests to work with group_paths()

The pgpolicy unit tests now work again, using group_paths().
test_one_group0(), which was skipped with the old path grouping code
because it failed, is now working correctly.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: add wrapper function around pgpolicyfn
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:48 +0000 (12:48 -0500)]
libmultipath: add wrapper function around pgpolicyfn

group_paths() is a wrapper around the pgpolicy functions, that pulls out
the common code from the beginning and the end. For this to work,
one_group() needs to change how it sets up the pathgroups vector to work
like the other pgpolicy functions. This does means that the pathgroups
in group_by_prio are now needlessly sorted afterwards. That will be
dealt with in a later patch.  Also, since store_pathgroup() is only
called by add_pathgroup(), it doesn't need to exist as a seperate
function.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agotests: add path grouping policy unit tests.
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:47 +0000 (12:48 -0500)]
tests: add path grouping policy unit tests.

In preparation for changing the path grouping code, add some unit tests
to verify that it works correctly. The only test that currently fails
(and so it being skipped) is using MULTIBUS when mp->paths is empty. All
the other path grouping policies free mp->paths, even if it is empty.
one_group() should as well. This will be fixed when the path grouping
code is updated.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: add marginal paths and groups infrastructure
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:46 +0000 (12:48 -0500)]
libmultipath: add marginal paths and groups infrastructure

This commit adds a marginal variable ot the paths and pathgroups structs.
The marginal paths variable can be set by

multipathd path <path> setmarginal

and cleared by

multipathd path <path> unsetmarginal

All of the marginal paths on a multipath device can be cleared by

multipathd map <map> unsetmarginal

Currently, the marginal variable of a pathgroup will not change. This
will be added by a future commit. The marginal state of a path or
pathgroup is printable with the %M wildcard, and is displayed in the
json output.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agolibmultipath: make vector_foreach_slot_backwards work as expected
Benjamin Marzinski [Fri, 23 Aug 2019 17:48:45 +0000 (12:48 -0500)]
libmultipath: make vector_foreach_slot_backwards work as expected

All of the code that uses vector_foreach_slot_backwards() treats "i" as
the index of the entry "p", but the way it was coded, that wasn't the
case. "i" was the number of the entry counting from 1, not 0.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 months agokpartx: Use __kernel_daddr_t for solaris_x86_slice.s_start
Petr Vorel [Mon, 8 Jul 2019 21:35:51 +0000 (23:35 +0200)]
kpartx: Use __kernel_daddr_t for solaris_x86_slice.s_start

It was meant to be used daddr_t (which is mostly int, only sparc and
mips have it defined as int), but instead used long.
But musl libc does not define daddr_t as it's deprecated, therefore
use __kernel_daddr_t from <linux/types.h>.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>