multipath-tools/.git
2 days agoBump version to 0.7.3 master 0.7.3
Christophe Varoqui [Wed, 20 Sep 2017 17:04:24 +0000 (19:04 +0200)]
Bump version to 0.7.3

2 days agokpartx.rules: move symlink code to other files
Martin Wilck [Thu, 14 Sep 2017 20:00:10 +0000 (22:00 +0200)]
kpartx.rules: move symlink code to other files

Current kpartx.rules combines two purposes: setting properties and
creating symlinks for dm partition devices, and creating such
partition devices on top of other devices. This is contrary to
common conventions for udev rules files.

This patch moves the code for properties and symlinks into other
files. The code that generates symlinks for multipath maps is moved
to 11-dm-mpath.rules, and for partitions we introduce a new file
11-dm-parts.rules. Necessarily this results in minor code duplication.
OTOH quite some code is removed because the properties are now set
before 13-dm-disk.rules runs, so we can rely on the latter to create
the symlinks.

The reason I put this last in the series is that it will possibly
require changes in other packages, notably dracut, in order to make
sure partitions mappings are cleanly set up during boot.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx/del-part-nodes.rules: new udev file
Martin Wilck [Thu, 14 Sep 2017 20:00:09 +0000 (22:00 +0200)]
kpartx/del-part-nodes.rules: new udev file

A new udev rules file "68-del-part-nodes.rules" is introduced,
based on code from Ben Marzinki. This code deletes partitions on
multipath member devices. The purpose of this is to avoid users
accidentally accessing partitions of member devices rather than of the
multipath devcice. The deletion is done only once for every disk
device. If the user wants to get the partitions back, he can run "partx
-a" or "partprobe" on the disk device.

This code could be extended to wipe partitions on member devices
of non-multipath dm targets if desired.

Means to deactivate this behavior are provided via kernel parameter
"dont_del_part_nodes", or a custom udev rules file setting the
"DONT_DEL_PART_NODES" environment variable.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agomultipath/kpartx rules: avoid superfluous scanning
Martin Wilck [Sat, 2 Sep 2017 22:38:58 +0000 (00:38 +0200)]
multipath/kpartx rules: avoid superfluous scanning

Multipath maps receive certain udev events that only indicate
changes in the path list. Use MPATH_UNCHANGED to tell this to
upper layers, so that they can ignore the event.

multipathd-generated events with DM_SUBSYSTEM_UDEV_FLAG0 are one
case, and kernel-generated PATH_FAILED and PATH_REINSTATED events
are another.

The LVM rules rely on DM_ACTIVATION, but other rules such as
kpartx can't do that, because they'd miss e.g. partition table
changes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx.rules: fix logic for adding partitions
Martin Wilck [Sat, 2 Sep 2017 22:38:57 +0000 (00:38 +0200)]
kpartx.rules: fix logic for adding partitions

Based on code by Ben Marzinski, this patch updates kpartx.rules.

The main change is that the flags that determine whether scanning is now
possible are DM_NOSCAN and DM_SUSPENDED. This assumes that said flags
are set correctly by 11-dm-mpath.rules.

Note that kpartx can't just be run if DM_ACTIVATION=1; doing so we
would miss events caused e.g. by partition table editing. It's not
necessary to scan for certain events. This will be handled in another
patch.

Currently this works for multipath only, but code for other targets
could be added if desired.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx.rules: generate type-name links only for multipath devices
Martin Wilck [Sat, 2 Sep 2017 22:38:56 +0000 (00:38 +0200)]
kpartx.rules: generate type-name links only for multipath devices

... and their partitions. This rule generates irritiating symlinks
like /dev/disk/by-id/raid-${VG}-${LV} for LVM LVs otherwise.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx.rules: create by-partuuid and by-partlabel symlinks
Martin Wilck [Sat, 2 Sep 2017 22:38:55 +0000 (00:38 +0200)]
kpartx.rules: create by-partuuid and by-partlabel symlinks

