multipath-tools/.git
10 days agolibmultipath: test code for "zombie" TUR threads master
Martin Wilck [Wed, 10 Oct 2018 20:05:04 +0000 (22:05 +0200)]
libmultipath: test code for "zombie" TUR threads

This patch adds test code that simulates hanging, non-cancellable
TUR threads, for testing multipathd's behavior in that situation.
Compile libmultipath with CFLAGS=-DTUR_TEST_MAJOR=8 to activate
the test code. Without that flag, the patch has no effect.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipath.8: man page update
Martin Wilck [Wed, 10 Oct 2018 20:05:03 +0000 (22:05 +0200)]
multipath.8: man page update

Clean up the synopsis, listing only combinations of command line switches
that work and make sense. Split the switches between "operation modes"
and options. Fix the documentation of the -v switch, which was wrong.
Move the description of the "device" argument to the top. Link to
multipath.conf(5) for the description of the path grouping policy rather
than repeating the content here. Various minor improvements and clarifications.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agomultipath.rules: add comment about DM_MULTIPATH_DEVICE_PATH=2
Martin Wilck [Wed, 10 Oct 2018 20:05:02 +0000 (22:05 +0200)]
multipath.rules: add comment about DM_MULTIPATH_DEVICE_PATH=2

See dm-devel discussion "Changes in DM_MULTIPATH_DEVICE_PATH in
multipath-tools 0.7.7" (Sep. 2018) for rationale.

Cc: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agolibmultipath: cciss_ioctl_pathinfo doesn't fail
Martin Wilck [Wed, 10 Oct 2018 20:05:01 +0000 (22:05 +0200)]
libmultipath: cciss_ioctl_pathinfo doesn't fail

Make it a void function and move the DI_SERIAL test to pathinfo().

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agolibmultipath: scsi_ioctl_pathinfo doesn't fail
Martin Wilck [Wed, 10 Oct 2018 20:05:00 +0000 (22:05 +0200)]
libmultipath: scsi_ioctl_pathinfo doesn't fail

This function never returns error, so make a void.
Move the mask test to pathinfo() where it belongs.
The error message about the serial number isn't important
any more, reduce its level to v3.

Signed-off-by: Martin Wilck <mwilck@suse.com>
10 days agotest-kpartx: add test for invocation on image file
Martin Wilck [Wed, 10 Oct 2018 20:04:59 +0000 (22:04 +0200)]
test-kpartx: add test for invocation on image file

Add a test for kpartx invocation on an image file that is not
yet part of a loop device, passing a relative path to kpartx:

        # kpartx -av disk.img
        ...
        # kpartx -d disk.img

The recent patches 95c4189b "kpartx: Use absolute paths to create mappings"
and c1adcc5b "kpartx: Use absolute paths to create mappings" both
independently fixed this behavior, which had been broken previously by
9bdfa3eb "kpartx: use absolute path for regular files".

Cc: Stef Walter <stefw@redhat.com>
Cc: Yuval Turgeman <yturgema@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
11 days agomultipath-tools: delete trailing whitespaces
Xose Vazquez Perez [Wed, 10 Oct 2018 19:51:16 +0000 (21:51 +0200)]
multipath-tools: delete trailing whitespaces

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
11 days agolibmultipath: timeout on unresponsive tur thread
Benjamin Marzinski [Wed, 10 Oct 2018 18:01:13 +0000 (13:01 -0500)]
libmultipath: timeout on unresponsive tur thread

If the tur checker thread has been cancelled but isn't responding,
timeout instead of doing a sync check.  This will keep one bad
device from impacting all of multipathd.

Fixes: 455242d ("libmultipath: fix tur checker timeout")
Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agompathpersist: fix registration rollback issue
Benjamin Marzinski [Wed, 10 Oct 2018 18:01:12 +0000 (13:01 -0500)]
mpathpersist: fix registration rollback issue

When mpathpersist tries to rollback the registration, it copies
the SARK to the RK, and clears the SARK. However, it repeated this step
for each thread. This means that the first rollback thread correctly
had the RK set to the SARK used during registration. However, if more
than one registration needed to be rolled back, later threads would have
both the RK and SARK cleared. This commit fixes that by only copying and
clearing the SARK once.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agomultipathd: set return code for multipathd commands
Benjamin Marzinski [Wed, 10 Oct 2018 18:01:11 +0000 (13:01 -0500)]
multipathd: set return code for multipathd commands

Failed multipathd commands should set the return code to 1.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agolibmultipath: remove max_fds code duplication
Benjamin Marzinski [Wed, 10 Oct 2018 18:01:10 +0000 (13:01 -0500)]
libmultipath: remove max_fds code duplication

Instead of multipath, multipathd, and mpathpersist all having code to
set the max number of open file descriptors, just use a util function to
do it.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agomultipathd: check for NULL udevice in cli_add_path
Benjamin Marzinski [Wed, 10 Oct 2018 18:01:09 +0000 (13:01 -0500)]
multipathd: check for NULL udevice in cli_add_path

