multipath-tools/.git
3 weeks agoBump version to 0.8.3 master 0.8.3
Christophe Varoqui [Wed, 2 Oct 2019 07:15:03 +0000 (09:15 +0200)]
Bump version to 0.8.3

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

Tegile IntelliFlash was acquired by DDN, from WD.

HPE Primera is also identified as 3PARdata/VV

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Nexenta was acquired by DDN.

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

The manual page is more complete and detailed.

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

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

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

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

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

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

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

Got this config from Dell.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

multipathd path <path> setmarginal

and cleared by

multipathd path <path> unsetmarginal

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

multipathd map <map> unsetmarginal

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

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

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

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

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

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
3 weeks agolibmultipath: trigger uevents for partitions, too
Martin Wilck [Tue, 2 Jul 2019 22:09:42 +0000 (22:09 +0000)]
libmultipath: trigger uevents for partitions, too

We have added code to re-trigger uevents in various cases where
the status of a device changes from multipath to non-multipath,
or vice-versa. When multipathd triggers uevents for paths of a map
because the status of the map has changed, it needs to trigger
events for the partitions of the path devices, too. The kernel
doesn't do this automatically.

Fixes: c5023200 libmultipath: indicate wwid failure in dm_addmap_create()
Fixes: e5d3c3a0 libmultipath: trigger change uevent on new device creation
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agoBump version to 0.8.2 0.8.2
Christophe Varoqui [Wed, 3 Jul 2019 06:56:58 +0000 (08:56 +0200)]
Bump version to 0.8.2

3 months agomultipath.conf.5: Improve documentation of WWID determination
Martin Wilck [Mon, 24 Jun 2019 09:27:56 +0000 (11:27 +0200)]
multipath.conf.5: Improve documentation of WWID determination

Clarify the effect of setting uid_attrs, and document the effect of setting
uid_attribute to an empty string. Replace the arcane "vpd_pg83" with
something easier to understand. Tell the user that the defaults are
usually good enough.

Cc: Tang Junhui <tang.junhui@zte.com.cn>
Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: more cautious blacklisting by missing property
Martin Wilck [Mon, 24 Jun 2019 09:27:55 +0000 (11:27 +0200)]
libmultipath: more cautious blacklisting by missing property

If a tool likk sg_inq or scsi_id fails to access a device during uevent
processing, the required properties for whitelisting a device may be
missing. This causes the device to be blacklisted and permanently orphaned,
which is not desired.

Rather, blacklisting by missing properties is meant to ensure that the
WWID determined from udev properties is _reliable_. Therefore, blacklist
only devices that exhibit ID_SERIAL (or more generally, the configured
uid_attribute), but do not have the required whitelist properties set. This
will avoid the above-mentioned problem, because if failed device I/O was
causing properties to be missing, ID_SERIAL will most likely also not be set.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools tests: add test for uid_attrs parsing
Martin Wilck [Mon, 24 Jun 2019 09:27:54 +0000 (11:27 +0200)]
multipath-tools tests: add test for uid_attrs parsing

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix memory leak with "uid_attrs" config option
Martin Wilck [Mon, 24 Jun 2019 09:27:53 +0000 (11:27 +0200)]
libmultipath: fix memory leak with "uid_attrs" config option

pp->uid_attribute is normally just a pointer to memory that belongs
to the configuration. But if "uid_attrs" is used, it's a pointer
to strdup()d memory returned by parse_uid_attribute_by_attrs().
Consequently, this strdup()'d memory is never freed.

Fix this by splitting the uid_attrs string when the configuration is
read, and using just a refererence to this memory in pp->uid_attribute.
A side effect is that this makes the code more efficient in both
memory and CPU terms.

This requires a change for the uevents test, as uid_attrs must now be
set up differently.

Cc: Tang Junhui <tang.junhui@zte.com.cn>
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix has_uid_fallback() logic
Martin Wilck [Mon, 24 Jun 2019 09:27:52 +0000 (11:27 +0200)]
libmultipath: fix has_uid_fallback() logic

The idea of 061daf40 "Do not automatically fall back to vpd uid
generation" applies not only to SCSI. Use the same logic for NVMe.
Allow fallback in two cases:
 - uid_attribute has the default value for the bus in question
 - uid_attribute has been set to "" to disable udev-based WWID checking