The LVM rules do this since 2.02.173 (c48149cf80 "udev: also
create /dev/disk/by-part{label,uuid} and gpt-auto-root symlinks").
We have to do it here for partitions on unaccessible mpath maps.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx.rules: improved logic for by-uuid and by-label links
Martin Wilck [Sat, 2 Sep 2017 22:38:54 +0000 (00:38 +0200)]
kpartx.rules: improved logic for by-uuid and by-label links

If blkid can be run, these links are already set up by 13-dm-disk.rules.
In the DM_NOSCAN=1 case, they are imported from db in 11-dm-mpath.rules
for multipath maps, but not for partitions (there is currently no flag
for kpartx-generated partitions that indicates whether the device will
be able to do IO).

Moreover, the previous logic for running IMPORT{db} was wrong (condition
used '=="?*"' rather than '!="?*"').

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx.rules: respect DM_UDEV_LOW_PRIORITY_FLAG
Martin Wilck [Sat, 2 Sep 2017 22:38:53 +0000 (00:38 +0200)]
kpartx.rules: respect DM_UDEV_LOW_PRIORITY_FLAG

kpartx.rules increased link priority unconditionally, but for
explicitly marked low prio devices that shouldn't be done.
Fix that. Also, use "+=" for OPTIONS, as most other rules do.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agokpartx.rules: don't rely on DM_DEPS and DM_TABLE_STATE
Martin Wilck [Sat, 2 Sep 2017 22:38:52 +0000 (00:38 +0200)]
kpartx.rules: don't rely on DM_DEPS and DM_TABLE_STATE

These tests (which were SUSE-specific anyway) are not needed
here. The kpartx invocation further down is guarded separately.
SYMLINK actions must be run in any case for consistency, and
there's no need to access the udev db here because kpartx_id
also works on otherwise broken devices.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agomultipath.rules: set ID_FS_TYPE to "mpath_member"
Martin Wilck [Sat, 2 Sep 2017 22:38:51 +0000 (00:38 +0200)]
multipath.rules: set ID_FS_TYPE to "mpath_member"

... for devices that have been identified as such.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days ago11-dm-mpath.rules: handle new maps with READY==0
Martin Wilck [Sat, 2 Sep 2017 22:38:48 +0000 (00:38 +0200)]
11-dm-mpath.rules: handle new maps with READY==0

We need to distinguish the case where a device came up with
ENV{MPATH_DEVICE_READY}=="0" in the first place from the case
where it changed from "ready" to "not ready".

Otherwise, we may save a wrong state in DM_DISABLE_OTHER_RULES_FLAG_OLD.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days ago11-dm-mpath.rules: no need to test before IMPORT
Martin Wilck [Sat, 2 Sep 2017 22:38:47 +0000 (00:38 +0200)]
11-dm-mpath.rules: no need to test before IMPORT

This code is run before 13-dm-disk.rules which calls "blkid",
therefore the code can be simplified because the condition checked
always holds.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days ago11-dm-mpath.rules: import more ID_FS_xxx vars from db
Martin Wilck [Sat, 2 Sep 2017 22:38:46 +0000 (00:38 +0200)]
11-dm-mpath.rules: import more ID_FS_xxx vars from db

We have code for importing blkid variables from db but this code
is missing the _ENC variants needed for creating symlinks, and
ID_FS_LABEL.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days ago11-dm-mpath.rules: multipath -U for READY check
Martin Wilck [Sat, 2 Sep 2017 22:38:45 +0000 (00:38 +0200)]
11-dm-mpath.rules: multipath -U for READY check

For kernel-generated path events, DM_NR_VALID_PATHS indicates
whether usable paths are available. But this information isn't
reliable as events may be received out of order.

Use multipath -U to determine whether a multipath map can
handle I/O.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agomultipath: implement "check usable paths" (-C/-U)
Martin Wilck [Sat, 2 Sep 2017 22:38:44 +0000 (00:38 +0200)]
multipath: implement "check usable paths" (-C/-U)

When we process udev rules, it's crucial to know whether I/O on a given
device will succeed. Unfortunately DM_NR_VALID_PATHS is not reliable,
because the kernel path events aren't necessarily received in order, and
even if they are, the number of usable paths may have changed during
udev processing, in particular when there's a lot of load on udev
because many paths are failing or reinstating at the same time.
The latter problem can't be completely avoided, but the closer the
test before the actual "blkid" call, the better.

This patch adds the -C/-U options to multipath to check if a given
map has usable paths. Obviously this command must avoid doing any I/O
on the multipath map itself, thus no checkers are called; only status
from sysfs and dm is collected.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agolibmultipath: add dm_get_multipath
Martin Wilck [Sat, 2 Sep 2017 22:38:43 +0000 (00:38 +0200)]
libmultipath: add dm_get_multipath

This function is simply factored out from dm_get_maps.
No functional difference.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agolibmultipath: add DI_NOIO flag for pathinfo
Martin Wilck [Sat, 2 Sep 2017 22:38:42 +0000 (00:38 +0200)]
libmultipath: add DI_NOIO flag for pathinfo

This flag can used to avoid any IO on the device itself. Useful
for getting the path state without the risk of hanging or running
into IO errors.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agolibmultipath: use const char* in some dm helpers
Martin Wilck [Sat, 2 Sep 2017 22:38:41 +0000 (00:38 +0200)]
libmultipath: use const char* in some dm helpers

Changing dm_get_info and dm_get_uuid for now.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agolibmultipath: get_refwwid: use get_udev_device
Martin Wilck [Sat, 2 Sep 2017 22:38:40 +0000 (00:38 +0200)]
libmultipath: get_refwwid: use get_udev_device

Call the factored-out function to obtain the udev device.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agolibmultipath: add get_udev_device
Martin Wilck [Sat, 2 Sep 2017 22:38:39 +0000 (00:38 +0200)]
libmultipath: add get_udev_device

This factors out the functionality of retrieving the
udev_device from different device types from get_refwwid.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 days agolibmultipath: support MPATH_UDEV_NO_PATHS_FLAG on map creation
Martin Wilck [Sat, 2 Sep 2017 22:38:38 +0000 (00:38 +0200)]
libmultipath: support MPATH_UDEV_NO_PATHS_FLAG on map creation

Some vendor kernels (e.g. SUSE) have supported loading multipath
maps without valid paths for a long time. Without that feature,
problems can occur in failover scenarios when multipathd tries
to (re)load maps after device failure/removal, because multipathd's
attempts to reload the configuration may fail unnecessarily.
The discussion in the kernel community is ongoing
(see e.g. https://patchwork.kernel.org/patch/4579551/).

One corner case of this is creation of a map with only failed
paths. Such maps can be created if the kernel patch mentioned above
is applied. The current udev rules for dm-multipath can't detect
this situation. This patch fixes that by setting
DM_SUBSYSTEM_UDEV_FLAG2, which is already used for the "map reload"
case with no valid paths. Thus no additional udev rules are required
to detect this situation.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agokpartx: only recognize dasd part table on DASD
Martin Wilck [Sat, 2 Sep 2017 22:38:37 +0000 (00:38 +0200)]
kpartx: only recognize dasd part table on DASD

The code for reading DASD partition tables is so generic
that it will pretend to find a partition even on a totally
zeroed disk. Prevent that by recognizing dasd partition tables
only on DASD disks. Such a check was already present for DM
mappings on DASD, but (strangely) not for DASD itself.

Without this, kpartx will (try to) create a partition mapping
on a loop device with no partition table.

Found this during testing because test-kpartx unexpectedly
succeeded without my "fix part deletion without partition table" fix
when run on a loop device. That was caused by this bug pretending an
existing partition table although there was none.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agotest-kpartx: test deletion with empty part table
Martin Wilck [Sat, 2 Sep 2017 22:38:36 +0000 (00:38 +0200)]
test-kpartx: test deletion with empty part table

Added a test case for "kpartx: fix part deletion without partition
table".

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agokpartx: fix part deletion without partition table
Martin Wilck [Sat, 2 Sep 2017 22:38:35 +0000 (00:38 +0200)]
kpartx: fix part deletion without partition table

If we are deleting partition mappings, there's no need to
parse the partition table. We just look for mappings created
by kpartx and destroy them. Without this patch, kpartx fails
to delete partition mappings on devices on which the partition
table has been destroyed.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agokpartx: fix a corner case when renaming partitions
Martin Wilck [Sat, 2 Sep 2017 22:38:34 +0000 (00:38 +0200)]
kpartx: fix a corner case when renaming partitions

Fix a pathological issue that I discovered with test-kpartx.
When a dm device is named like a device node (e.g. dm name "loop1"),
kpartx would erroneously pick the dm device if asked to work on
partitions on the other device. Fortunately we can use the UUID
scheme created earlier to see whether or not the device is a dm device.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agotest-kpartx: add tests for renaming functionality
Martin Wilck [Sat, 2 Sep 2017 22:38:33 +0000 (00:38 +0200)]
test-kpartx: add tests for renaming functionality

Add test for the functionality implemented in patch
"kpartx: search partitions by UUID, and rename".

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agokpartx: search partitions by UUID, and rename
Martin Wilck [Sat, 2 Sep 2017 22:38:32 +0000 (00:38 +0200)]
kpartx: search partitions by UUID, and rename

Partition mappings may have been created by other tools such as parted,
multipathd (during map renaming), or kpartx itself with different
delimiter (-p) option. In such cases kpartx fails, because the partition
mappings have a different name. However, we have a convention for UUID
mappings which seems to be more universal. So, when the search for the
named partition fails, search for the UUID instead and try to rename the
map.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agokpartx: helper functions for name and uuid generation
Martin Wilck [Sat, 2 Sep 2017 22:38:31 +0000 (00:38 +0200)]
kpartx: helper functions for name and uuid generation

strip_slash() is copied from kpartx.c, and will be removed there
in a follow-up patch. The others are new helpers.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: fix partition_delimiter config option
Martin Wilck [Sat, 2 Sep 2017 22:38:30 +0000 (00:38 +0200)]
libmultipath: fix partition_delimiter config option

The partition_delimiter setting was effecitvely ignored. Fix it.

Fixes: 95bf339bb9d7 "correctly set partition delimiter on rename"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agohwtable: set 'none' as default checker for NVMe
Hannes Reinecke [Fri, 15 Sep 2017 06:30:30 +0000 (08:30 +0200)]
hwtable: set 'none' as default checker for NVMe

We shouldn't be using the directio checker for NVMe, as this might
cause spurious path failures under high load.
As the 'state' attribute provides reliable information about the link
status it's sufficient to just check this and don't call any
path checkers.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agoAdd 'none' checker
Hannes Reinecke [Fri, 15 Sep 2017 06:30:29 +0000 (08:30 +0200)]
Add 'none' checker

For NVMe we don't have a good way of checking the path state, so
add a new checker 'none' which doesn't do any checking, but rely
on the internal sysfs state for path checking.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agolibmultipath/discovery: modify NVMe path states
Hannes Reinecke [Fri, 15 Sep 2017 06:30:28 +0000 (08:30 +0200)]
libmultipath/discovery: modify NVMe path states

The NVMe path states 'resetting' and 'reconnecting' indicate that
the controller could not talk to the namespace, which translates
into a path down state, not a path pending state.
Path pending should only be used for short lived intermediate states
like 'new' or 'deleting'.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agodiscovery: sanitize NVMe discovery
Hannes Reinecke [Fri, 15 Sep 2017 06:30:27 +0000 (08:30 +0200)]
discovery: sanitize NVMe discovery

Bring the output of NVMe discovery inline with the other transports,
and set the sg_id mappings to avoid ugly '#' outputs.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agomultipath-tools: libdmmp: New function to flush and reconfig
Gris Ge [Wed, 16 Aug 2017 12:34:09 +0000 (20:34 +0800)]
multipath-tools: libdmmp: New function to flush and reconfig

New functions:
    * dmmp_reconfig() to invoke reconfiguration of multipathd daemon.
    * dmmp_flush_mpath() to flush/del unused mpath.

Signed-off-by: Gris Ge <fge@redhat.com>
3 days agomultipath-tools: libdmmp: Improve timeout mechanism
Gris Ge [Wed, 16 Aug 2017 12:34:08 +0000 (20:34 +0800)]
multipath-tools: libdmmp: Improve timeout mechanism

Issue:
    libdmmp return error of timeout before user requested timeout was
    met.
    This happens when multipathd daemon is starting with a lot(1k+) mpaths.

Root cause:
    The multipath has two timeout settings:
        1. 'uxsock_timeout' in multipath.conf
        2. libmpathcmd timeout argument.
    And the first is not controllable in current libdmmp code.

Fix:
    * Only keep 1 timeout setting in libdmmp:
        dmmp_context_timeout_set()/dmmp_context_timeout_get().
    * libdmmp will keep reply until meet user requested timeout.
    * Allow user to set timeout as 0 which mean infinite, only return
      when error or pass.
    * Updated libdmmp.h document to to indicate timeout 0 as infinite.
    * Increase timeout setting in libdmmp test case to test this
      mechanism.

Signed-off-by: Gris Ge <fge@redhat.com>
3 days agomultipath-tools: Remove the limitation of IPC command reply length.
Gris Ge [Wed, 16 Aug 2017 12:34:07 +0000 (20:34 +0800)]
multipath-tools: Remove the limitation of IPC command reply length.

Issue:
    libmpathcmd will reply error 22(Invalid argument) when having 1000
    mpath.

Root cause:
    libmpathcmd return error when reply string length exceeded the 65535.

Fix:
    Remove the limitation on reply data length.

Extra:
    Initially this limitation was removed and improved by commit
    bb219efb131aef61c331f181193bf1d80e6b2a99
    but then was added back via commit
    7381c3f2b19903cc56d1ddafb13e8ad3afc08580

Signed-off-by: Gris Ge <fge@redhat.com>
3 days agomultipath-tools: add info about adding new hardware
Xose Vazquez Perez [Tue, 12 Sep 2017 16:24:01 +0000 (18:24 +0200)]
multipath-tools: add info about adding new hardware

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>
3 days agolibmultipath: update INFINIDAT builtin config
Arnon Yaari [Tue, 29 Aug 2017 11:27:22 +0000 (14:27 +0300)]
libmultipath: update INFINIDAT builtin config

Based on the manufacturer documentation:
https://support.infinidat.com/hc/en-us/articles/202319222

INFINIDAT recommends round-robin path selector using
a different path per IO. Timeout and path recovery values
are adjusted for error-free hot upgrade scenarios.

Signed-off-by: Arnon Yaari <arnony@infinidat.com>
3 days agomultipath-tools: add Dot Hill/Seagate arrays to hwtable
Xose Vazquez Perez [Sat, 12 Aug 2017 16:30:36 +0000 (18:30 +0200)]
multipath-tools: add Dot Hill/Seagate arrays to hwtable

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>
3 days agomultipath-tools: add Xiotech iglu blaze arrays to hwtable
Xose Vazquez Perez [Thu, 10 Aug 2017 19:18:24 +0000 (21:18 +0200)]
multipath-tools: add Xiotech iglu blaze arrays to hwtable

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>
3 days agomultipath-tools: add support for all arrays from Sun StorEdge 3000 family
Xose Vazquez Perez [Thu, 10 Aug 2017 19:18:09 +0000 (21:18 +0200)]
multipath-tools: add support for all arrays from Sun StorEdge 3000 family

They were made by Dot Hill.

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>
3 days agomultipath-tools: remove Sun StorEdge T4(6020,6120,6320) arrays from hwtable
Xose Vazquez Perez [Wed, 9 Aug 2017 17:00:56 +0000 (19:00 +0200)]
multipath-tools: remove Sun StorEdge T4(6020,6120,6320) arrays from hwtable

Multipathing for these arrays is not supported by multipath-tools.
Only available with Sun StorEdge Traffic Manager software.
Or with a "new" infrastructure: https://marc.info/?l=dm-devel&m=116322662722330

Cc: James Cassidy <jcassidy@qfire.net>
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>
3 days agomultipath-tools: link internal libraries before foreigns
Martin Wilck [Mon, 14 Aug 2017 20:40:43 +0000 (22:40 +0200)]
multipath-tools: link internal libraries before foreigns

Otherwise, the runtime linker may resolve foreign symbols instead of
internal ones for certain symbol names (observed with xfree()
from libreadline).

Reported-by: nikola.pajkovsky@suse.com
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: cli_add_map: Use CMD_NONE
Martin Wilck [Mon, 14 Aug 2017 20:40:42 +0000 (22:40 +0200)]
libmultipath: cli_add_map: Use CMD_NONE

Commands issued from the daemon itself should always pass
CMD_NONE to coalesce_paths. Otherwise, the daemon mistakenly
tries to talk to itself via the socket, causing deadlock.

Reproduce simply by calling "multipathd add map $X".

Fixes: d19936f4 "libmultipath: Do not access 'conf->cmd' in domap()"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agokpartx/devmapper.h: remove dm_no_partitions
Martin Wilck [Mon, 14 Aug 2017 20:40:41 +0000 (22:40 +0200)]
kpartx/devmapper.h: remove dm_no_partitions

This removes the deleted function from the header file.

Fixes: 2ea69fc9 'kpartx: remove "no_partitions" support'
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: sanitize fd handling
Hannes Reinecke [Fri, 15 Sep 2017 06:15:12 +0000 (08:15 +0200)]
libmultipath: sanitize fd handling

One should remember that '0' _is_ a valid fd, so we need to set
the fd to '-1' upon allocating the path structure and ensure we're
checking for a value _smaller_ than 0 to detect an invalid fd.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 days agomultipath-tools: replace "setting: array" with "setting: storage device" at multipath...
Xose Vazquez Perez [Sun, 20 Aug 2017 00:47:13 +0000 (02:47 +0200)]
multipath-tools: replace "setting: array" with "setting: storage device" at multipath output

Reported-by: 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>
3 days agomultipath-tools: clarify how to dump the multipathd config
Xose Vazquez Perez [Mon, 28 Aug 2017 23:46:59 +0000 (01:46 +0200)]
multipath-tools: clarify how to dump the multipathd config

Reported-by: Martin Wilck <mwilck@suse.com>
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>
3 days agolibmultipath: add_feature: allow only 1 feature
Martin Wilck [Mon, 28 Aug 2017 22:05:35 +0000 (00:05 +0200)]
libmultipath: add_feature: allow only 1 feature

The existing test "if feature is already present" doesn't work for
multiple features, and we are only using add_feature() for single
feature additions anyway. Simplify the code by not allowing spaces
in the feature string to be added. This way we can drop the
complex "count new features" code. Moreover, print an error message if
the existing features string is malformed.

The old code calculated the width of the feature count twice, and the
second time messed up the buffer length field passed to snprintf(); fix
that, too.  Finally, replace several strcat() invocations by one
strncpy() call to make the code easier to review.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agolibmultipath: add_feature: skip pointless NULL check
Martin Wilck [Mon, 28 Aug 2017 22:05:34 +0000 (00:05 +0200)]
libmultipath: add_feature: skip pointless NULL check

The case f == NULL is already handled by the code from
b1ecdd46b6ec "segment faulty occured in add_feature()" above.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agomultipathd: don't flood system with sd_notify calls
Martin Wilck [Mon, 28 Aug 2017 22:05:33 +0000 (00:05 +0200)]
multipathd: don't flood system with sd_notify calls

DAEMON_RUNNING is only used by checkerloop to indicate that
path checkers are running. checkerloop switches back and forth
between DAEMON_IDLE and DAEMON_RUNNING in every iteration, i.e.
it performs two status changes per second on an idle system.
The repeated sd_notify() calls cause a lot of traffic on dbus as
systemd forwards these messages on the system bus. This can be
seen with systemd.log_level=debug. Better skip these notifications
that don't provide useful information to the user, who is very
unlikely to catch the daemon in "running" state anyway.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 days agomultipath-tools: fix incorrect length for strncmp in uevent.c
Guan Junxiong [Tue, 5 Sep 2017 03:54:42 +0000 (11:54 +0800)]
multipath-tools: fix incorrect length for strncmp in uevent.c

Cc: Martin Wilck <mwilck@suse.com>
Signed-off-by: Junxiong Guan <guanjunxiong@huawei.com>
3 days agomultipath-tools: minor edition and corrections in multipath.conf.5
Xose Vazquez Perez [Thu, 17 Aug 2017 22:42:14 +0000 (00:42 +0200)]
multipath-tools: minor edition and corrections in multipath.conf.5

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>
3 days agompathpersist: add support for prkeys file
Benjamin Marzinski [Fri, 15 Sep 2017 22:25:36 +0000 (17:25 -0500)]
mpathpersist: add support for prkeys file

When the reservation_key is set to "file", the reservation key needs to
be added to the prkeys file for multipathd to be able to register new
paths as they are added to the device.  This patch adds support to the
mpathpersist command to message multipathd when a key is registered or
unregistered to either add or remove the mapping from the prkeys file.

With these changes, once a device is configured to use the prkeys file,
running mpathpersist commands will automatically update the prkeys file
as necessary.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 days agomultipath: add alternate reservation_key method
Benjamin Marzinski [Fri, 15 Sep 2017 22:25:35 +0000 (17:25 -0500)]
multipath: add alternate reservation_key method

The scsi persistent reservation API doesn't force devices to implement
any method to display the mapping from a reservation key to an I_T Nexus
(the READ_FULL_STATUS action is an optional later addition, and a number
of devices don't support it). To allow multipathd to determine the
correct reservation key for a device without support from the device
itself, it uses the reservation_key configuration option. Unfortunately,
using this option forces the multipath configuration to be updated
whenever a new scsi registration key is used.  This isn't acceptable to
some users, who want a static configuration file.

This patch provides an alternate method of setting the reservation_key
for the multipath device. The reservation_key configuration option now
also accepts the keyword "file". If this is used, multpath will look in
the new prkeys file (by default "/etc/multipath/prkeys") for a line with
the device wwid and it's associated reservation_key. Where a device's
reservation key comes from is tracked by the prkey_source variable,
which is set and read through the reservation_key dict.c functions.

There are also new multipathd commands to get, set, and unset the
mappings in the prkesy file. Currently,

"multipathd map $map setprkey key $key" sets the mapping
"multipathd map $map unsetprkey" unsets the mapping
"multipathd map $map getprkey" gets the current reservation_key for a
multipath device.

There is some lack of symmetry here where you are allowed to set and
unset mappings even for devices that aren't configured to use the prkeys
file, but you will only get the mapping from the prkeys file for devices
that are configured to use it. Otherwise you will get the mapping from
multipath.conf. In other words, setprkey and unsetprkey return success
but don't do anything useful unless a device is configured with

reservation_key file

but getprkey will return the device's current reservation_key regardless
of where the key came from.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 days agolibmpathpersist: fix update_prflag code
Benjamin Marzinski [Fri, 15 Sep 2017 22:25:34 +0000 (17:25 -0500)]
libmpathpersist: fix update_prflag code

There are multiple problems with the prflag code. First, it doesn't do
anything useful at all currently. update_prflags is called with "set"
and "unset" instead of "setprstatus" and "unsetprstatus", so it doesn't
actually enable persistent reservation tracking in multipathd when a key
is registered. Second, the string is to store the multipathd message is
64 bytes long, while just a WWID, which can be used as an alias, can be
128 bytes long, so it's possible to run out of space in the message.
Finally, it is called by mpath_persistent_reserve_out when doing a
preempt and abort, which doesn't make any sense. This disables
multipathd persistent reservation tracking when a node has just taken
over the reservation on a device.

This patch fixes these issues, cleans up the return codes and variable
names, and splits update_prflag into two functions, so that the bulk of
the work (now in do_update_pr), can be reused by other callers.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 days agolibmultipath: change reservation_key to a be64
Benjamin Marzinski [Fri, 15 Sep 2017 22:25:32 +0000 (17:25 -0500)]
libmultipath: change reservation_key to a be64

The reservation key is currently being stored as any array of 8 unsigned
chars.  This is exactly the same in-memory representation as a big
endian 64 bit integer. However, the code for dealing with a big endian
64 bit integer is much simpler, so switch to use that instead.  Instead
of directly using a uint64_t, which could cause problems if people
forgot the conversion from cpu order to big endian, Martin suggested
using a structure and some helper macros to store it.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 days agolibmultipath: pull functions into util.c
Benjamin Marzinski [Fri, 15 Sep 2017 22:25:31 +0000 (17:25 -0500)]
libmultipath: pull functions into util.c

This patch just pulls safe_write out of rbd. and the persistent
reservation key parsing code out of dict.c and puts them in util.c,
so that other functions can make use of them.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 days agolibmultipath: add pthread_cleanup hook for udev monitor
Hannes Reinecke [Fri, 15 Sep 2017 06:14:30 +0000 (08:14 +0200)]
libmultipath: add pthread_cleanup hook for udev monitor

The udev monitor from uevent_listen() needs to be cleaned up from
a pthread cleanup hook.
Valgrind complained here.

Signed-off-by: Hannes Reinecke <hare@suse.com>
7 weeks agoBump version to 0.7.2 0.7.2
Christophe Varoqui [Sat, 5 Aug 2017 06:35:36 +0000 (08:35 +0200)]
Bump version to 0.7.2

7 weeks agolibmultipath: update 3PARdata builtin config
Benjamin Marzinski [Mon, 26 Jun 2017 19:03:19 +0000 (14:03 -0500)]
libmultipath: update 3PARdata builtin config

This updated config comes from hp.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
7 weeks agomultipath-tools: fix format in multipath.conf.5
Xose Vazquez Perez [Fri, 4 Aug 2017 23:44:29 +0000 (01:44 +0200)]
multipath-tools: fix format in multipath.conf.5

multipath/multipath.conf.5:408: warning: can't find font `,'

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>
7 weeks agomultipath-tools: beautify path_latency.c code
Xose Vazquez Perez [Thu, 22 Jun 2017 16:46:23 +0000 (18:46 +0200)]
multipath-tools: beautify path_latency.c code

Mainly running scripts/Lindent, from kernel dir, to replace indent spaces
by tabs.

Cc: Yang Feng <philip.yang@huawei.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>
7 weeks agomultipath-tools: sync third-party headers with 3.13 upstream
Xose Vazquez Perez [Wed, 21 Jun 2017 12:26:39 +0000 (14:26 +0200)]
multipath-tools: sync third-party headers with 3.13 upstream

Cc: Bart Van Assche <bart.vanassche@sandisk.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>
7 weeks agomultipath-tools: check sysfs path state for NVMe/NVMf
Guan Junxiong [Fri, 28 Jul 2017 01:28:43 +0000 (09:28 +0800)]
multipath-tools: check sysfs path state for NVMe/NVMf

The previous code of path_offline checking was only valid for SCSI
device. It returned PATH_UP for other devices and throwed path check-
ing to chekers. This patch supplements checking sysfs path state for
NVMe/NVMf devices. For example, if NVMe/NVMf path is reconnectting or
resetting, we return PATH_PENDING in order to skip current path check-
ing and reschedule path checking in the next tick as soon as possible.

Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com>
7 weeks agomultipath-tools: add/change fujitsu arrays
Xose Vazquez Perez [Fri, 21 Jul 2017 19:06:31 +0000 (21:06 +0200)]
multipath-tools: add/change fujitsu arrays

E[234]000 are a/a asymmetric with alua support
E[68]000  are a/a symmetric

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>
7 weeks agolibmultipath: fix over-long NVME WWIDs
Martin Wilck [Tue, 18 Jul 2017 07:29:16 +0000 (09:29 +0200)]
libmultipath: fix over-long NVME WWIDs

Fix for NVME wwids looking like this (line continuations inserted here
for readability):

nvme.0000-3163653363666438366239656630386200-\
4c696e75780000000000000000000000000000000000000000000000000000000000000000000000-\
00000002

which are encountered in some combinations of Linux NVME host and target,
where the 2nd field represents the serial number (SN) and the 3rd the
model number (MN).

The device mapper allows map names only up to 128 characters.
Strip the "00" sequences at the end of the serial and model field,
they are hex-encoded 0-bytes which are forbidden by the NVME spec
anyway.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Guan Junxiong <guanjunxiong@huawei.com>
7 weeks agolibmultipath: only listen for uevents with DEVTYPE=disk
Martin Wilck [Tue, 18 Jul 2017 07:29:15 +0000 (09:29 +0200)]
libmultipath: only listen for uevents with DEVTYPE=disk

We are only interested in disks anyway. This saves us checking
for devtype in the uevent processing queue, and is more powerful
than the previous test in the dropped function
uevent_can_discard_by_devpath().

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: "Schremmer, Steven" <Steve.Schremmer@netapp.com>
Reviewed-by: Guan Junxiong <guanjunxiong@huawei.com>
7 weeks agolibmultipath: drop uevent_can_discard_by_devpath
Martin Wilck [Tue, 18 Jul 2017 07:29:14 +0000 (09:29 +0200)]
libmultipath: drop uevent_can_discard_by_devpath

This function is broken. Not all devices that matter for multipathd
follow the block/$DEVICE/$PARTITION convention (example: NVME)

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: "Schremmer, Steven" <Steve.Schremmer@netapp.com>
Reviewed-by: Guan Junxiong <guanjunxiong@huawei.com>
7 weeks agolibmultipath: get_udev_uid: make sure pp->wwid is 0-terminated
Martin Wilck [Tue, 18 Jul 2017 07:29:13 +0000 (09:29 +0200)]
libmultipath: get_udev_uid: make sure pp->wwid is 0-terminated

If the first WWID_LEN bytes of the uuid_attribute do not contain
a 0 byte, pp->wwid may end up not properly terminated. Fix it by
using strlcpy() rather than strncpy().

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
7 weeks agomultipath-tools: add HPE MSA 2050/2052 to hwtable
Xose Vazquez Perez [Sat, 8 Jul 2017 11:45:19 +0000 (13:45 +0200)]
multipath-tools: add HPE MSA 2050/2052 to hwtable

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>
7 weeks agomultipath-tools: add HPE StoreVirtual 3200 family to hwtable
Xose Vazquez Perez [Fri, 7 Jul 2017 13:55:45 +0000 (15:55 +0200)]
multipath-tools: add HPE StoreVirtual 3200 family to hwtable

It's a new LEFTHAND array.

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>
7 weeks agolibmultipath: fix unit to seconds in log message for checker timeout
Martin Wilck [Tue, 27 Jun 2017 15:11:47 +0000 (17:11 +0200)]
libmultipath: fix unit to seconds in log message for checker timeout

checker_timeout is in seconds, not milliseconds, since 905281da
"Specify checker_timeout in seconds". Fix the log messages.

Signed-off-by: Martin Wilck <mwilck@suse.com>
7 weeks agomultipath-tools: delete libdmmp/docs/man directory in make clean
Xose Vazquez Perez [Sat, 24 Jun 2017 18:06:13 +0000 (20:06 +0200)]
multipath-tools: delete libdmmp/docs/man directory in make clean

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>
7 weeks agokpartx.rules: Fix syntax error in skip_kpartx code
Martin Wilck [Fri, 23 Jun 2017 21:57:40 +0000 (23:57 +0200)]
kpartx.rules: Fix syntax error in skip_kpartx code

Fixes: 22736419 "kpartx.rules: respect skip_kpartx flag"
Signed-off-by: Martin Wilck <mwilck@suse.com>
7 weeks agomultipath-tools: move up TEMPLATE in hwtable
Xose Vazquez Perez [Fri, 23 Jun 2017 21:13:51 +0000 (23:13 +0200)]
multipath-tools: move up TEMPLATE in hwtable

and the 'MD Series' comment to the right place.

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>
7 weeks agolibmultipath: retain_attached_hw_handler obsolete with 4.3+
Martin Wilck [Thu, 22 Jun 2017 14:59:11 +0000 (16:59 +0200)]
libmultipath: retain_attached_hw_handler obsolete with 4.3+

Kernels 4.3 and newer (commit 1bab0de0 "dm-mpath, scsi_dh: don't
let dm detach device handlers") imply "retain_attached_hw_handler yes".

Clarify this in the propsel code, log messages, and documentation.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agolibmultipath: add deprecated warning for some features settings
Martin Wilck [Thu, 22 Jun 2017 14:59:10 +0000 (16:59 +0200)]
libmultipath: add deprecated warning for some features settings

The device-mapper features "queue_if_no_path" and
"retain_attached_hw_handler" should be set via the configuration
keywords "no_path_retry" and "retain_attached_hw_handler",
respectively, not via "features".
Print a warning if these "features" settings are encountered.

So far these "features" settings will only be ignored if the
respective other keyword is set, so in particular
'features "1 queue_if_no_path"' will still work as expected, but
cause the warning to be printed.

We should consider ignoring these completely in a future version.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agomultipath.conf.5: Remove ??? and other minor fixes
Martin Wilck [Thu, 22 Jun 2017 14:59:09 +0000 (16:59 +0200)]
multipath.conf.5: Remove ??? and other minor fixes

Remove the FIXME markers by filling in missing content,
and make some other minor fixes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agomultipath.conf.5: document no_path_retry vs. queue_if_no_path
Martin Wilck [Thu, 22 Jun 2017 14:59:08 +0000 (16:59 +0200)]
multipath.conf.5: document no_path_retry vs. queue_if_no_path

Clarify the documentation about option precedence.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agolibmultipath: assemble_map: fix queue_if_no_path logic
Martin Wilck [Thu, 22 Jun 2017 14:59:07 +0000 (16:59 +0200)]
libmultipath: assemble_map: fix queue_if_no_path logic

It is wrong to remove the queue_if_no_path feature if no_path_retry
is unset. Rather, in this case the feature should neither be added
nor removed.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agolibmultipath: merge_hwe: fix queue_if_no_path logic
Martin Wilck [Thu, 22 Jun 2017 14:59:06 +0000 (16:59 +0200)]
libmultipath: merge_hwe: fix queue_if_no_path logic

The logic applied here should match the logic in select_features().
This is achieved by calling reconcile_features_with_options().

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
7 weeks agolibmultipath: clarify option conflicts for "features"
Martin Wilck [Thu, 22 Jun 2017 14:59:05 +0000 (16:59 +0200)]
libmultipath: clarify option conflicts for "features"

The "features" option in multipath.conf can possibly conflict
with "no_path_retry" and "retain_attached_hw_handler".

Currently, "no_path_retry" takes precedence, unless it is set to
"fail", in which case it's overridden by "queue_if_no_path".
This is odd, either "features" or "no_path_retry" should take
precedence.
No precedence rules are defined for "retain_attached_hw_handler".

Make this behavior more consistent by always giving precedence
to the explicit config file options, and improve logging.

Put this logic into a separate function, which can be used
from other places in the code.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agolibmultipath: add/remove_feature: use const char* for feature
Martin Wilck [Thu, 22 Jun 2017 14:59:04 +0000 (16:59 +0200)]
libmultipath: add/remove_feature: use const char* for feature

Change the argument type for the feature to add or remove to
const char*, making it possible to pass const strings without
warnings.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
7 weeks agolibmultipath: load_config: skip setting unnecessary defaults
Martin Wilck [Thu, 22 Jun 2017 14:59:03 +0000 (16:59 +0200)]
libmultipath: load_config: skip setting unnecessary defaults

We have the logic for setting defaults for paths and maps
in propsel.c. By pre-setting conf values with defaults in
load_config(), we generate irritating log messages like
'features = "0" (setting: multipath.conf defaults/devices section)'
if multipath.conf doesn't contain a features setting at all.

For some config settings, we need to use declare_def_snprint_defint()
now to make sure "multipathd show config" prints all defaults correctly.
To avoid confusion, we don't do this for "max_sectors", because
multipathd leaves this untouched by default.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Acked-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
3 months agomultipath-tools: add limits.h to kpartx/lopart.c
Xose Vazquez Perez [Wed, 17 May 2017 23:58:44 +0000 (01:58 +0200)]
multipath-tools: add limits.h to kpartx/lopart.c

musl libc complains of
lopart.c:76:12: error: ‘PATH_MAX’ undeclared (first use in this function)

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>
3 months agomultipath-tools: Replace multipath configuration output
Xose Vazquez Perez [Tue, 18 Apr 2017 00:07:56 +0000 (02:07 +0200)]
multipath-tools: Replace multipath configuration output

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>
3 months agomultipath-tools: enable libdmmp installation in alternative directory
Martin Wilck [Mon, 15 May 2017 20:33:25 +0000 (22:33 +0200)]
multipath-tools: enable libdmmp installation in alternative directory

Introduce a new Makefile variable, usr_prefix, to be used for
libdmmp and the associated pkgconfig file.

Some distributions install those libraries which are  necessary
for booting (and mounting /usr) in a different location (/lib or
/lib64) than other libraries (/usr/lib or /usr/lib64). On such
distributions, installation to the different paths can be achieved
by setting "usr_prefix=/usr". This will affect only libdmmp at this
time, as all other libaries in the multipath-tools package may be
relevant for booting.

For distributions on which /lib and /lib64 are just symlinks to their
/usr counterparts, nothing changes.

Comments are welcome.

Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools: delete vendor name HUASY for Huawei devices
Zou Ming [Sat, 20 May 2017 08:27:02 +0000 (08:27 +0000)]
multipath-tools: delete vendor name HUASY for Huawei devices

For product XSG1,HUASY is obsolete for Huawei devices,Only HUAWEI is the official vendor name.

3 months agomultipath-tools: replace hidden tabs by spaces in .vendor
Xose Vazquez Perez [Sat, 20 May 2017 13:29:52 +0000 (15:29 +0200)]
multipath-tools: replace hidden tabs by spaces in .vendor

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>
3 months agomultipath-tools: fix a format warning in multipathd.8
Xose Vazquez Perez [Fri, 26 May 2017 16:19:20 +0000 (18:19 +0200)]
multipath-tools: fix a format warning in multipathd.8

warning: macro `list' not defined

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>
3 months agompathpersist.8: add missing documentation for -K, -C, -l
Martin Wilck [Mon, 22 May 2017 22:16:43 +0000 (00:16 +0200)]
mpathpersist.8: add missing documentation for -K, -C, -l

Furthermore, add a reference to the sg_persist man page.

3 months agolibmultipath: lazy device-mapper initialization
Martin Wilck [Tue, 6 Jun 2017 19:33:11 +0000 (21:33 +0200)]
libmultipath: lazy device-mapper initialization

The multipath command fails early if libdevmapper and/or the
dm_multipath driver are not found. But some multipath operations
don't require device mapper, notably the path checking operations
called from udev rules during early boot.

This patch delays dm initialization until the first device-mapper
call, allowing such operations to succeed even if the dm_multipath
driver is not loaded yet.

This fixes the following problem: during system boot, the dm_multipath
driver is usually loaded via "ExecStartPre" from the multipathd service
file. But with commit d7188fcd, this service is started only after
udev settle and thus the modules are loaded too late for udev
rule processing, causing "multipath" invocations from udev rules to fail
and paths to be wrongly classified as non-multipath.

Fixes: d7188fcd "multipathd: start daemon after udev trigger"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agolibmpathpersist: use extern struct udev from main program
Martin Wilck [Sun, 26 Mar 2017 13:49:47 +0000 (15:49 +0200)]
libmpathpersist: use extern struct udev from main program

Use the global variable "udev" - the internal one is not
initialized, causing current libudev calls to fail.
In the main program "mpathpersist", use a globally visible
variable "udev" rather than a local variable in main().
This imitates the way the global variable "udev" is used
in multipath and multipathd.

Removed the "udev" parameter from mpath_lib_init() to
clarify that it isn't used.

Fixes: b87454988 "libmultipath: separate out 'udev' config entry"
Signed-off-by: Martin Wilck <mwilck@suse.com>
3 months agomultipath-tools: Prioritizer based on a latency algorithm
Yang Feng [Wed, 21 Jun 2017 09:40:34 +0000 (17:40 +0800)]
multipath-tools: Prioritizer based on a latency algorithm

libmultipath/prioritizers: Prioritizer for device mapper multipath,
where the corresponding priority values of specific paths are provided
by a latency algorithm on the logarithmic scale. And the latency algorithm
is dependent on the following arguments(io_num and base_num).
The principle of the algorithm is illustrated as follows:
1. By sending a certain number "io_num" of read IOs to the current
path continuously, the IOs' average latency can be calculated.
2. Max average latency value is 100s, and min value is 1us. According
to the average latency of each path and the "base_number" of logarithmic
scale, the priority "rc" of each path can be provided.

For example: If base_num=10, the paths will be grouped in priority groups
with path latency <=1us, (1us, 10us], (10us, 100us], (100us, 1ms], (1ms, 10ms],
(10ms, 100ms], (100ms, 1s], (1s, 10s], (10s, 100s], >100s. As follows:

       <=1us            (1us, 10us]      (10us, 100us]               >100s
|------------------|------------------|------------------|...|------------------|
|  priority rank 9 |  priority rank 8 |  priority rank 7 |...|  priority rank 0 |
|------------------|------------------|------------------|...|------------------|
       Priority Rank Partitioning

Signed-off-by: Yang Feng <philip.yang@huawei.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
3 months agomultipath: Fix a potential buffer overflow
Bart Van Assche [Tue, 13 Jun 2017 16:33:39 +0000 (09:33 -0700)]
multipath: Fix a potential buffer overflow

Avoid that gcc 7 reports the following warning:

cli_handlers.c:1340:18: warning: '%d' directive writing between 1 and 3 bytes into a region of size 2 [-Wformat-overflow=]
  sprintf(*reply,"%d",mpp->prflag);

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath/datacore: Remove dead code
Bart Van Assche [Tue, 13 Jun 2017 16:33:38 +0000 (09:33 -0700)]
libmultipath/datacore: Remove dead code

Remove those variables a value is assigned to but that are never
used. This patch avoids that gcc 7 reports the following warning:

datacore.c:98:22: warning: '
   ' directive output may be truncated writing 1 byte into a region of size between 0 and 8 [-Wformat-truncation=]
  snprintf(vendor, 8, "%.8s\n", inqBuffp + 8);

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agolibmultipath: Simplify assemble_map()
Bart Van Assche [Tue, 13 Jun 2017 16:33:37 +0000 (09:33 -0700)]
libmultipath: Simplify assemble_map()

Introduce a macro for appending formatted text to the output buffer.
Eliminate the local variables 'shift' and 'freechar'. Move the
code for freeing a temporary buffer to the end of the function.
Handle snprintf() conversion errors. This patch avoids that gcc 7
reports the following warning:

dmparser.c:137:20: warning: '__builtin_snprintf' output truncated before the last format character [-Wformat-truncation=]
  snprintf(p, 1, "\n");
                    ^

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
3 months agokpartx: Improve portability of set_loop()
Bart Van Assche [Tue, 13 Jun 2017 16:33:36 +0000 (09:33 -0700)]
kpartx: Improve portability of set_loop()

Because macros like __x86_64__ are not defined by the C standard
and because it is easy to convert the int2ptr() macro into
standard C, use (void*)(uintptr_t) instead of int2ptr(). Inline
this macro because it only has one user. This patch does not
change any functionality.

Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>