If cli_add_path can't get a udevice for the path, it should fail
immediately, instead of continuing with a NULL udevice, since it will
fail in store_pathinfo() anyway.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agomultipath: tweak logging style
Benjamin Marzinski [Wed, 10 Oct 2018 18:01:08 +0000 (13:01 -0500)]
multipath: tweak logging style

When multipathd commands are run, errors should be printed to stderr,
instead of syslog. Also, when the multipath is run and calls
device-mapper, device-mapper should log to stderr instead of stdout,
just like multipath does now.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agokpartx: fix new memory leak in dm_find_part
Benjamin Marzinski [Thu, 11 Oct 2018 20:43:48 +0000 (15:43 -0500)]
kpartx: fix new memory leak in dm_find_part

While commit 960bb238 fixed one memory leak, it created another.

Fixes: 960bb238 ("kpartx: Fix memory leak of uuid found by coverity")
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11 days agolibmultipath: free allocated value in set_int
Benjamin Marzinski [Thu, 11 Oct 2018 20:43:47 +0000 (15:43 -0500)]
libmultipath: free allocated value in set_int

set_int() needs to free the buffer it got back from set_value()

Fixes: 8f9ac30d ("libmultipath: fix set_int error path")
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agoBump version to 0.7.8 0.7.8
Christophe Varoqui [Wed, 10 Oct 2018 06:12:21 +0000 (08:12 +0200)]
Bump version to 0.7.8

13 days agolibmultipath: Fixup updating paths
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:16 +0000 (18:03 -0500)]
libmultipath: Fixup updating paths

Commit 582c56cc broke some code paths in uev_update_path. First, it
changed the handling of paths that were not fully initialized.
uev_update_path was simply setting the wwids for all of these paths.
Instead, it should ignore the ones that had not requested a new uevent.
These paths are likely down, and are already getting handled by
check_path, after it verifies that they have become active. Also,
setting the wwid doesn't update all of the other information that
may have been missed when the path was initially added.

Also, it wasn't possible for pp->wwid_changed to transition back to
zero, unless the path's wwid was empty, in which case there was no
reason to worry about the wwid change in the first place, since the path
hadn't been fully initialized yet. So, even if a path's wwid changed and
then changed back to the original value, the path still could not be
used.

This patch fixes these issues, and also moves the check for paths that
have requested a new uevent up in the functions. These paths will get
fully reinitialized anyway, so there is no reason to do all the other
work first.

Fixes: 582c56cc ("libmultipath: uev_update_path: always warn if WWID
changed")

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: Don't blank intialized paths
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:15 +0000 (18:03 -0500)]
libmultipath: Don't blank intialized paths

When pathinfo fails for some likely transient reason, it clears the path
wwid, but otherwise returns successfully, to keep the path around but
not usable until it gets fully initialized. However, if the path has
already been initialized, and pathinfo hits a transient error, it
shouldn't clear the wwid.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agomultipathd: fix memory leak on error in configure
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:14 +0000 (18:03 -0500)]
multipathd: fix memory leak on error in configure

If configure fails after allocing mpvec, it must free it. Found by
coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agomultipathd: remove useless check and fix format
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:13 +0000 (18:03 -0500)]
multipathd: remove useless check and fix format

The only thing this patch changes is to remove the check for pp->mpp
before the check for pp->mpp->prflags, since check_path() already
verified that pp->mpp != NULL. This fixes a number of coverity warnings.
Also, I normalized the spacing and indenting of the nearby code.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agomultipathd: minor fixes
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:12 +0000 (18:03 -0500)]
multipathd: minor fixes

In update_multipath(), conf is set again in a couple of lines, and
nothing uses it before then, so there's no point in setting it twice.
Also, in ev_remove_path(), strncpy() could end up unterminated, so
use strlcpy() instead.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agomultipathd: function return value tweaks
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:11 +0000 (18:03 -0500)]
multipathd: function return value tweaks

In cli_add_map() the return value of get_refwwid is never used, and
refwwid is checked to see if the function returned successfully, so the
return value doesn't need to be saved.

In resize_map, if setup_map fails, multipathd shouldn't attempt to
create the device with resulting params string. It should just fail
instead. Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agomultipath: fix max array size in print_cmd_valid
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:10 +0000 (18:03 -0500)]
multipath: fix max array size in print_cmd_valid

The code is attempting to verify that 0 <= k < 3
However, sizeof(val) is 12, assuming 4 byte integers. The check needs to
take integer size into account. Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmutipath: don't use malformed uevents
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:09 +0000 (18:03 -0500)]
libmutipath: don't use malformed uevents

A uevent that doesn't include the ACTION and DEVPATH fields is
malformed. It should be ignored, instead of used with those fields being
NULL.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix null dereference int alloc_path_group
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:08 +0000 (18:03 -0500)]
libmultipath: fix null dereference int alloc_path_group

If all_pathgroup failed to allocate a vector for pgp->paths, instead of
failing after it freed pgp, it would set pgp to NULL and then
dereference it. This patch fixes that. Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix memory issue in path_latency prio
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:07 +0000 (18:03 -0500)]
libmultipath: fix memory issue in path_latency prio