As uid_fallback() has only one caller, no need to check the conditions
there again.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: get_uid: straighten the fallback logic
Martin Wilck [Mon, 24 Jun 2019 09:27:51 +0000 (11:27 +0200)]
libmultipath: get_uid: straighten the fallback logic

The code had two distinct fallback paths, with non-obvious logic.
Try to straighten it out. The "allow_fallback" logic from
ffaf9477d115 "multipathd: Don't use fallback code after getting wwid"
should only apply in the case where get_udev_uid() failed, not
if it wasn't even tried. Moreover, uid_attribute is hardly ever NULL
since ffaf9477; allow the user to set it to the empty string to
skip udev-based WWID determination. This is rather not meant for
production, but it's useful for testing. Finally, only set "origin"
to "udev" if a WWID was actually retrieved from udev.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: parse_vpd_pg80: fix whitespace handling
Martin Wilck [Mon, 24 Jun 2019 09:27:50 +0000 (11:27 +0200)]
libmultipath: parse_vpd_pg80: fix whitespace handling

According to the SPC spec, the unit serial number is right-aligned
ASCII. Thus leading whitespace must be skipped. Moreover, trailing
whitespace should be discarded before doing the length check.

Fixes: 756ef73b7197 "Separate out vpd parsing functions"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: parse_vpd_pg80: fix overflow output
Martin Wilck [Mon, 24 Jun 2019 09:27:49 +0000 (11:27 +0200)]
libmultipath: parse_vpd_pg80: fix overflow output

"vpd pg80 overflow, 20/20 bytes required" looks weird. Make it clear
that actually 21 bytes are required in this case.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix parsing of non-space-terminated T10 ID
Martin Wilck [Mon, 24 Jun 2019 09:27:48 +0000 (11:27 +0200)]
libmultipath: fix parsing of non-space-terminated T10 ID

If the T10 vendor specific ID doesn't end with spaces, the last
part won't be parsed. Fix it.

Fixes: 18176202e75c "Read wwid from sysfs vpg_pg83 attribute"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: allow zero-padded SCSI names in parse_vpd_pg83()
Martin Wilck [Mon, 24 Jun 2019 09:27:47 +0000 (11:27 +0200)]
libmultipath: allow zero-padded SCSI names in parse_vpd_pg83()

The spec says that SCSI name strings designator length must be a multiple of
4, and that strings must be zero-terminated and zero-padded.
Fix the returned string length if the VPD input ends with multiple 0-bytes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: parse_vpd_pg83: common code for SCSI string parsing
Martin Wilck [Mon, 24 Jun 2019 09:27:46 +0000 (11:27 +0200)]
libmultipath: parse_vpd_pg83: common code for SCSI string parsing

The three cases for eui, naa, and iqn parsing share almost all code.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: add consistent WWID overflow logging in parse_vpd_pg83
Martin Wilck [Mon, 24 Jun 2019 09:27:45 +0000 (11:27 +0200)]
libmultipath: add consistent WWID overflow logging in parse_vpd_pg83

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix parsing of SCSI name string, iqn format
Martin Wilck [Mon, 24 Jun 2019 09:27:44 +0000 (11:27 +0200)]
libmultipath: fix parsing of SCSI name string, iqn format

Do not overwrite the leading '8'.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix another WWID overflow in parse_vpd_pg83()
Martin Wilck [Mon, 24 Jun 2019 09:27:43 +0000 (11:27 +0200)]
libmultipath: fix another WWID overflow in parse_vpd_pg83()

This one is an obvious typo.

Fixes: 18176202e75c "Read wwid from sysfs vpg_pg83 attribute"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix possible WWID overflow in parse_vpd_pg83()
Martin Wilck [Mon, 24 Jun 2019 09:27:42 +0000 (11:27 +0200)]
libmultipath: fix possible WWID overflow in parse_vpd_pg83()

We have to check the remaining length before printing to the
output buffer, not afterwards.

Fixes: 18176202e75c "Read wwid from sysfs vpg_pg83 attribute"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: Fix buffer overflow in parse_vpd_pg80()
Martin Wilck [Mon, 24 Jun 2019 09:27:41 +0000 (11:27 +0200)]
libmultipath: Fix buffer overflow in parse_vpd_pg80()

