multipath-tools/.git
2 weeks agolibmultipath: allow distributions to change partition_delim default master
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 weeks 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>
2 weeks agomultipathd: fix buffer size in cli_getprkey()
Martin Wilck [Sun, 24 Jun 2018 19:09:43 +0000 (21:09 +0200)]
multipathd: fix buffer size in cli_getprkey()

gcc 8.1 warned about this.

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

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

tur(default) is only for SCSI devices.

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

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

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

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

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

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

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

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

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

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

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

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

It was replaced in 00ee0bda40f8b6ac060211c36a419c699af7f778

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

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

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

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

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

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

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

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

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

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

Implement removal of invalid and duplicate entries in blacklists.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: allow printing local maps in snprint_config
Martin Wilck [Fri, 8 Jun 2018 10:20:35 +0000 (12:20 +0200)]
libmultipath: allow printing local maps in snprint_config

"mulitpatd show config" only dumps multipath sections for maps which are
present in local configuration files. This patch adds the ability to dump
"multipath" subsections for every locally detected map, even for those
that have no local configuration, and at the same time, skip dumping
multipath configurations for maps that aree not present locally.

This makes it possible for users to generate a multipath.conf template
matching local devices, and e.g. add explicit alias entries for existing
maps. If user_friendly_names is in use, a commented-out config line is added
to the dump output showing the implicitly configured alias, simplifying
identification of the devices.

This facility is optional and will only be used in new commands added
in follow-up patches.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agotests/hwtable: add test for local configuration dump
Martin Wilck [Fri, 8 Jun 2018 10:20:34 +0000 (12:20 +0200)]
tests/hwtable: add test for local configuration dump

This adds another test iteration in test_driver(): It now tests:

 1) with "user-supplied" configuration,
 2) using the full config dump (equivalent with "multipath -t" output),
 3) using the local config dump as implemented in the previous patch.

Again, the properties of paths and maps should be the same for all 3
scenarios. For 3), the "multipath -t" output can't be expected to be
exactly equal to the output in 1), because merging of hwentries may move the
position of a hwentry down in the hwentry list, and empty "multipath"
sections are being added.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: allow dumping only "local" hwtable in snprint_config
Martin Wilck [Fri, 8 Jun 2018 10:20:33 +0000 (12:20 +0200)]
libmultipath: allow dumping only "local" hwtable in snprint_config

This change is key for allowing to dump the "local" multipath configuration
only, i.e. those entries of the hardware table that match existing devices
in the system. By passing the output of the new helper function
get_used_hwes() as the last argument for snprint_config(), only the local
entries will be dumped.

The rationale is that "multipath -t" output is overwhelmingly long for most
use cases; in particular it's not useful as a template for creating a local
configuration.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agotests/hwtable: implement configuration dump + reload test
Martin Wilck [Fri, 8 Jun 2018 10:20:32 +0000 (12:20 +0200)]
tests/hwtable: implement configuration dump + reload test

In order to test dumping and re-reading the configuration, we modify the
test_driver() function so that runs the same test three twice:

 1) with "user-supplied" configuration,
 2) using the config dump from 1) (equivalent with "multipath -t" output) as input
 configuration.

The expectation is that actual paths and maps have same options applied.
Furthermore, the "multipath -T" output from 2) should be the same as from 1),
IOW, "multipath -T" in 2) reproduces its input config file exactly.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agomultipath, multipathd: consolidate config dumping
Martin Wilck [Fri, 8 Jun 2018 10:20:31 +0000 (12:20 +0200)]
multipath, multipathd: consolidate config dumping

"multipath -t" and "multipathd show config" use very similar code.
Consolidate it into a libmultipath function. Simplify it a bit in
the process, and do some "const" and "static" cleanup.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: don't merge by regex in setup_default_blist()
Martin Wilck [Fri, 8 Jun 2018 10:20:30 +0000 (12:20 +0200)]
libmultipath: don't merge by regex in setup_default_blist()

The merging of blacklist entries by regular expression leads
to similar problems as the merging of hwentries. Only merge
blacklist entries if they're exactly equal.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath/hwtable: remove inherited props from ONTAP NVMe
Martin Wilck [Fri, 8 Jun 2018 10:20:29 +0000 (12:20 +0200)]
libmultipath/hwtable: remove inherited props from ONTAP NVMe

With the new hwtable code, properties inherited from generic NVMe
don't need to be duplicated.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: merge hwentries inside a conf file
Martin Wilck [Fri, 8 Jun 2018 10:20:28 +0000 (12:20 +0200)]
libmultipath: merge hwentries inside a conf file

Merging hwentries with identical vendor/product/revision is still useful,
although it's not strictly necessary any more. But such identical entries
should always be merged, not only if they appear in different configuration
files. This requires changing the logic of factorize_hwtable.

By setting -DCHECK_BUILTIN_HWTABLE at compile time, the built-in hwtable
can be checked against duplicates as well.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: don't merge hwentries by regex
Martin Wilck [Fri, 8 Jun 2018 10:20:27 +0000 (12:20 +0200)]
libmultipath: don't merge hwentries by regex

Merging by regular expression is wrong, because regular expressions can't be
matched against each other. Unexpected results for hardware properties may
result. Don't do it any more.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: allow more than one hwentry
Martin Wilck [Fri, 8 Jun 2018 10:20:26 +0000 (12:20 +0200)]
libmultipath: allow more than one hwentry