The path_latency prioriziter was assuming that prepare_directio_read()
always succeeds. However, it doesn't, and when it fails, the prioritizer
used buf without it pointing to alloced memory. Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: remove unused code
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:06 +0000 (18:03 -0500)]
libmultipath: remove unused code

since vector_foreach_slot() already checks if the entry is NULL, there's
no point in checking it in the loop, since it can't be NULL there. Found
by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: _install_keyword cleanup
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:05 +0000 (18:03 -0500)]
libmultipath: _install_keyword cleanup

_install_keyword should use VECTOR_LAST_SLOT(), which has better error
checking. It should also fail if it gets a NULL pointer, instead of
dereferencing it. Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix length issues in get_vpd_sgio
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:04 +0000 (18:03 -0500)]
libmultipath: fix length issues in get_vpd_sgio

When get_vpd_sgio() finds out that the vpd info needed to be truncated
to fit in the buffer, it doesn't trucate the size as well,  which allows
it to overwrite the buffer. Also, in once len is set to -ENODATA,
get_vpd_sgio() should exit, instead of using the negative len in
memcpy(). Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix set_int error path
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:03 +0000 (18:03 -0500)]
libmultipath: fix set_int error path

set_int() wasn't checking if the line actually had a value before
converting it to an integer.  Found by coverity. Also, it should
be using set_value().

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix tur checker timeout issue
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:02 +0000 (18:03 -0500)]
libmultipath: fix tur checker timeout issue

If the tur checker is run, and the tur_thread has timed out,
libcheck_check() doesn't actually check if the thread is still running.
This means that the thread could have already completed successfully,
but the tur checker would still return PATH_TIMEOUT, instead of the
value returned by the thread. This patch makes libcheck_check() actually
check if the thread completed, and if so, it returns the proper value.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: cleanup tur locking
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:01 +0000 (18:03 -0500)]
libmultipath: cleanup tur locking

There are only three variables whose access needs to be synchronized
between the tur thread and the path checker itself: state, message, and
active.  The rest of the variables are either only written when the tur
thread isn't running, or they aren't accessed by the tur thread, or they
are atomics that are themselves used to synchronize things.

This patch limits the amount of code that is covered by ct->lock to
only what needs to be locked. It also makes ct->lock no longer a
recursive lock. To make this simpler, tur_thread now only sets the
state and message one time, instead of twice, since PATH_UNCHECKED
was never able to be returned anyway.

One benefit of this is that the tur checker thread gets more time to
call tur_check() and return before libcheck_check() gives up and
return PATH_PENDING.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix tur memory misuse
Benjamin Marzinski [Tue, 9 Oct 2018 23:03:00 +0000 (18:03 -0500)]
libmultipath: fix tur memory misuse

when tur_thread() was calling tur_check(), it was passing ct->message as
the copy argument, but copy_msg_to_tcc() was assuming that it was
getting a tur_checker_context pointer. This means it was treating
ct->message as ct. This is why the tur checker never printed checker
messages. Intead of simply changing the copy argument passed in, I just
removed all the copying code, since it is completely unnecessary. The
callers of tur_check() can just pass in a buffer that it is safe to
write to, and copy it later, if necessary.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix tur checker double locking
Benjamin Marzinski [Tue, 9 Oct 2018 23:02:59 +0000 (18:02 -0500)]
libmultipath: fix tur checker double locking

tur_devt() locks ct->lock. However, it is ocassionally called while
ct->lock is already locked. In reality, there is no reason why we need
to lock all the accesses to ct->devt. The tur checker only needs to
write to this variable one time, when it first gets the file descripter
that it is checking. This patch sets ct->devt in libcheck_init() when it
is first initializing the checker context. After that, ct->devt is only
ever read.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agolibmultipath: fix tur checker timeout
Benjamin Marzinski [Tue, 9 Oct 2018 23:02:58 +0000 (18:02 -0500)]
libmultipath: fix tur checker timeout

The code previously was timing out mode if ct->thread was 0 but
ct->running wasn't. This combination never happens.  The idea was to
timeout if for some reason the path checker tried to cancel the thread,
but it didn't die.  The correct thing to check for this is ct->holders.
ct->holders will always be at least one when libcheck_check() is called,
since libcheck_free() won't get called until the device is no longer
being checked. So, if ct->holders is 2, that means that the tur thread
is has not shut down yet.

Also, instead of timing out, the tur checker will switch to synchronous
mode.  The chance of this code path happening is very low.  I simply
exists because the old thread must not interfere with a new thread
starting up. But if something does go very wrong, and a thread does get
stuck, this solution will keep the checker from just ignoring the device
forever.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
13 days agokpartx: Use absolute paths to create mappings
Stef Walter [Sat, 6 Oct 2018 07:38:56 +0000 (09:38 +0200)]
kpartx: Use absolute paths to create mappings

kpartx -d now uses absolute paths to delete mappings, since the
commit 9bdfa3eb8e24b668e6c2bb882cddb0ccfe23ed5b. We should use
those same absolute paths to create the mappings.

Without this patch, the following workflow (as seen in the
manual page for kpartx) fails to actually remove the devices:

    # kpartx -av disk.img
    ...
    # kpartx -d disk.img