We set out[len] = '\0' later, thus we should set len to no more then
out_len - 1.

Fixes: 756ef73b7197 "Separate out vpd parsing functions"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix parsing of VPD 83 type 1 (T10 vendor ID)
Martin Wilck [Mon, 24 Jun 2019 09:27:40 +0000 (11:27 +0200)]
libmultipath: fix parsing of VPD 83 type 1 (T10 vendor ID)

In the buffer overflow case, the code would set p_len = out_len - len - 2,
then len = len + plen = out_len - 2, and check if len >= out_len - 1,
which is never the case. Rather, set p_len = out_len - len -1, and
check the length again before appending the underscore.

Fixes: 18176202e75c "Read wwid from sysfs vpg_pg83 attribute"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools tests: add test for VPD parsing
Martin Wilck [Mon, 24 Jun 2019 09:27:39 +0000 (11:27 +0200)]
multipath-tools tests: add test for VPD parsing

Add a test for parsing the WWID from VPDs, with focus on WWID
buffer overflow detection and handling.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools tests: add strlcpy() tests
Martin Wilck [Mon, 24 Jun 2019 09:27:38 +0000 (11:27 +0200)]
multipath-tools tests: add strlcpy() tests

As we're using strlcpy quite a bit, make sure it works as designed.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agotests/hwtable: decrease log verbosity
Martin Wilck [Mon, 24 Jun 2019 09:27:37 +0000 (11:27 +0200)]
tests/hwtable: decrease log verbosity

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools tests: omit timestamp in log messages
Martin Wilck [Mon, 24 Jun 2019 09:27:36 +0000 (11:27 +0200)]
multipath-tools tests: omit timestamp in log messages

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: add size argument to dm_get_uuid()
Martin Wilck [Mon, 24 Jun 2019 09:27:35 +0000 (11:27 +0200)]
libmultipath: add size argument to dm_get_uuid()

The length of the uuid field in libdm is DM_UUID_LEN, which happens
to be one byte more than our WWID_SIZE. Handle this cleanly.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: inline set_default()
Martin Wilck [Mon, 24 Jun 2019 09:27:34 +0000 (11:27 +0200)]
libmultipath: inline set_default()

This is nothing but a reimplementation of strdup(), and it causes gcc 9
warnings. Remove it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmpathcmd: use target length for unix socket sun_path
Martin Wilck [Mon, 24 Jun 2019 09:27:32 +0000 (11:27 +0200)]
libmpathcmd: use target length for unix socket sun_path

Note that sun_path doesn't necessarily need to be 0-terminated for an abstract
socket name for ux_socket_listen(), this means we need to use memcpy to avoid
a spurious warning.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools: Fix more strncpy(X, Y, size - 1) calls
Martin Wilck [Mon, 24 Jun 2019 09:27:31 +0000 (11:27 +0200)]
multipath-tools: Fix more strncpy(X, Y, size - 1) calls

The compiler emitted no warnings for these, but for consistency
it makes sense to fix them, too.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools: fix more gcc 9 -Wstringop-truncation warnings
Martin Wilck [Mon, 24 Jun 2019 09:27:30 +0000 (11:27 +0200)]
multipath-tools: fix more gcc 9 -Wstringop-truncation warnings

More often than not, this means replacing strncpy() by strlcpy().

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix -Wstringop-overflow warning in merge_words()
Martin Wilck [Mon, 24 Jun 2019 09:27:29 +0000 (11:27 +0200)]
libmultipath: fix -Wstringop-overflow warning in merge_words()

Fixes the following warning from gcc 9:

In file included from /usr/include/string.h:494,
                 from dmparser.c:8:
In function ‘strncpy’,
    inlined from ‘merge_words’ at dmparser.c:41:2:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’
                 specified bound depends on the length of the source argument
                 [-Wstringop-overflow=]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dmparser.c: In function ‘merge_words’:
dmparser.c:41:19: note: length computed here
   41 |  strncpy(p, word, strlen(word) + 1);
      |                   ^~~~~~~~~~~~

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: remove 'space' argument to merge_words()
Martin Wilck [Mon, 24 Jun 2019 09:27:28 +0000 (11:27 +0200)]
libmultipath: remove 'space' argument to merge_words()