The previous patch "use vector for for pp->hwe and mp->hwe" changed the
data structure for hwentries. This patch changes actual behavior by
allowing more than one hwentry to match a given path (or multipath).

This fixes several currently broken test cases. The test code is adapted
accordingly.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: use vector for for pp->hwe and mp->hwe
Martin Wilck [Fri, 8 Jun 2018 10:20:25 +0000 (12:20 +0200)]
libmultipath: use vector for for pp->hwe and mp->hwe

Change the data structure of "struct path" and "struct multipath"
such that the "hwe" entry is a vector of hwentry structures rather
than a single hwentry structure. Add respective code to the
constructors and destructors (note that mp->hwe is never allocated,
it's always a pointer to a path hwe).

Change find_hwe() to fill in the passed vector rather than returning
a hwentry pointer. Change the propsel code to look through vectors
of hwentries to determine a given property.

This patch just creates the new data structure and the functions to
deal with them, it doesn't introduce semantic changes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: add debug messages to hwentry lookup/merging code
Martin Wilck [Fri, 8 Jun 2018 10:20:24 +0000 (12:20 +0200)]
libmultipath: add debug messages to hwentry lookup/merging code

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agotests/hwtable: tests for config file handling and hwentry merging
Martin Wilck [Fri, 8 Jun 2018 10:20:23 +0000 (12:20 +0200)]
tests/hwtable: tests for config file handling and hwentry merging

Add unit tests for parsing "device" and "blacklist" configuration entries and
hwtable entry merging. The tests work by creating a multipath.conf file and one
or more config_dir/*.conf files, reading device entries from both, simulating
discovery of fake paths and multipaths, and verifying these are configured as
expected. The focus is on the behavior if several hwtable or blacklist entries
match a single device.

Most of these tests in this file serve as regression test for follow-up changes.
But Some of the tests are meant to illustrate problems problems with
the current code, which behaves inconsistently in certain cases. By
changing the BROKEN macro at the top of the file, the user can control if broken
behavior causes test failure, or succeeds with a warning. Subsequent patches
will remove the BROKEN tests. Reviewers are encouraged to focus on the BROKEN
tests, which annotate current behavior that follow-up patches are going to change.

Problems with the current code are mainly found in two areas:

 1. It currently makes a difference whether several entries matching the same
 device are in in the same configuration file (default "multipath.conf") or
 distributed over "multipath.conf" and other files under config_dir. This is
 highly unexpected behavior.
 Moreover, in this context, the built-in hwtable can be viewed as yet another
 "configuration file" which is parsed before "multipath.conf". The same problem
 arises: adding a hwentry to "multipath.conf" doesn't necessarily have the same
 effect as adding the same entry to the built-in hwtable and recompiling,
 because different merging logic applies (in short: entries from different
 "configuration files" are merged, but entries from the same "file" aren't).

 This is a major blocker for using the configuration dumped with
 "multipath -t" as input for multipath-tools, because a built-in entry which
 is dumped ends up in "multipath.conf" or a config_dir file, which may change
 the way it's merged with other entries.

  2. The vendor/product/rev IDs are regular expressions, and merging of entries
  by regular expressions simply doesn't work. Entries are merged if a later
  regex, interpreted as a string, matches an earlier added regex. But that's
  incorrect. Except in trivial cases, matching of a regex r2 by another regex
  r1 doesn't say anything about whether strings matched by r2 will be matched
  by r1 as well.

Another, minor issue is the treatment of double quotes.

The way these tests are implemented using the test_driver() function may seem
weird in the first place. The reason is that in a later patch, when we have
configuration-dumping-and-reloading basically working, test_driver() will be
extended to run the same test both with the initial and dumped configuration
and ensure that there are no differences. If I didn't introduce test_driver()
right away, I'd have major, confusing changes in the test code when this
functionality is added.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agotests/test-lib: cmocka helpers to simulate path and map discovery
Martin Wilck [Fri, 8 Jun 2018 10:20:22 +0000 (12:20 +0200)]
tests/test-lib: cmocka helpers to simulate path and map discovery

These functions simulate path discovery and multipath setup with cmocka. They will be
used in the hwtable test case, but may be useful for other future test cases,
too.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agotests/Makefile: autogenerate list of symbols to be wrapped
Martin Wilck [Fri, 8 Jun 2018 10:20:21 +0000 (12:20 +0200)]
tests/Makefile: autogenerate list of symbols to be wrapped

Rather than manually listing all the -Wl,--wrap=... options, autogenerate
a list of functions to be wrapped in a cmocka test. Allowing this not only
for the test file itself but also for additional "test library" source files
requires some Makefile incantations.

Moreover, no need to list globals.c in dependencies, automatic dependency
tracking takes care for this (and avoids recompilation of tests that don't
pull in global.c).

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath/prio: constify simple getters
Martin Wilck [Fri, 8 Jun 2018 10:20:20 +0000 (12:20 +0200)]
libmultipath/prio: constify simple getters

One day we should also constify getprio(), but that requires
touching all prioritizers.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: change prototypes of hwe_regmatch() and find_hwe()
Martin Wilck [Fri, 8 Jun 2018 10:20:19 +0000 (12:20 +0200)]
libmultipath: change prototypes of hwe_regmatch() and find_hwe()

hwentry structures are supposed to be initialized and destroyed
with alloc_hwe() and free_hwe(), respectively. The second
argument is of hwe_regmatch() isn't a real hwentry, just a
vendor/product/revision tuple. Clarify that by adapting the
prototype. This allows to use const arguments in find_hwe(), too.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: some const usage in hwentry handling
Martin Wilck [Fri, 8 Jun 2018 10:20:18 +0000 (12:20 +0200)]
libmultipath: some const usage in hwentry handling

Add some const qualifiers in in the code dealing with hwentries.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath/structs.c: constify some functions
Martin Wilck [Fri, 8 Jun 2018 10:20:17 +0000 (12:20 +0200)]
libmultipath/structs.c: constify some functions

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: remove superfluous conditionals in load_config()
Martin Wilck [Fri, 8 Jun 2018 10:20:16 +0000 (12:20 +0200)]
libmultipath: remove superfluous conditionals in load_config()

In load_config(), conf is freshly allocated, there's no point in checking
previously set values.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agolibmultipath: fix memory leak in process_config_dir()
Martin Wilck [Fri, 8 Jun 2018 10:20:15 +0000 (12:20 +0200)]
libmultipath: fix memory leak in process_config_dir()

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agokpartx: no need to use FREE_CONST
Martin Wilck [Fri, 8 Jun 2018 10:20:14 +0000 (12:20 +0200)]
kpartx: no need to use FREE_CONST

A function that returns a result of strdup() doesn't need to declare that
result as const char*.

Signed-off-by: Martin Wilck <mwilck@suse.com>
4 weeks agomultipath.conf.5: update the description of marginal_path_err_rate_threshold
Wang Ke [Fri, 8 Jun 2018 06:47:46 +0000 (14:47 +0800)]
multipath.conf.5: update the description of marginal_path_err_rate_threshold

    The path will not reinstate for \fImarginal_path_err_rate_threshold\fR
    seconds unless there is one active path, when it should be marginal_path_err_recheck_gap_time seconds
    instead of marginal_path_err_rate_threshold.

Signed-off-by: Ke Wang <wangke16@huawei.com>
4 weeks agomultipath: don't check timestamps without a path
Benjamin Marzinski [Tue, 5 Jun 2018 22:40:21 +0000 (17:40 -0500)]
multipath: don't check timestamps without a path

If a path was blacklisted, pathvec could exist but have no path in it.
print_cmd_valid wasn't checking this before calling
find_multipaths_check_timeout(). This was causing it to dereference a
NULL pointer in these cases.

Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
4 weeks agompathpersist: fix aptpl support
Benjamin Marzinski [Tue, 5 Jun 2018 22:40:20 +0000 (17:40 -0500)]
mpathpersist: fix aptpl support

The "Active Persist Through Power Loss" flag must be set whenever a key
is registered. However, there is no way for multipathd to know if this
was set by mpathpersist. The result is that if a path goes down and
comes back up (or if it wasn't up when mpathpersist was first run)
multipathd will clear the aptpl flag when it reregisters the key on it.

To fix this, multipath.conf now accepts an optional ":aptpl" appended
on the reservation_key value. If this is added to the reservation_key
multipathd will set the aptpl flag when it reregisters the key. If
reservation_key is set to "file", this will automatically be tracked
in the /etc/multipath/prkeys file.

To track this flag in the prkeys file, without changing the format
I've made "0x<key>" stand for non-aptpl keys, and "0X<key>" stand
for aptpl keys. Since previously, all keys used a lower-case x, this
will default to the current behavior for existing keys. Obviously, the
next time mpathpersist is run, this will be changed if --param-aptpl
is used.  Since there are no more flags that are in sg_persist that
multipathd needs to care about in mpathpersist, there shouldn't need
to be any more flags added to the prkeys file.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
4 weeks agompathpersist: add all_tg_pt option
Benjamin Marzinski [Fri, 1 Jun 2018 22:22:01 +0000 (17:22 -0500)]
mpathpersist: add all_tg_pt option

Some arrays, such as the EMC VNX, don't follow the scsi persistent
reservations spec in making key registrations per I_T NEXUS. Instead,
the registration is shared by all target ports connected to a given
host.  This causes mpathpersist to fail whenever it tries to register a
key, since it will receive a registration conflict on some of the paths.

To deal with this, mpathpersist needs to track the hosts that it has
done a registration on, and only register once per host. The new
"all_tg_pt" multipath.conf option is used to set which arrays need this
feature.  I currently don't know if all EMC VNX arrays handle persistent
reservations like this, or if it is configurable. A future patch will
update the VNX built-in config, if this is indeed their default (or
only) setting.

Multipathd doesn't need to worry about this. It is often the case that
when a path device comes back, it will still have the keys registered to
it. Because of this, multipathd uses register-and-ignore, which means
that it won't cause an error if the registration has already happened
down a different target port.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
4 weeks agolibmultipath: remove rbd code
Benjamin Marzinski [Fri, 1 Jun 2018 22:22:02 +0000 (17:22 -0500)]
libmultipath: remove rbd code

The Ceph tean has asked to drop support for multipathed rbd, since it
was running into data corruption issues. There was never an upstream
Ceph release based on it, and because of the corruption, there should be
no users of this code. This patch simply reverts all the rbd code from
multipath.

Cc: Michael Christie <mchristi@redhat.com>
Cc: Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: fix error parsing "find_multipaths strict"
Martin Wilck [Tue, 15 May 2018 12:32:44 +0000 (14:32 +0200)]
libmultipath: fix error parsing "find_multipaths strict"

If "find_multipaths strict" is set in multipath.conf, the error message
"illegal value for find_multipaths: strict" is printed. This causes no
functional problem, as "strict" happens to be the default, fallback
value. It should be fixed nonetheless. FIND_MULTIPATHS_STRICT, having
the highest numeric value, must be last in the enum.

Fixes: c36f2f42 "libmultipath: change find_multipaths option to multi-value"
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipathd: handle errors in uxlsnr as fatal
Martin Wilck [Wed, 21 Mar 2018 09:34:19 +0000 (10:34 +0100)]
multipathd: handle errors in uxlsnr as fatal

The ppoll() calls of the uxlsnr thread are vital for proper functioning of
multipathd. If the uxlsnr thread can't open the socket or fails to call ppoll()
for other reasons, quit the daemon. If we don't do that, multipathd may
hang in a state where it can't be terminated any more, because the uxlsnr
thread is responsible for handling all signals. This happens e.g. if
systemd's multipathd.socket is running in and multipathd is started from
outside systemd.

24f2844 "multipathd: fix signal blocking logic" has made this problem more
severe. Before that patch, the signals weren't actually blocked in any thread.
That's not to say 24f2844 was wrong. I still think it's correct, we just
need this one on top.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: don't reject maps with undefined prio
Martin Wilck [Wed, 21 Mar 2018 09:34:18 +0000 (10:34 +0100)]
libmultipath: don't reject maps with undefined prio

libmultipath's prio routines can deal with pp->priority == PRIO_UNDEF
just fine. PRIO_UNDEF is just a very low priority. So there's
no reason to reject setting up a multipath map because paths have
undefined priority.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: configure hitachi ams2000 and hus100 as full active arrays
Xose Vazquez Perez [Mon, 14 May 2018 15:30:17 +0000 (17:30 +0200)]
multipath-tools: configure hitachi ams2000 and hus100 as full active arrays

AMS2000 and HUS100 families are active/active arrays.

Based on https://support.hitachivantara.com/download/epcra/df818913.pdf
and internal hitachi docs.

Cc: Matthias Rudolph <Matthias.Rudolph@hitachivantara.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEV ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: refresh kernel-doc from kernel sources
Xose Vazquez Perez [Sat, 12 May 2018 22:39:42 +0000 (00:39 +0200)]
multipath-tools: refresh kernel-doc from kernel sources

Cc: Gris Ge <fge@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: add +x to doc-preclean.pl and split-man.pl
Xose Vazquez Perez [Sat, 12 May 2018 22:39:41 +0000 (00:39 +0200)]
multipath-tools: add +x to doc-preclean.pl and split-man.pl

It is not strictly necessary, but it helps identify bin files.

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: fix compilation with musl libc
Xose Vazquez Perez [Fri, 11 May 2018 16:39:44 +0000 (18:39 +0200)]
multipath-tools: fix compilation with musl libc

In file included from alias.c:15:
file.h:9:47: error: unknown type name ‘mode_t’; did you mean ‘time_t’?
 int ensure_directories_exist(const char *str, mode_t dir_mode);
                                               ^~~~~~
                                               time_t

sysfs.c: In function ‘sysfs_is_multipathed’:
sysfs.c:304:15: error: ‘PATH_MAX’ undeclared (first use in this function); did you mean ‘PATH_UP’?
  char pathbuf[PATH_MAX];
               ^~~~~~~~
               PATH_UP

Cc: Martin Wilck <mwilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: Remove trailing/leading whitespaces and reformat code
Xose Vazquez Perez [Fri, 11 May 2018 13:43:11 +0000 (15:43 +0200)]
multipath-tools: Remove trailing/leading whitespaces and reformat code

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: replace FSF address with a www pointer
Xose Vazquez Perez [Fri, 11 May 2018 13:42:43 +0000 (15:42 +0200)]
multipath-tools: replace FSF address with a www pointer

Less prone to future modifications, new FSF licences
point exactly to this url: <http://www.gnu.org/licenses/>.
And sending a smail to FSF is outdated.

First clean up was done in 5619a39c433ac3d10a88079593cec1aa6472cbeb

Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: remove emacs autoconfig of kpartx/gpt.h
Xose Vazquez Perez [Thu, 12 Apr 2018 16:17:13 +0000 (18:17 +0200)]
multipath-tools: remove emacs autoconfig of kpartx/gpt.h

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: remove "c" from __cpluscplus, misspelled
Xose Vazquez Perez [Tue, 24 Apr 2018 13:03:40 +0000 (15:03 +0200)]
multipath-tools: remove "c" from __cpluscplus, misspelled

found by cppcheck(http://cppcheck.sf.net/):
[libmpathcmd/mpath_cmd.h:24]: (error) Invalid number of character '{' when these macros are defined: '__cpluscplus'.

Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: add RDAC SUN/ArrayStorage to hwtable
Xose Vazquez Perez [Wed, 11 Apr 2018 13:14:13 +0000 (15:14 +0200)]
multipath-tools: add RDAC SUN/ArrayStorage to hwtable

Already in scsi_dh: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/scsi/scsi_dh.c#n70

Cc: NetApp RDAC team <ng-eseries-upstream-maintainers@netapp.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agoBump version to 0.7.7 0.7.7
Christophe Varoqui [Fri, 11 May 2018 08:52:41 +0000 (10:52 +0200)]
Bump version to 0.7.7

2 months agomultipathd: fix reservation_key check
Benjamin Marzinski [Tue, 24 Apr 2018 20:15:31 +0000 (15:15 -0500)]
multipathd: fix reservation_key check

mpath_pr_event_handle should exit if the reservation key is zero, not
non-zero.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipathd: add failures path format wildcard
Benjamin Marzinski [Tue, 24 Apr 2018 20:15:30 +0000 (15:15 -0500)]
multipathd: add failures path format wildcard

multipath already tracks this, so it should be able to print it out.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath.rules: find_multipaths "smart" logic
Martin Wilck [Fri, 13 Apr 2018 22:00:15 +0000 (00:00 +0200)]
multipath.rules: find_multipaths "smart" logic

When the first path to a device appears, we don't know if more paths are going
to follow. find_multipath "smart" logic attempts to solve this dilemma by
waiting for additional paths for a configurable time before giving up
and releasing single paths to upper layers.

These rules apply only if both find_multipaths is set to "smart" in
multipath.conf. In this mode, multipath -u sets DM_MULTIPATH_DEVICE_PATH=2 if
there's no clear evidence wheteher a given device should be a multipath member
(not blacklisted, not listed as "failed", not in WWIDs file, not member of an
existing map, only one path seen yet). In this case, "multipath -u" also sets the
variable FIND_MULTIPATHS_WAIT_UNIL to a relative time stamp (we need to use
relative "monotonic" time stamps because this may be triggered early during
boot, before system "calendar" time is correctly initialized).

In the DM_MULTIPATH_DEVICE_PATH=2 case, pretend that the path is multipath
member, disallow further processing by systemd (allowing multipathd some time
to grab the path), and set a systemd timer to check again after the given
timeout. If the path is still not multipathed by then, pass it on to systemd
for further processing.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: enable find_multipaths "smart"
Martin Wilck [Fri, 13 Apr 2018 22:00:14 +0000 (00:00 +0200)]
libmultipath: enable find_multipaths "smart"

This activates "smart" path detection. This is similar to
"find_multipaths yes", but doesn't generally ignore single paths
that are not listed in the WWIDs file. Rather, such paths are
temporarily treated like multipath members. If no additional paths
are detected after a certain time, the paths are re-added to the
system as non-multipath. This needs support by the udev rules, to
be added in a follow-up patch.

If a multipath map is successfully successfully created, and paths are
in waiting state, trigger path uevents to update their status.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath -u: test if path is busy
Martin Wilck [Fri, 13 Apr 2018 22:00:13 +0000 (00:00 +0200)]
multipath -u: test if path is busy

For "find_multipaths smart", check if a path is already in use
before setting DM_MULTIPATH_DEVICE_PATH to 1 or 2 (and thus,
SYSTEMD_READY=0). If we don't do this, a device which has already been
mounted (e.g. during initrd processing) may be unmounted by systemd, causing
havoc to the boot process.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath -u: don't grab devices already passed to system
Martin Wilck [Fri, 13 Apr 2018 22:00:12 +0000 (00:00 +0200)]
multipath -u: don't grab devices already passed to system

Setting SYSTEMD_READY=0 on a device that has previously been passed to
systemd is dangerous - already mounted file systems might be unmounted by
systemd.

Avoid that by checking for previously set DM_MULTIPATH_DEVICE_PATH
environment variable.

This requires to change the exit status of multipath -u - it needs to exit
with status 0 even if the path is not a multipath device path, otherwise
udev doesn't import the printed key-value pairs. We do this only for
"multipath -u"; legacy "multipath -c", which is more likely to be run in user
scripts, still exits with 1 for non-multipath devices.

The condition ENV{DM_MULTIPATH_DEVICE_PATH}!="1" before the "multipath -u"
statement in multipath.rules needs to be removed. This condition was
pointless anyway, because until this patch, DM_MULTIPATH_DEVICE_PATH hadn't
been imported from the db and thus was never set, and "multipath -u" was
always invoked. We want to keep this behavior.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath -u: quick check if path is multipathed
Martin Wilck [Fri, 13 Apr 2018 22:00:11 +0000 (00:00 +0200)]
multipath -u: quick check if path is multipathed

With "find_multipaths smart", we accept paths as valid if they are
already part of a multipath map. This patch avoids doing a full path
and device-mapper map scan for this case, speeding up "multipath -u"
considerably.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath -u: cleanup logic
Martin Wilck [Fri, 13 Apr 2018 22:00:10 +0000 (00:00 +0200)]
multipath -u: cleanup logic

The CMD_VALID_PATH logic is complex and hard to read and understand.
This patch cleans it up a bit (preparing for folluw-up patches).
It doesn't change any logic.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath -u : set FIND_MULTIPATHS_WAIT_UNTIL from /dev/shm
Martin Wilck [Fri, 13 Apr 2018 22:00:09 +0000 (00:00 +0200)]
multipath -u : set FIND_MULTIPATHS_WAIT_UNTIL from /dev/shm

In "find_multipaths smart" mode, use time stamps under
/dev/shm/multipath/find_multipaths to track waiting for multipath
siblings. When a path is first encountered and is "maybe" multipath, create
a file under /dev/shm, set its modification time to the expiry time of the
timer, and set the FIND_MULTIPATHS_WAIT_UNTIL variable. On later calls,
also set FIND_MULTIPATHS_WAIT_UNTIL to the expiry time (but don't change
the time stamp) if it's not expired yet, or 0 if it is expired. Set
FIND_MULTIPATHS_WAIT_UNTIL even if enough evidence becomes available to
decide if the path needs to be multipathed - this enables the udev rules to
detect that this is a device a timer has been started for, and stop it. By
using /dev/shm, we share information about "smart" timers between initrd
and root file system, and thus only calculate the timeout once.

Because we use major:minor to identify the devices in /dev/shm, and because
a removed device might be replaced by a different one with the same
major/minor number, add a rule to multipath.rules to remove the
find_multipaths marker on remove uevents.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: implement find_multipaths_timeout
Martin Wilck [Fri, 13 Apr 2018 22:00:08 +0000 (00:00 +0200)]
libmultipath: implement find_multipaths_timeout

This makes the timeout for "find_multipaths smart" configurable.
If the timeout has a negative value (default), it's applied only
to "known" hardware which is either in the hwtable or in a "device" section in
multipath.conf. For typical non-multipath hardware, which is not in the
hwtable, a short timeout of 1s is used, so that boot delays caused by
pointlessly waiting e.g. for SATA devices will be minimal.

It's expected that a "reasonable" timeout value depends less on the storage
hardware itself but on other properties of the data center such as network
latencies or distances. find_multipaths_timeout is therefore just a "defaults"
section setting.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath -u: add DM_MULTIPATH_DEVICE_PATH=2 for "maybe"
Martin Wilck [Fri, 13 Apr 2018 22:00:07 +0000 (00:00 +0200)]
multipath -u: add DM_MULTIPATH_DEVICE_PATH=2 for "maybe"

Use DM_MULTIPATH_DEVICE_PATH="2" to indicate that this might be a
valid path, but we aren't certain. This happens with find_multipaths
"smart", when the first path to a device (or a single-path
device) is encountered, and the device is neither blacklisted,
nor marked failed, nor whitelisted in the wwids file.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath -u: treat failed wwids as invalid
Martin Wilck [Fri, 13 Apr 2018 22:00:06 +0000 (00:00 +0200)]
multipath -u: treat failed wwids as invalid

If a WWID has been marked as "failed", don't treat it as "valid multipath
device path" in multipath -c/-u. This is key to achieve consistency between
multipathd and udev rule processing.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath -u: change output to environment/key format
Martin Wilck [Fri, 13 Apr 2018 22:00:05 +0000 (00:00 +0200)]
multipath -u: change output to environment/key format

... instead of free format. This provides more flexibility
for udev rule processing for the future. Adapt code in multipath.rules.
The exit status remains as usual. This affects "multipath -c", too.

The parameters "pathvec" and "conf" for print_cmd_valid are currently
unused, but will be in follow-up patches.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath -u: common code path for result message
Martin Wilck [Fri, 13 Apr 2018 22:00:04 +0000 (00:00 +0200)]
multipath -u: common code path for result message

Print the result message in one place only. This simplifies
future changes. multipath -c is also affected.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: indicate wwid failure in dm_addmap_create()
Martin Wilck [Fri, 13 Apr 2018 22:00:03 +0000 (00:00 +0200)]
libmultipath: indicate wwid failure in dm_addmap_create()

dm_addmap_create() is where we actually try to set up a new
multipath map. Depending on the result, mark the wwid as
failed (or not), and re-trigger an uevent if necessary.
If a path changes from multipath to non-multipath, use an "add"
event to make sure LVM2 rules pick it up. Increase log level
of this event to 3.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: functions to indicate mapping failure in /dev/shm
Martin Wilck [Fri, 13 Apr 2018 22:00:02 +0000 (00:00 +0200)]
libmultipath: functions to indicate mapping failure in /dev/shm

Create a simple API that indicates failure to create a map for a
certain WWID. This will allow multipathd to indicate to other tools
(in particular, "multipath -u" during udev processing) that
an attempt to create a map for a certain wwid failed.

The indicator is simply the existence of a file under
/dev/shm/multipath/failed_wwids. This has been chosen because it
"survives" during pivot-root between initrd and root file system.

The exact semantics of /dev/shm/multipath/failed_wwids/$WWID is:
"multipath or multipathd has tried to create this map from its
members with a DM_DEVICE_CREATE call, and failed on the latest,
or only, attempt to do so".

In particular, the existence of the file proves that here was at
least one unsuccessful attempt to create the map since the last
reboot. On the contrary, the non-existence of this file does not
indicate a successful attempt - perhaps multipathd never tried to
set up the map.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agolibmultipath: use const char* in open_file()
Martin Wilck [Fri, 13 Apr 2018 22:00:01 +0000 (00:00 +0200)]
libmultipath: use const char* in open_file()

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: change find_multipaths option to multi-value
Martin Wilck [Fri, 13 Apr 2018 22:00:00 +0000 (00:00 +0200)]
libmultipath: change find_multipaths option to multi-value

Change the "find_multipaths" option from yes/no to multi-value. This
option now covers the effects of "find_multipaths" as it used to be,
plus the -i option to multipath (ignore_wwids) and the -n option to
multipathd (ignore_new_devs), excluding such combinations of the former
options that are dangerous or inconsistent.

The possible values for "find_multipaths" are now:

 - strict: strictly stick to the WWIDs file; never add new maps automatically
   (new default; upstream behaviour with with find_multipaths "yes" and
   commit 64e27ec "multipathd: imply -n if find_multipaths is set")
 - off|no: multipath like "strict", multipathd like "greedy" (previous
   upstream default)
 - on|yes: set up multipath if >1 paths are seen (current Red Hat/Ubuntu
   behavior with find_multipaths "yes")
 - greedy: set up multipath for all non-blacklisted devices (current SUSE
   default)
 - smart: Like "yes", but try to avoid inconsistencies between udev processing
   and multipathd processing by waiting for path siblings to
   appear (fully implemented in follow-up patches)

The default has been changed to "strict", because "no" may cause inconsistent
behavior between "multipath -u" and multipathd. This is deliberately a
conservative choice.

The patch also updates the related man pages.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: trigger path uevent only when necessary
Martin Wilck [Fri, 13 Apr 2018 21:59:59 +0000 (23:59 +0200)]
libmultipath: trigger path uevent only when necessary

Paths that are already classified as DM_MULTIPATH_DEVICE_PATH don't
need to be retriggered.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: trigger change uevent on new device creation
Benjamin Marzinski [Fri, 13 Apr 2018 21:59:58 +0000 (23:59 +0200)]
libmultipath: trigger change uevent on new device creation

When multipath first sees a path device with find_multipaths
enabled, it can't know if the device should be multipathed. This means
that it will not claim the device in udev.  If the device is eventually
multipathed, multipath should trigger a change uevent to update the udev
database to claim the device.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath -u -i: respect entries in WWIDs file
Martin Wilck [Fri, 13 Apr 2018 21:59:57 +0000 (23:59 +0200)]
multipath -u -i: respect entries in WWIDs file

Previously, if find_multipaths was set, devices listed in the WWIDs file
weren't classified as multipath members by "multipath -u -i" unless they also
met the "find_multipaths" criteria (at least two paths, or existing map with
this WWID). Now we classify all paths in the WWIDs file as multipath members, too.

The rationale for this patch is to match the logic that multipathd applies
by default (i.e. without "-n").

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: should_multipath: keep existing maps
Martin Wilck [Fri, 13 Apr 2018 21:59:56 +0000 (23:59 +0200)]
libmultipath: should_multipath: keep existing maps

with find_multipaths "yes" and without the "-n" option to multipathd,
if a path is already multipathed, keep it. The same logic is applied by
"multipath -u -i".

To do this, we need to add a "mpvec" parameter to should_multipath().

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agoRevert "multipathd: imply -n if find_multipaths is set"
Martin Wilck [Fri, 13 Apr 2018 21:59:55 +0000 (23:59 +0200)]
Revert "multipathd: imply -n if find_multipaths is set"

This reverts commit 64e27ec066a001012f44550f095c93443e91d845.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agoRevert "multipath: ignore -i if find_multipaths is set"
Martin Wilck [Fri, 13 Apr 2018 21:59:54 +0000 (23:59 +0200)]
Revert "multipath: ignore -i if find_multipaths is set"

This reverts commit ffbb886a8a16cb063d669cd76a1e656fd3ec8c4b.

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: Fix logic in should_multipath
Martin Wilck [Fri, 13 Apr 2018 17:20:42 +0000 (19:20 +0200)]
libmultipath: Fix logic in should_multipath

Commit d3b71498 missed a negation.

Fixes: d3b71498 "multipath: fix rcu thread cancellation hang"
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipath-tools: add licence info to README
Xose Vazquez Perez [Fri, 13 Apr 2018 16:17:07 +0000 (18:17 +0200)]
multipath-tools: add licence info to README

Alternative patch to [PATCH v2 2/2] multipath-tools: link LICENSES/LGPL-2.0 to LICENSE.default

Cc: Hannes Reinecke <hare@suse.de>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Gris Ge <fge@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: create LICENSES dir with the text of all used licences
Xose Vazquez Perez [Tue, 10 Apr 2018 15:42:18 +0000 (17:42 +0200)]
multipath-tools: create LICENSES dir with the text of all used licences

On 04/10/2018 09:25 AM, Martin Wilck wrote:
> On Mon, 2018-04-09 at 18:51 +0200, Xose Vazquez Perez wrote:
>> Move COPYING -> LICENSES/GPL-2.0
>> Move COPYING.LESSER -> LICENSES/LGPL-2.0
>>
>> Add GPL-3.0 and LGPL-2.1 to the LICENSES dir.
>> Source directly from:
>> https://www.gnu.org/licenses/gpl-3.0.txt
>> https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
>>
>> Cc: Martin Wilck <mwilck@suse.com>
>> Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
>> Cc: device-mapper development <dm-devel@redhat.com>
>> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
>> ---
>
> I like this.
> Acked-by: Martin Wilck <mwilck@suse.com>
>
> I  suggest to add my posting from yesterday ("multipath-tools 0.7.6
> fossology license assessment") as "README.licenses".
> With these changes, we'd be in a fine state for the time being.
>
> Actual license changes can be considered for the long term, but don't
> need to be - the current situation is complex but not actually
> problematic. SPDX tags can be added to source files by and by, as we
> see fit.

In the meantime, this patch should clarify the default license:

From c10b33cd2385f3726a0a47e5356b7bec20b10963 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Tue, 10 Apr 2018 17:34:44 +0200
Subject: [PATCH] multipath-tools: link LICENSES/LGPL-2.0 to COPYING

Default licence is LGPL-2.0

Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months agomultipath-tools: create LICENSES dir with the text of all used licences
Xose Vazquez Perez [Mon, 9 Apr 2018 16:51:04 +0000 (18:51 +0200)]
multipath-tools: create LICENSES dir with the text of all used licences

Move COPYING -> LICENSES/GPL-2.0
Move COPYING.LESSER -> LICENSES/LGPL-2.0

Add GPL-3.0 and LGPL-2.1 to the LICENSES dir.
Source directly from:
https://www.gnu.org/licenses/gpl-3.0.txt
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt

Cc: Martin Wilck <mwilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2 months ago11-dm-mpath.rules: dont't run "multipath -U" during coldplug
Martin Wilck [Fri, 6 Apr 2018 11:45:21 +0000 (13:45 +0200)]
11-dm-mpath.rules: dont't run "multipath -U" during coldplug

When udevadm trigger is run after switching root, lots of simultaneous uevents
for both path and multipath devices arrive. In may happen that when "multipath
-U" is called on a dm device, the path's uevents haven't finished yet, thus
the paths aren't found in the udev db, and multipath -U erroneously concludes
that there are no usable paths. Avoid that by skipping "multipath -U" during
coldplug.

Fixes: "ce5ea6a 11-dm-mpath.rules: multipath -U for READY check"
Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmpathpersist: decrease log level of various messages
Martin Wilck [Wed, 4 Apr 2018 16:22:00 +0000 (18:22 +0200)]
libmpathpersist: decrease log level of various messages

Silence a few libmpathpersist messages which need not be printed
at the default loglevel.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipathd: decrease log level of waiter thread start/stop msgs
Martin Wilck [Wed, 4 Apr 2018 16:21:59 +0000 (18:21 +0200)]
multipathd: decrease log level of waiter thread start/stop msgs

These rather unimportant messages account for a large portion
of multipathd's log messages with the default verbosity level (2).

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: decrease log level of uevent filter/merge messages
Martin Wilck [Wed, 4 Apr 2018 16:21:58 +0000 (18:21 +0200)]
libmultipath: decrease log level of uevent filter/merge messages

There should be no need to log these at -v2. The messages are
informational.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agomultipathd: decrease log level of "spurious uevent" message
Martin Wilck [Wed, 4 Apr 2018 16:21:57 +0000 (18:21 +0200)]
multipathd: decrease log level of "spurious uevent" message

We trigger such events under various conditions, there's no point
logging them at -v2.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 months agolibmultipath: don't print undefined values
Benjamin Marzinski [Fri, 30 Mar 2018 03:37:03 +0000 (22:37 -0500)]
libmultipath: don't print undefined values

commit 48e9fd9f ("libmultipath: parser: use call-by-value for "snprint"
methods") removed some of the code that checked for undefined values to
avoid printing them.  This lead to device configurations that printed
out values for parameters that they hadn't configured. This patch adds
that code back in.

Fixes: 48e9fd9f ("libmultipath: parser: use call-by-value for "snprint" methods")
Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agompathcmd: fix libmpathcmd license
Benjamin Marzinski [Fri, 30 Mar 2018 03:37:02 +0000 (22:37 -0500)]
mpathcmd: fix libmpathcmd license

There is no version 2 of the GNU Lesser General Public License, so
change the license header to version 2.1, which does exist. Also copy
the license header to mpath_cmd.c. I've CC'ed everyone who has
contributed code to libmpathcmd.

Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: tang.junhui <tang.junhui@zte.com.cn>
Cc: Gris Ge <fge@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipathd: remove unneeded function parameter
Benjamin Marzinski [Fri, 30 Mar 2018 03:37:01 +0000 (22:37 -0500)]
multipathd: remove unneeded function parameter

remove_map_and_stop_waiter was always called with purge_vecs = 1, so
it can simply be removed, as suggested by Martin Wilck

Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipathd: minor dmevents polling code cleanups
Benjamin Marzinski [Fri, 30 Mar 2018 03:37:00 +0000 (22:37 -0500)]
multipathd: minor dmevents polling code cleanups

Change strncpy to strlcpy and lock_cleanup_pop to pthread_cleanup_pop,
based on suggestions by Martin Wilck

Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipath: add comments
Benjamin Marzinski [Fri, 30 Mar 2018 03:36:59 +0000 (22:36 -0500)]
multipath: add comments

This commit simply adds a number of comments based on suggestions by
Martin Wilck.

Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 months agomultipathd: remove incorrect pthread_testcancel
Benjamin Marzinski [Fri, 30 Mar 2018 03:36:58 +0000 (22:36 -0500)]
multipathd: remove incorrect pthread_testcancel

As Martin Wilck pointed out, a thread that's trying to stop the waiter
thread should not cancel itself before it gets a chance to do so

Cc: Martin Wilck <mwilck@suse.com>
Fixes: c7625f92 "multipathd: fix waiter thread cancelling"
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>