13 days agomultipath-tools: sync third-party headers with valgrind-3.14
Xose Vazquez Perez [Tue, 9 Oct 2018 22:37:14 +0000 (00:37 +0200)]
multipath-tools: sync third-party headers with valgrind-3.14

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 weeks agolibmultipath: fix gcc 8.1 "truncated output" warnings
Martin Wilck [Mon, 8 Oct 2018 09:38:21 +0000 (11:38 +0200)]
libmultipath: fix gcc 8.1 "truncated output" warnings

gcc 8.1 was warning about a possibly truncated output in snprintf.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks ago(lib)mpathpersist: use O_RDONLY file descriptors
Martin Wilck [Mon, 8 Oct 2018 09:38:20 +0000 (11:38 +0200)]
(lib)mpathpersist: use O_RDONLY file descriptors

udevd catches close-after-write inotify events and generates "change"
uvents for such devices, which may cause extra unnecessary and unwanted
udev activity.

Therefore use O_RDONLY file descriptors for PRIN and PROUT commands. This
works just as well as O_WRONLY. sg_persist has supported the --readonly option
for years.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmpathpersist: fix byte swapping for big endian systems
Martin Wilck [Mon, 8 Oct 2018 09:38:19 +0000 (11:38 +0200)]
libmpathpersist: fix byte swapping for big endian systems

The functions "mpath_reverse_uintXY_byteorder"  were apparently meant to
convert BE integers to native. This leads to wrong results on big-endian
systems. Make these functions use the get_unaligned_beXY API, and rename.

Also, remove the unused endianness test in mpath_pr_ioctl.c.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agomultipath-tools/tests: add tests for get_unaligned_beXX
Martin Wilck [Mon, 8 Oct 2018 09:38:18 +0000 (11:38 +0200)]
multipath-tools/tests: add tests for get_unaligned_beXX

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmultipath: add (get|put)_unaligned_be64
Martin Wilck [Mon, 8 Oct 2018 09:38:17 +0000 (11:38 +0200)]
libmultipath: add (get|put)_unaligned_be64

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmpathpersist: fix stack overflow in mpath_format_readfullstatus()
Martin Wilck [Mon, 8 Oct 2018 09:38:16 +0000 (11:38 +0200)]
libmpathpersist: fix stack overflow in mpath_format_readfullstatus()

Some storage arrays return corrupt data in response to READ FULL STATUS
PRIN commands. This may lead to stack overflow if the values aren't
sanitized.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmpathpersist: fix typo in mpath_format_readfullstatus
Martin Wilck [Mon, 8 Oct 2018 09:38:15 +0000 (11:38 +0200)]
libmpathpersist: fix typo in mpath_format_readfullstatus

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmpathpersist: remove duplicate test in readfullstatus
Martin Wilck [Mon, 8 Oct 2018 09:38:14 +0000 (11:38 +0200)]
libmpathpersist: remove duplicate test in readfullstatus

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agomultipath-tools: refresh kernel-doc from kernel sources
Xose Vazquez Perez [Sat, 18 Aug 2018 20:38:52 +0000 (22:38 +0200)]
multipath-tools: refresh kernel-doc from kernel sources

Cc: Gris Ge <fge@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 weeks agomultipath-tools: tests/hwtable: test hidden devices
Martin Wilck [Tue, 2 Oct 2018 18:47:01 +0000 (20:47 +0200)]
multipath-tools: tests/hwtable: test hidden devices

Add a test for skipping "hidden" devices.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agomultipath/tests: fix hwtable tests after "hidden" support
Martin Wilck [Tue, 2 Oct 2018 18:47:00 +0000 (20:47 +0200)]
multipath/tests: fix hwtable tests after "hidden" support

The previous patch "libmultipath: pathinfo: skip hidden devices"
requires a change in the pathinfo mocking code. Otherwise the hwtable
tests will fail.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agomultipathd: try SCSI persistent reservations for SCSI only
Martin Wilck [Mon, 1 Oct 2018 18:45:07 +0000 (20:45 +0200)]
multipathd: try SCSI persistent reservations for SCSI only

This avoids error messages when PERSISTENT RESERVE IN ioctls
are tried on non-SCSI devices.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmultipath: allow sysfs_pathinfo to return SKIPPED
Martin Wilck [Mon, 1 Oct 2018 18:45:06 +0000 (20:45 +0200)]
libmultipath: allow sysfs_pathinfo to return SKIPPED

The sysfs_pathinfo() code path can't distinguish between real
failure and a devices that have to be skipped. One example
for this are NVMe native multipath devices. This may cause
lots of irritating log messages.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agomultipathd: decrease log level of uevent messages
Martin Wilck [Fri, 14 Sep 2018 12:51:03 +0000 (14:51 +0200)]
multipathd: decrease log level of uevent messages