merge_words() is always called with space = 1. Remove the argument.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmultipath: fix gcc -Wstringop-truncation warning in set_value()
Martin Wilck [Mon, 24 Jun 2019 09:27:27 +0000 (11:27 +0200)]
libmultipath: fix gcc -Wstringop-truncation warning in set_value()

Fixes the following warning:

In function ‘strncat’,
    inlined from ‘set_value’ at parser.c:382:3:
/usr/include/bits/string_fortified.h:136:10: warning: ‘__builtin_strncat’
    output truncated before terminating nul copying as many bytes from a
    string as its length [-Wstringop-truncation]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parser.c: In function ‘set_value’:
parser.c:382:3: note: length computed here
  382 |   strncat(alloc, str, strlen(str));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc's stringop checker expects that the size argument of strncat() is derived
from the destination, not source, side.
See https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/

Fix typo in error message along the way.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agokpartx: dasd: fix -Waddress-of-packed-member warning from gcc9
Martin Wilck [Mon, 24 Jun 2019 09:27:26 +0000 (11:27 +0200)]
kpartx: dasd: fix -Waddress-of-packed-member warning from gcc9

Fixes the following warning:

dasd.c: In function ‘read_dasd_pt’:
dasd.c:206:3: warning: converting a packed ‘volume_label_t’ {aka ‘struct
volume_label’} pointer (alignment 1) to a ‘label_ints_t’ {aka ‘unsigned int’}
pointer (alignment 4) may result in an unaligned pointer value
[-Waddress-of-packed-member]
  206 |   label_ints_t *label = (label_ints_t *) &vlabel;
      |   ^~~~~~~~~~~~

As volume_label_t is only used in read_dasd_pt(), and filled with memcpy(),
increasing its alignment should be safe.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath: call store_pathinfo with DI_BLACKLIST
Benjamin Marzinski [Mon, 3 Jun 2019 19:29:16 +0000 (14:29 -0500)]
multipath: call store_pathinfo with DI_BLACKLIST

Commit ca19f865f moved adding DI_BLACKLIST to the pathinfo flags out of
store_pathinfo(), but it didn't add it to all of the necessary callers.
Without this, store_pathinfo() callers can do unnecessary extra work,
including running the path checker on blacklisted devices. Also, running

multipathd add path <blacklisted_path_device>

will add a blacklisted path.

Fixes: ca19f865f "libmultipath: add 'cmd' as argument for get_refwwid()"
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agompathpersist.8: add documentation for --batch-file (-f)
Martin Wilck [Mon, 27 May 2019 12:59:42 +0000 (14:59 +0200)]
mpathpersist.8: add documentation for --batch-file (-f)

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agompathpersist.8: fix examples in man page
Martin Wilck [Mon, 27 May 2019 12:59:41 +0000 (14:59 +0200)]
mpathpersist.8: fix examples in man page

--prout-type is ignored in the REGISTER service action. The RESERVE service
action takes a Reservation Key, not a Service action Reservation Key, as
argument. The text mentions "Service Action Reservation Key" in several places
where it means the Reservation Key. Add examples for unregistering the current
key, and the CLEAR service action. Fix formatting with longer text in the
description lines (the .TP formatting would produce bad results if the
first line needs to be broken).

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmpathpersist: don't bother with priorities
Martin Wilck [Mon, 27 May 2019 12:59:40 +0000 (14:59 +0200)]
libmpathpersist: don't bother with priorities

We send our PR commands to every active path, regardless of priority.
Thus we can save the effort to obtain priorities.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agompathpersist: initialize data structures only once
Martin Wilck [Mon, 27 May 2019 12:59:39 +0000 (14:59 +0200)]
mpathpersist: initialize data structures only once

We now have the possibility to run several PR commands in a single
mpathpersist invocation. Run initialization / discovery and teardown
only once at program invocation / exit.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmpathpersist: factor out initialization and teardown
Martin Wilck [Mon, 27 May 2019 12:59:38 +0000 (14:59 +0200)]
libmpathpersist: factor out initialization and teardown

