multipath-tools/.git
2 years agolibmultipath: rdac checker: leave unsupported paths alone
Martin Wilck [Fri, 2 Nov 2018 12:21:19 +0000 (13:21 +0100)]
libmultipath: rdac checker: leave unsupported paths alone

A checker shouldn't set the path state to PATH_DOWN if it fails
to obtain information about the path in the first place. Add logic
to the checker to distinguish a failed path from an unsupported path.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath: hp_sw checker: leave unsupported paths alone
Martin Wilck [Fri, 2 Nov 2018 12:21:18 +0000 (13:21 +0100)]
libmultipath: hp_sw checker: leave unsupported paths alone

A checker shouldn't set the path state to PATH_DOWN if it fails
to obtain information about the path in the first place. Add logic
to the checker to distinguish a failed path from an unsupported path.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath: clariion checker: leave unsupported paths alone
Martin Wilck [Fri, 2 Nov 2018 12:21:17 +0000 (13:21 +0100)]
libmultipath: clariion checker: leave unsupported paths alone

A checker shouldn't set the path state to PATH_DOWN if it fails
to obtain information about the path in the first place. Add logic
to the checker to distinguish a failed path from an unsupported path.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: support unsupported paths
Martin Wilck [Fri, 2 Nov 2018 12:21:16 +0000 (13:21 +0100)]
libmultipath/checkers: support unsupported paths

We should be able to distinguish the case where a checker
determines a path to be positively down from the case where
the checker fails to obtain necessary information, e.g.
because of a configuration problem (wrong checker).
Use PATH_WILD for the latter case, as it's hardly used now.

Provide a generic message for the situation that a path
checker can't handle a certain path.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agomultipathd: improve checker message logging
Martin Wilck [Fri, 2 Nov 2018 12:21:15 +0000 (13:21 +0100)]
multipathd: improve checker message logging

Don't rely on any variables being defined in LOG_MSG.
If message log level is low, don't bother to fetch the message.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: tur: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:14 +0000 (13:21 +0100)]
libmultipath/checkers: tur: use message id

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: readsector0: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:13 +0000 (13:21 +0100)]
libmultipath/checkers: readsector0: use message id

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: rdac: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:12 +0000 (13:21 +0100)]
libmultipath/checkers: rdac: use message id

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: hp_sw: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:11 +0000 (13:21 +0100)]
libmultipath/checkers: hp_sw: use message id

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: emc_clariion: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:10 +0000 (13:21 +0100)]
libmultipath/checkers: emc_clariion: use message id

emc_clariion is the only path checker that was using a non-constant
message ("read error" case). This isn't possible with the msgid
approach any more. Use condlog() for the dynamic log message and
simply report "read error" as checker message.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: directio: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:09 +0000 (13:21 +0100)]
libmultipath/checkers: directio: use message id

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: cciss_tur: use message id
Martin Wilck [Fri, 2 Nov 2018 12:21:08 +0000 (13:21 +0100)]
libmultipath/checkers: cciss_tur: use message id

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath/checkers: replace message by msgid
Martin Wilck [Fri, 2 Nov 2018 12:21:07 +0000 (13:21 +0100)]
libmultipath/checkers: replace message by msgid

Replace the character array "message" in struct checker with
a "message ID" field.

The generic checker code defines a couple of standard message IDs
and corresponding messages. Checker-specific message IDs start
at CHECKER_FIRST_MSG. Checkers that implement specific message
IDs must provide a table for converting the IDs into actual log
messages.

This simplifies the checker data structure and the handling of
checker messages in the critical checker code path. It comes at
the cost that only constant message strings are supported. It
turns out that only a single checker log message (in the emc_clariion
checker) was dynamically generated, and the missing information can
be provided with a standard condlog message.

Follow-up patches implement this for the existing checkers.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath: fix memory leaks from scandir() use
Martin Wilck [Fri, 2 Nov 2018 12:21:06 +0000 (13:21 +0100)]
libmultipath: fix memory leaks from scandir() use

scandir() users must not only free the resulting dirent* array,
but also every member. Add a cleanup function, and fix the
existing users of scandir() in libmultipath.

Add a small helper macro for casting function pointers to the
type pthread_cleanup_push() expects.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath: fix use of uninitialized memory in write()
Martin Wilck [Fri, 2 Nov 2018 12:21:05 +0000 (13:21 +0100)]
libmultipath: fix use of uninitialized memory in write()

valgrind complained about this.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agomultipath.8: fix description of "device" argument
Martin Wilck [Tue, 23 Oct 2018 13:43:48 +0000 (15:43 +0200)]
multipath.8: fix description of "device" argument

Describe the fact that we can refer to path devices by WWID, and
to multipath maps by devnode.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agomultipathd: improve "add missing path" handling
Martin Wilck [Tue, 23 Oct 2018 13:43:47 +0000 (15:43 +0200)]
multipathd: improve "add missing path" handling

Only add devices that have been properly initialized by pathinfo().
For others, increase the path check interval to avoid useless checks
of devices which are probably not meant to be multipathed anyway.

The check for pp->initialized != INIT_MISSING_UDEV is redundant,
as check_path() returns early in all other cases. Replace it by a
check for INIT_FAILED, in case we ever add more init states.

Suggested-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agomultipathd: handle repeated udev retrigger failure
Martin Wilck [Tue, 23 Oct 2018 13:43:46 +0000 (15:43 +0200)]
multipathd: handle repeated udev retrigger failure

If a path was still not properly initialized after exhausting the
retrigger tries, it used to remain in INIT_MISSING_UDEV state forever.
get_uid() might fall back to non-udev-based methods to determine
the WWID, but it would never be called for a path in this state any more.

This patch changes this behavior by resetting the path back to FAILED
state if udev can't provide the WWID even after retriggering. Now, if
the path ever happens to be in PATH_UP or PATH_GHOST state again,
pathinfo(DI_ALL) will be called from check_path(), and there's at least
some chance to obtain a WWID for it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath: handle TUR threads that can't be cancelled
Martin Wilck [Tue, 23 Oct 2018 13:43:45 +0000 (15:43 +0200)]
libmultipath: handle TUR threads that can't be cancelled

When the tur checker code determines that a hanging TUR thread
couldn't be cancelled, rather than simply returning, reallocate
the checker context and start a new thread. This will leak some
memory if the hanging thread never wakes up again, but well, in
that highly unlikely case we're leaking threads anyway.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agolibmultipath: test code for "zombie" TUR threads
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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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

2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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

2 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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>
2 years 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>
2 years 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>