The messages "multipathd: add path (uevent)" etc. are displayed
frequently, and often for devices that don't matter for multipathd.
If real action needs to be taken, such as adding or removing paths
or maps from the internal structures, multipathd emits other log
messages at level 2 later on.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agomultipathd: fix version check for DM_DEV_ARM_POLL ioctl
Martin Wilck [Fri, 14 Sep 2018 12:51:02 +0000 (14:51 +0200)]
multipathd: fix version check for DM_DEV_ARM_POLL ioctl

Make sure the checks in dmevent_poll_supported() and
arm_dm_event_poll() use the same logic. Currently, the
version check check fails in arm_dm_event_poll() if
libdevmapper's DM_VERSION is newer than the kernel's.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmultipath: pathinfo: skip hidden devices
Martin Wilck [Fri, 14 Sep 2018 12:51:01 +0000 (14:51 +0200)]
libmultipath: pathinfo: skip hidden devices

Hidden block devices (in practice: members of nvme native multipath
devices) can't be used by multipath anyway. Current multipath code
(with default blacklisting) skips them, too, but emits a misleading
"blacklisted: udev property missing" message.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmultipath: nvme: shorter topology output
Martin Wilck [Fri, 14 Sep 2018 12:51:00 +0000 (14:51 +0200)]
libmultipath: nvme: shorter topology output

The nvme foreign code maps the NVMe subsys NQN to the "%n"
wildcard ("alias"). Some real-world devices use very lengthy
expressions for the subsys NQN (counted 95 characters on one
system here), making the "multipath -ll" output hardly readable
for humans. Use a shorter and more concise printout instead,
based on the WWID only.

The subsys NQN is still available via the "%n" wildcard:
"multipathd show maps format %n".

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 weeks agolibmultipath: nvme: fix path detection for kernel 4.16
Martin Wilck [Fri, 14 Sep 2018 12:50:59 +0000 (14:50 +0200)]
libmultipath: nvme: fix path detection for kernel 4.16

The path detection logic of the NVMe code relies on the "slaves"
symlinks from NVMe subsys to controllers in sysfs, which have
been removed in the 4.16 kernel.

With this patch, we use the symlinks on the NVMe subsys level
instead.

Example: a multipathed NVMe subsystem with 2 controllers:

/sys/devices/virtual/nvme-subsystem/nvme-subsys2/nvme2n1
/sys/devices/virtual/nvme-fabrics/ctl/nvme2/nvme2c6n1
/sys/devices/virtual/nvme-fabrics/ctl/nvme3/nvme2c8n1

The controllers are found from the subsystem like this:

/sys/devices/virtual/nvme-subsystem/nvme-subsys2/nvme2 ->
    ../../nvme-fabrics/ctl/nvme2
/sys/devices/virtual/nvme-subsystem/nvme-subsys2/nvme3 ->
    ../../nvme-fabrics/ctl/nvme3

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: reformat maintainer info
Xose Vazquez Perez [Sun, 1 Jul 2018 15:55:38 +0000 (17:55 +0200)]
multipath-tools: reformat maintainer info

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: update Hitachi maintainer email
Xose Vazquez Perez [Tue, 26 Jun 2018 13:52:31 +0000 (15:52 +0200)]
multipath-tools: update Hitachi maintainer email

Cc: Matthias Rudolph <Matthias.Rudolph@hitachivantara.com>
Cc: Matthias Rudolph <matthias.rudolph@hds.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agokpartx: remove duplicated gpt validation check
Benjamin Marzinski [Wed, 1 Aug 2018 20:57:01 +0000 (15:57 -0500)]
kpartx: remove duplicated gpt validation check

The identical check exists twice in a row.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agokpartx: fix bad dm_devn return
Benjamin Marzinski [Wed, 1 Aug 2018 20:57:00 +0000 (15:57 -0500)]
kpartx: fix bad dm_devn return

dm_devn shouldn't be returning success if you can't create a dm task to
find the device info. Found by coverity.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agokpartx: Fix memory leak of uuid found by coverity
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:59 +0000 (15:56 -0500)]
kpartx: Fix memory leak of uuid found by coverity

After the call to make_prefixed_uuid() allocs uuid, it must be freed if
dm_find_part() fails.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agokpartx: minor fixes to make coverity happy
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:58 +0000 (15:56 -0500)]
kpartx: minor fixes to make coverity happy

an open() failure for fd_dasd will return -1, not 0. Also, cast blocksize
to a uint64_t to keep coverity from complaining about sign extension issues.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agompathpersist: add missing --param-rk usage info
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:57 +0000 (15:56 -0500)]
mpathpersist: add missing --param-rk usage info

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath tests: add blacklist tests
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:56 +0000 (15:56 -0500)]
multipath tests: add blacklist tests

These are tests to validate the filter_* blacklist functions. They not
only verify that the device is correctly blacklisted/whitelisted, but
they also verify the log messages that are printed out.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath tests: change to work with old make versions
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:55 +0000 (15:56 -0500)]
multipath tests: change to work with old make versions

the $(file <) operation only works with make 4.2 and above. I tried
running the tests on an old machine and it failed. The $shell function
can do the same thing and multipath has been using that in its
Makefiles for a while.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: remove _filter_* blacklist functions
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:54 +0000 (15:56 -0500)]
libmultipath: remove _filter_* blacklist functions