mpath_presistent_reserve_{in,out} share a lot of common code
for initial data structure initialization (discovery) and teardown.
Factor this code out into mpath_persistent_reserve_init_vecs()
(global data structure initialization),
mpath_persistent_reserve_free_vecs (global teardown) and mpath_get_map()
(struct multipath setup for given map device).

Provide __mpath_presistent_reserve_{in,out}, which are the same
as their counterparts without leading underscores, but do not
call the global setup and teardown routines. This allows running
several PR commands in a row without having to re-initialize in
between. Because libmpathpersist is a public API, the previously
known functions don't change behavior.

Don't call path_discovery() any more during global initialization.
We rather do this lazily in the get_mpvec() call chain. dm_get_maps(),
OTOH, is part of the global initialization procedure. In get_mpvec(),
we don't delete non-matching maps any more, because we way want to
act on them later on.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmpathpersist: updatepaths: deal with missing pp->udev
Martin Wilck [Mon, 27 May 2019 12:59:37 +0000 (14:59 +0200)]
libmpathpersist: updatepaths: deal with missing pp->udev

We will change the data structure initialization to a lazy
approach, where pp->udev isn't necessarily initialized
when get_mpvec() is called. Deal with it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agompathpersist: no need to treat error close() as fatal
Martin Wilck [Mon, 27 May 2019 12:59:36 +0000 (14:59 +0200)]
mpathpersist: no need to treat error close() as fatal

Simplify code a bit.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agompathpersist: add option --batch-file (-f)
Martin Wilck [Mon, 27 May 2019 12:59:35 +0000 (14:59 +0200)]
mpathpersist: add option --batch-file (-f)

Add the option --batch-file (-f) to mpathpersist. The option argument
is a text file that is parsed line-by-line. Every line of the file is
interpreted as an additional input line for mpathpersist. The initial
"mpathpersist" on each line is optional. The '#' character denotes
a comment. '#' is only recognized after whitespace. Empty lines,
or comment lines, are allowed.

If -f is given, other command line options are parsed as usual and
commands (if any) are run before running the batch file. Inside the
batch file, the option -f is forbidden, and -v is ignored. If a command
fails, the batch processing is not aborted. The return status of
mpathpersist is 0 if all commands succeeded, and the status of the
first failed command otherwise.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agompathpersist: call usage() just once on return
Martin Wilck [Mon, 27 May 2019 12:59:34 +0000 (14:59 +0200)]
mpathpersist: call usage() just once on return

This simplifies further changes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipathd: handle NULL return from genhelp_handler
Benjamin Marzinski [Fri, 17 May 2019 16:14:10 +0000 (11:14 -0500)]
multipathd: handle NULL return from genhelp_handler

parse_cmd() wasn't checking if genhelp_handler() returned NULL. It was simply
assuming that it got a string. On NULL, it now returns an error. Found by
Coverity.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agomultipathd: fix REALLOC_REPLY with max length reply
Benjamin Marzinski [Fri, 17 May 2019 16:14:09 +0000 (11:14 -0500)]
multipathd: fix REALLOC_REPLY with max length reply

Commit cd5a9797e added code to REALLOC_REPLY() that intended to stop
growing the reply buffer after it reached a maximum size. However this
code didn't stop the realloc() from happening. Worse, if the realloc()
failed, multipathd would double free the reply buffer. Found by
Coverity.

Fixes: cd5a9797e "libmpathcmd(coverity): limit reply length"
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agokpartx: fail if dup() of dasd file descriptor fails
Benjamin Marzinski [Fri, 17 May 2019 16:14:08 +0000 (11:14 -0500)]
kpartx: fail if dup() of dasd file descriptor fails

If kpartx fails to create a copy of the dasd file descriptor, it should
fail, instead of treating the error value as a valid fd. Found by
coverity.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 months agolibmultipath: get_prio(): really don't reset prio for inaccessible paths
Martin Wilck [Thu, 16 May 2019 07:10:24 +0000 (09:10 +0200)]
libmultipath: get_prio(): really don't reset prio for inaccessible paths

As pointed out by Ben Marzinski, my previous patch ebbb56f2 doesn't do what
it pretends to do.

Fixes: ebbb56f2 "libmultipath: get_prio(): don't reset prio for inaccessible
paths"

3 months agomultipath-tools: format correctly maintainer info in hwtable
Xose Vazquez Perez [Tue, 7 May 2019 18:53:09 +0000 (20:53 +0200)]
multipath-tools: format correctly maintainer info in hwtable

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: document missing mpathpersist flags in help output
Xose Vazquez Perez [Thu, 2 May 2019 21:49:01 +0000 (23:49 +0200)]
multipath-tools: document missing mpathpersist flags in help output

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: document missing multipathd option at man page
Xose Vazquez Perez [Thu, 2 May 2019 19:26:19 +0000 (21:26 +0200)]
multipath-tools: document missing multipathd option at man page

 -w was added in 2858c60a34527401381ea6b13cf316c3e5064383

Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath-tools: document missing multipath flags in help output
Xose Vazquez Perez [Thu, 2 May 2019 19:24:08 +0000 (21:24 +0200)]
multipath-tools: document missing multipath flags in help output

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipathd: fix client response for socket activation
Martin Wilck [Tue, 30 Apr 2019 22:41:38 +0000 (00:41 +0200)]
multipathd: fix client response for socket activation

When a client wakes up multipathd through the socket, it is likely that the
ux listener responds to client requests before multipathd startup has
completed. This means that client commands such as "show paths" or "show
topology" return success with an empty result, which is quite confusing.

Therefore, in the ux listener, don't start answering client requests while
the daemon is configuring. Rather, wait for some other daemon state. We
can't wait hard, because the ux listener must also handle signals. So just
wait for some short time, and poll again.

This has the side effect that command responses for commands that don't
require full initialization, such as "show wildcards", "show config" or
"shutdown", are also delayed until the configuration stage has completed.
But that seems to be a relatively cheap price to pay for getting the
expected response for other commands. To avoid this side effect, the client
handling would need to be rewritten such that the uxlsnr thread would have
a means to "know" which commands require the configuration stage to
complete and which do not.

v2: Removed an unrelated, unnecessary hunk in child().

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools: document missing kpartx options in man and output
Xose Vazquez Perez [Sat, 27 Apr 2019 01:30:45 +0000 (03:30 +0200)]
multipath-tools: document missing kpartx options in man and output

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
3 months agomultipath -u: test socket connection in non-blocking mode
Martin Wilck [Wed, 24 Apr 2019 09:07:59 +0000 (11:07 +0200)]
multipath -u: test socket connection in non-blocking mode

Since commit d7188fcd "multipathd: start daemon after udev trigger",
multipathd startup is delayed during boot until after "udev settle"
terminates. But "multipath -u" is run by udev workers for storage devices,
and attempts to connect to the multipathd socket. This causes a start job
for multipathd to be scheduled by systemd, but that job won't be started
until "udev settle" finishes. This is not a problem on systems with 129 or
less storage units, because the connect() call of "multipath -u" will
succeed anyway. But on larger systems, the listen backlog of the systemd
socket can be exceeded, which causes connect() calls for the socket to
block until multipathd starts up and begins calling accept(). This creates
a deadlock situation, because "multipath -u" (called by udev workers)
blocks, and thus "udev settle" doesn't finish, delaying multipathd
startup. This situation then persists until either the workers or "udev
settle" time out. In the former case, path devices might be misclassified
as non-multipath devices by "multipath -u".

Fix this by using a non-blocking socket fd for connect() and interpret the
errno appropriately.

This patch reverts most of the changes from commit 8cdf6661 "multipath:
check on multipathd without starting it". Instead, "multipath -u" does
access the socket and start multipath again (which is what we want IMO),
but it is now able to detect and handle the "full backlog" situation.

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

Use same error reporting convention in __mpath_connect() as in
mpath_connect() (Hannes Reinecke). We can't easily change the latter,
because it's part of the "public" libmpathcmd API.

6 months agolibmultipath: get_prio(): don't reset prio for inaccessible paths
Martin Wilck [Thu, 11 Apr 2019 10:49:23 +0000 (12:49 +0200)]
libmultipath: get_prio(): don't reset prio for inaccessible paths