The one point of these functions was for _filter_path(), and that wasn't
improved by using them. Since filter_path() only printed one message at
the end, you could have situations where the wwid was blacklisted, but
the blacklist message included the vendor/product instead. Also, the
protocol and property messages were printed twice, and if the device was
on multiple whitelists, only the last one is printed.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: add "protocol" blacklist option.
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:53 +0000 (15:56 -0500)]
libmultipath: add "protocol" blacklist option.

Multiple users have requested an easy way to setup blacklists that do
things such as blacklisting all non FC and iSCSI devices. Currently
there is no easy way to do this, without knowing in advance what the
devices are.  Looking into the udev property values, I didn't see a
consistent set of values that would worked for all the different types
of requests like this (which would have allowed us to solve this by
extending the "property" blacklist option to allow comparing values,
instead of just keywords).

Instead I've opted to allow multipath to blacklist/whitelist devices
by the protocol strings printed by "multipathd: add new protocol path
wildcard". This check happens after multipath checks the "device"
keyword, and before it checks wwid. This gives users an easily
understandible method to set up these types of blacklists, without
needing to know the exact arrays being used.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipathd: add new protocol path wildcard
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:52 +0000 (15:56 -0500)]
multipathd: add new protocol path wildcard

This patch adds a new path wildcard 'P', that will print the path's
protocol.  For scsi devices, it will additionally print the transport
protocol being used.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmutipath: remove unused IDE bus type
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:51 +0000 (15:56 -0500)]
libmutipath: remove unused IDE bus type

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agompathpersist: add --param-alltgpt option
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:50 +0000 (15:56 -0500)]
mpathpersist: add --param-alltgpt option

From the limited testing I've been able to do, commit 5b54e772
"mpathpersist: add all_tg_pt option", does appear to enable
--param-alltgpt to work correctly on devices that accept the ALL_TG_PT
flag, so I've added the option to mpathpersist.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath: fix setting conf->version
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:49 +0000 (15:56 -0500)]
multipath: fix setting conf->version

Commit d3b71498 stopped multipath from setting conf->version. Instead,
it was always being set to 0.0.0. Multipathd was still setting this
correctly.

Fixes: d3b71498 "multipath: fix rcu thread cancellation hang"
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: fix detect alua corner case
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:48 +0000 (15:56 -0500)]
libmultipath: fix detect alua corner case

If retain_attach_hw_handler = no, then the paths tpgs state will never
be checked, and the multipath device will always select the alua
handler, if no other handler is selected. the paths tpgs state
should be checked, regardless of the retain_hwhandler value.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: remove last of rbd code
Benjamin Marzinski [Wed, 1 Aug 2018 20:56:47 +0000 (15:56 -0500)]
libmultipath: remove last of rbd code

My previous patch to remove the rbd code missed a little bit.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath-tools: check for C compiler option -Werror=discarded-qualifiers
Mauricio Faria de Oliveira [Mon, 30 Jul 2018 19:37:45 +0000 (16:37 -0300)]
multipath-tools: check for C compiler option -Werror=discarded-qualifiers

The -Werror=discarded-qualifiers option is not supported on GCC 4.8
(ships in Ubuntu 14.04 at least). Use TEST_CC_OPTION to detect that
and fix a build failure.

No regression on Ubuntu 18.04 (GCC 7.3, -Werror=discarded-qualifiers
used).

Fixes: ff307801
"multipath-tools: Makefile.inc: use -Werror=cast-qual"

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
2 months agomultipath-tools: fix compilation with gcc < 4.9 on dash shell
Mauricio Faria de Oliveira [Mon, 30 Jul 2018 19:37:44 +0000 (16:37 -0300)]
multipath-tools: fix compilation with gcc < 4.9 on dash shell

The dash shell does not interpret '&>' as bash does, so instead
of stdout/stderr redirect, it runs the command in background [1].

    $ for shell in bash dash; do
        echo -n "$shell rc = "
        $shell -c 'echo "int main(void){return 0;}" \
                     | gcc -o /dev/null -c -fFAIL -xc - &>/dev/null; echo $?';
      done
    bash rc = 1
    dash rc = 0
    $ gcc: error: unrecognized command line option ‘-fFAIL’

This misleads the check for C compiler option in Makefile.inc
on Ubuntu 14.04 at least, which uses dash as /bin/sh, and has
GCC 4.8 (no -fstack-protector-strong), then the build fails.

So, replace '&>' with the equivalent '>' and '>&2'.

No regression on Ubuntu 18.04 (GCC 7.3, -fstack-protector-strong used).

Fixes: a8dd838c
"multipath-tools: fix compilation with gcc < 4.9"

[1] https://wiki.ubuntu.com/DashAsBinSh (see '&>' section)

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
2 months agokpartx: compare image filenames with backing files
Yuval Turgeman [Mon, 16 Jul 2018 12:52:13 +0000 (15:52 +0300)]
kpartx: compare image filenames with backing files

When running `kpartx -d`, find_loop_by_file tries to compare the image's
realpath with the output from loopinfo.lo_name, which may hold only the
basename of the image, making kpartx exit without finding the loopdev
for the image.

In case the original comparison fails, this patch will check the image's
realpath with the loop device's backing_file so that find_loop_by_file
will return the correct value.

Signed-off-by: Yuval Turgeman <yturgema@redhat.com>
2 months agomultipath-tools: fix products names in hwtable
Xose Vazquez Perez [Thu, 5 Jul 2018 18:55:05 +0000 (20:55 +0200)]
multipath-tools: fix products names in hwtable

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agolibmultipath: more debug output in alua prioritizer
Martin Wilck [Tue, 3 Jul 2018 07:57:07 +0000 (09:57 +0200)]
libmultipath: more debug output in alua prioritizer

Help debug problems with ALUA commands by emitting more
meaningful error messages.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: alua: retry RTPG for NOT_READY and UNIT_ATTENTION
Martin Wilck [Tue, 3 Jul 2018 07:57:06 +0000 (09:57 +0200)]
libmultipath: alua: retry RTPG for NOT_READY and UNIT_ATTENTION

Use similar logic as the kernel for retrying ALUA commands to
avoid misinterpreting temporary failures as fatal errors.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: alua_rtpg: use condlog for error messages
Martin Wilck [Tue, 3 Jul 2018 07:57:05 +0000 (09:57 +0200)]
libmultipath: alua_rtpg: use condlog for error messages

Map the PRINT_DEBUG macro of the ALUA code to a condlog call, to
be able to better debug SCSI error conditions.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: allow distributions to change partition_delim default
Martin Wilck [Mon, 25 Jun 2018 19:47:23 +0000 (21:47 +0200)]
libmultipath: allow distributions to change partition_delim default

partition_delimiter is UNSET by default, falling back to the kernel
default behavior to use "p" for devices ending in a digit, and ""
for others. However, the udev rules for kpartx have always used the
delimiter "-part". If a map name is changed (e.g. if an alias is
reconfigured), multipathd first sets partition names e.g. to name "mpatha1",
which is later changed to "mpatha-part1" by kpartx during udev rule
processing. That's inefficient and superfluous. However, if a distribution
simply changed DEFAULT_PARTITION_DELIM to "-part", users wouldn't be able
to restore the default behavior any more.

This patch allows to set 'partition_delimiter "/UNSET/"' in multipath.conf
to force the previous default behavior, even if the distribution default is
something other than UNSET. The string "/UNSET/" is not a valid partition
delimiter because filenames can't contain slashes, thus user freedom isn't
constrained by this patch.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: avoid error messages from RDAC check
Martin Wilck [Sun, 24 Jun 2018 19:09:44 +0000 (21:09 +0200)]
libmultipath: avoid error messages from RDAC check

VPD pages are only valid for SCSI devices, so we should disable
the RDAC detection for non-SCSI devices. Otherwise we'll get
an error about VPD inquiry failed.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipathd: fix buffer size in cli_getprkey()
Martin Wilck [Sun, 24 Jun 2018 19:09:43 +0000 (21:09 +0200)]
multipathd: fix buffer size in cli_getprkey()

gcc 8.1 warned about this.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools: add info about how to enable ALUA in ONTAP
Xose Vazquez Perez [Sat, 30 Jun 2018 23:02:55 +0000 (01:02 +0200)]
multipath-tools: add info about how to enable ALUA in ONTAP

Cc: Martin George <marting@netapp.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: add directio path_checker for DASD devices
Xose Vazquez Perez [Sat, 30 Jun 2018 22:50:01 +0000 (00:50 +0200)]
multipath-tools: add directio path_checker for DASD devices

tur(default) is only for SCSI devices.

CC: Hannes Reinecke <hare@suse.de>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: make Product Name mandatory and add all of them
Xose Vazquez Perez [Fri, 29 Jun 2018 21:22:45 +0000 (23:22 +0200)]
multipath-tools: make Product Name mandatory and add all of them

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath: fix return code handling in delegate_to_multipathd
Martin Wilck [Thu, 28 Jun 2018 10:34:46 +0000 (12:34 +0200)]
multipath: fix return code handling in delegate_to_multipathd

Error exit was handled in delegate_to_multipathd() and success
exit after it returned. That's inconsistent. Fix it. Introduce
symbolic return values for better readability.

Fixes: 506d253b "multipath: delegate dangerous commands to multipathd"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath: don't start multipathd unnecessarily
Martin Wilck [Thu, 28 Jun 2018 10:34:45 +0000 (12:34 +0200)]
multipath: don't start multipathd unnecessarily

When multipathd is off, but systemd is monitoring the multipathd socket,
mpath_connect() has the side effect of starting multipathd. That's
superfluous if we aren't going to pass the command at hand to multipathd.
So, only try to open the socket if the command at hand is a candidate
for delegation.

Note: Despite this, some day in the future, we may decide to delegate
almost everything to multipathd.

Fixes: 506d253b "multipath: delegate dangerous commands to multipathd"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipathd: fix mpp->hwe handling on path removal
Martin Wilck [Mon, 25 Jun 2018 15:10:20 +0000 (17:10 +0200)]
multipathd: fix mpp->hwe handling on path removal