pathinfo() doesn't call get_prio() if a path is down, now keeping the old
priority value. But if a path becomes inaccessible between the state check
and the get_prio() call, retrieving the priority will likely fail, and the
path priority will be reset to PRIO_UNDEF. This makes it timing-dependent
how the priority of a failed path is treated. Fix that by checking the path
state in get_prio() if an error occurs, and not touching pp->priority if
the path is in inaccessible state. A checker_check() call would be too
much here, but a quick path_offline() check seems appropriate.

Keep the previous behavior for the case where getting the priority fails
although the path is apparently healthy. This is presumably a very rare
condition, in which it seems actually wrong to preserve the old prio value.

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: ana prioritizer: decrease log level
Martin Wilck [Thu, 11 Apr 2019 10:49:22 +0000 (12:49 +0200)]
libmultipath: ana prioritizer: decrease log level

The "ana state = ..." printed in the get_prio() call path
is irritating, because by it's similarity to the checker
messages it suggests to the reader that an "ana checker",
which doesn't exist, was in place. Moreover, the "ana prio ="
message is also only printed at level 4.

Decrease the verbosity of this message.

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agoRevert "Set priority to '0' for PATH_BLOCKED or PATH_DOWN"
Martin Wilck [Thu, 11 Apr 2019 10:49:21 +0000 (12:49 +0200)]
Revert "Set priority to '0' for PATH_BLOCKED or PATH_DOWN"

This reverts commit ce8d707c4235860373238dea6491a77a931d4c9f.

In check_path(), we don't touch path priority if a path is down.
But when pathinfo(DI_CHECKER) is called in down state, we reset
the priority to 0. This is inconsistent.

Commit ce8d707 was about maps being rejected during multipath startup
because of undefined priorities. Since commit 94036e3 "libmultipath:
don't reject maps with undefined prio", such maps aren't rejected
any more, thus we can skip resetting the priority to 0.

Note that when we calculate path group priorities, the prio of
paths which are not UP or GHOST are ignored anyway, so this
change will not cause changes wrt PG priorities or PG ordering.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Cc: Hannes Reinecke <hare@suse.de>
6 months agolibmultipath: group_by_prio: fix signedness bug
Martin Wilck [Thu, 11 Apr 2019 10:49:20 +0000 (12:49 +0200)]
libmultipath: group_by_prio: fix signedness bug

pp->priority can be negative, so we we shouldn't compare
it with an unsigned int.

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agomultipath: check on multipathd without starting it
Benjamin Marzinski [Thu, 18 Apr 2019 17:49:46 +0000 (12:49 -0500)]
multipath: check on multipathd without starting it

When "multipath -u" is run, it checks if multipathd is running.
Currently it does this by trying to connect to the mutipathd socket.
This can cause problems during boot.  The multipathd.socket systemd unit
file will cause "multipath -u" to wait until multipathd has been started
before continuing.  If there is a lot of activity on the system,
multipathd may not start up immediately, causing block device
initialization to be delayed, potentially until after systemd times
waiting for the device.  To avoid this, multipath now checks if
multipathd is running by reading /run/multipathd.pid and checking the
/proc/<pid>/comm to verify that multipathd is really running with this
pid. This avoids forcing "multipath -u" to wait on multipathd starting
up.

As an alternative to this patch, multipath could simply switch the order
of the calls to systemd_service_enabled() and mpath_connect(). This would
make multipath only try to connect with multipathd if it wasn't enabled in
systemd, so that it wouldn't autostart.

Another alternative is to do away with multipathd.socket. Since multipathd
needs to always be running in order to get uevents, there isn't much value
in having it autoactivate when it gets an interactive command.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
6 months agoBump version to 0.8.1 0.8.1
Christophe Varoqui [Thu, 18 Apr 2019 11:13:10 +0000 (13:13 +0200)]
Bump version to 0.8.1

6 months agomultipath-tools: reorder vendors in hwtable
Xose Vazquez Perez [Sat, 16 Mar 2019 23:05:06 +0000 (00:05 +0100)]
multipath-tools: reorder vendors in hwtable

Xio was acquired by Violin, and add FlashSystem 9100 to Storwize in comments.

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
6 months agomultipath-tools: maintain the uniformity in the multipath.conf.5 page
Xose Vazquez Perez [Sat, 16 Mar 2019 22:25:56 +0000 (23:25 +0100)]
multipath-tools: maintain the uniformity in the multipath.conf.5 page

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
6 months agolibmultipath: hwtable: add Lenovo DE series
Martin Wilck [Mon, 18 Mar 2019 11:24:45 +0000 (12:24 +0100)]
libmultipath: hwtable: add Lenovo DE series