In my previous patch f0462f0c8338, I overlooked that during path removal,
the path that mpp->hwe references may be removed and and thus mpp->hwe
may become stale. Fix it.

Fixes: f0462f0c8338 "libmultipath: use vector for for pp->hwe and mp->hwe"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: print correct default for delay_*_checks
Benjamin Marzinski [Wed, 16 May 2018 22:43:26 +0000 (17:43 -0500)]
libmultipath: print correct default for delay_*_checks

These options default to "no", so they should display that when the
config is printed.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
4 months agomultipath-tools: fix help for hds prio
Xose Vazquez Perez [Mon, 21 May 2018 20:03:55 +0000 (22:03 +0200)]
multipath-tools: fix help for hds prio

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
4 months agomultipath-tools: remove unused SCSI_REV_SIZE
Xose Vazquez Perez [Fri, 15 Jun 2018 14:44:35 +0000 (16:44 +0200)]
multipath-tools: remove unused SCSI_REV_SIZE

It was replaced in 00ee0bda40f8b6ac060211c36a419c699af7f778

Cc: Martin Wilck <mwilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
4 months agoFix lintian complaint about bad whatis entry
Vincent McIntyre [Fri, 15 Jun 2018 14:17:40 +0000 (16:17 +0200)]
Fix lintian complaint about bad whatis entry

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Vincent McIntyre <vincent.mcintyre@csiro.au>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
4 months agofixup "libmultipath: merge hwentries inside a conf file"
Martin Wilck [Mon, 18 Jun 2018 09:54:36 +0000 (11:54 +0200)]
fixup "libmultipath: merge hwentries inside a conf file"

The previous patch "libmultipath: merge hwentries inside a conf file"
meant to enable checking for duplicate entries not only between different
"sections" of the configuration (i.e. built-in hwtable, multipath.conf,
config dir files), but also inside every section except the built-in
table. This patch fixes a bug to actually implement this new behavior.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agotests/hwtable: add test for broken hwentry filtering
Martin Wilck [Mon, 18 Jun 2018 09:54:35 +0000 (11:54 +0200)]
tests/hwtable: add test for broken hwentry filtering

Broken hwentries weren't correctly filtered after patch
"libmultipath: merge hwentries inside a conf file". Add a test
case for that.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agomultipath.conf(5): various corrections and clarifications
Martin Wilck [Fri, 8 Jun 2018 10:20:41 +0000 (12:20 +0200)]
multipath.conf(5): various corrections and clarifications

... related to the topics of option precedence, and config file syntax
in general.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agolibmultipath: escape '"' chars while dumping config
Martin Wilck [Fri, 8 Jun 2018 10:20:40 +0000 (12:20 +0200)]
libmultipath: escape '"' chars while dumping config

Since 044c5d6b "libmultipath: config parser: Allow '"' in strings",
double quotes can be part of string values in multipath.conf by escaping
them as double-double quotes ('""'). When dumping the configuration,
the un-escaping done during config file parsing must be reverted by replacing
'"' with '""' again.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agolibmultipath: implement and use blacklist merging
Martin Wilck [Fri, 8 Jun 2018 10:20:39 +0000 (12:20 +0200)]
libmultipath: implement and use blacklist merging

Implement removal of invalid and duplicate entries in blacklists.

With this fix, we can fully enable the config dump/reload test,
which doesn't fail any more.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agolibmultipath: merge "multipath" config sections by wwid
Martin Wilck [Fri, 8 Jun 2018 10:20:38 +0000 (12:20 +0200)]
libmultipath: merge "multipath" config sections by wwid

If more than one "multipath" section exists for a given wwid,
only the properties from the first section are applied, and
those of the later ones are silently discarded.

Fix this by merging mpentries in the same way we do it for hwentries.
Actually, later entries should take precedence, for consistency with
hwentry handling.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agomultipath: implement "multipath -T"
Martin Wilck [Fri, 8 Jun 2018 10:20:37 +0000 (12:20 +0200)]
multipath: implement "multipath -T"

This does the same as "multipathd show config local", and is
provided for convenience.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 months agomultipathd: implement "show config local"
Martin Wilck [Fri, 8 Jun 2018 10:20:36 +0000 (12:20 +0200)]
multipathd: implement "show config local"

This new command is like "show config", but only those "device" sections are
dumped that match actually present devices in the system. Furthermore, empty
"multipath" sections for all detected multipath maps are dumped. This way,
the output is suitable as a template for creating "multipath.conf".

"multipathd show config local" should produce output that,
when used as configuration file, creates the same configuration
as was in place while it was dumped. Add a test for this to the
test suite.

Some minor differences in the configuration dump can't be avoided
because the ordering of hwtable entries may change (e.g. if a user
adds a device entry for a device which is also in the built-in hwtable,
these entries will be merged end the merged entry will be at the position
of the new entry, i.e. after all built-in hwtable entries), and multipath
sections are added to the configuration. But by all means, path
and mulitpath objects should have the same properties than before.

Signed-off-by: Martin Wilck <mwilck@suse.com>