I got this from Steven.

Cc: Steve.Schremmer@netapp.com
Cc: NetApp RDAC team <ng-eseries-upstream-maintainers@netapp.com>
Cc: xose.vazquez@gmail.com
Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: check_rdac(): pre-check in hwtable
Martin Wilck [Mon, 18 Mar 2019 11:24:44 +0000 (12:24 +0100)]
libmultipath: check_rdac(): pre-check in hwtable

Currently check_rdac() always runs an SG_IO for VPD 0xc9 to check
if the storage supports RDAC. This is an extra IO, and may cause
annoying error messages on the storage side for non-RDAC arrays.
Do not use the RDAC override for arrays that have legacy configuration
to use a checker other than "rdac". For "unkown" devices with no checker
configured in either the hwtable or multipath.conf, the VPD call will
be tried.

Cc: Steve.Schremmer@netapp.com
Cc: NetApp RDAC team <ng-eseries-upstream-maintainers@netapp.com>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: tidy up do_set_from_hwe() with statement expression
Martin Wilck [Mon, 18 Mar 2019 11:24:43 +0000 (12:24 +0100)]
libmultipath: tidy up do_set_from_hwe() with statement expression

propsel.c has a lot of "funky" macros making assumptions about
variable and label names in callers. This one is particularly
ugly. As a first tidy-up step, split out a statement expression
which can be called cleanly from code that doesn't have said
variables and labels.

Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: don't link alua_rtpg.o twice
Martin Wilck [Mon, 18 Mar 2019 11:24:42 +0000 (12:24 +0100)]
libmultipath: don't link alua_rtpg.o twice

We link this already to libmultipath.so. Therefore, no need
to link ti to libprioalua.so, too.

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: lazy tpgs probing
Martin Wilck [Mon, 18 Mar 2019 11:24:41 +0000 (12:24 +0100)]
libmultipath: lazy tpgs probing

Provide a "getter" function that can be used to probe tpgs lazily.
This way we don't need to send an RTPG in the pathinfo() call
chain (e.g. in "multipath -u"). With this in place, no "user"
code should access pp->tpgs directly any more.

Moreover, in select_prio(), in the case where the alua checker
was statically configured, rather then calling into the alua
code directly, use get_tpgs(), which does all the proper error
checking, and fall back to const prio if it fails.

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: detect_alua(): use system timeout
Martin Wilck [Mon, 18 Mar 2019 11:24:40 +0000 (12:24 +0100)]
libmultipath: detect_alua(): use system timeout

This is not the path checker - we don't need to use the
configured checker timeout here. This makes it possible to
call this function without a current (struct config *).

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: constify sysfs_get_timeout()
Martin Wilck [Mon, 18 Mar 2019 11:24:39 +0000 (12:24 +0100)]
libmultipath: constify sysfs_get_timeout()

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: alua: try to retrieve inquiry data from sysfs
Martin Wilck [Mon, 18 Mar 2019 11:24:38 +0000 (12:24 +0100)]
libmultipath: alua: try to retrieve inquiry data from sysfs

This can avoid IO while configuring the path prioritizer.
The alua prioritizer avoids reading from sysfs for a reason
(see commit 7e2f46d3), but this applies only to RTPG / STPG,
not to INQUIRY calls.

Cc: Steve.Schremmer@netapp.com
Cc: NetApp RDAC team <ng-eseries-upstream-maintainers@netapp.com>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: alua: make API more consistent
Martin Wilck [Mon, 18 Mar 2019 11:24:37 +0000 (12:24 +0100)]
libmultipath: alua: make API more consistent

Let all alua functions take "const struct path *" as first
argument.

Signed-off-by: Martin Wilck <mwilck@suse.com>
6 months agolibmultipath: add sysfs_get_inquiry()
Martin Wilck [Mon, 18 Mar 2019 11:24:36 +0000 (12:24 +0100)]
libmultipath: add sysfs_get_inquiry()

Provide a utility function to retrieve inquiry data from
sysfs, like we do for VPDs.

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