multipath-tools/.git
3 years agolibmpathpersist: Fix possible overrun in devt2devname()
Hannes Reinecke [Wed, 15 Jun 2016 08:52:53 +0000 (10:52 +0200)]
libmpathpersist: Fix possible overrun in devt2devname()

pp->dev is of size FILE_NAME_SIZE, not PATH_SIZE.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmpathcmd: limit size of the CLI buffer
Hannes Reinecke [Wed, 15 Jun 2016 14:49:54 +0000 (16:49 +0200)]
libmpathcmd: limit size of the CLI buffer

A malicious program might inject a large buffer via the CLI and
causing the daemon to abort due to OOM.
So limit the maximum CLI buffer size to 64k.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: memory leak in iet.c
Hannes Reinecke [Wed, 15 Jun 2016 09:18:18 +0000 (11:18 +0200)]
libmultipath: memory leak in iet.c

'pmatch' was never freed.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: fixup possible buffer overflow in alua_rtpg.c
Hannes Reinecke [Thu, 16 Jun 2016 07:03:36 +0000 (09:03 +0200)]
libmultipath: fixup possible buffer overflow in alua_rtpg.c

We need to reserve an additional 4 bytes for the length of
the response buffer, so add a proper range check to avoid
accidental wrap-arounds.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: use fstat() when reading sysfs attributes
Hannes Reinecke [Thu, 16 Jun 2016 05:49:24 +0000 (07:49 +0200)]
libmultipath: use fstat() when reading sysfs attributes

Coverity pointed out that we shouldn't be using stat()/open(),
as the file might have vanished or changed in between those
two calls. So modify it to open()/fstat() instead.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: drop unused variable 'diop' in libsg.c
Hannes Reinecke [Wed, 15 Jun 2016 12:20:01 +0000 (14:20 +0200)]
libmultipath: drop unused variable 'diop' in libsg.c

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath/discovery.c: handle errors from sscanf()
Hannes Reinecke [Wed, 15 Jun 2016 12:07:11 +0000 (14:07 +0200)]
libmultipath/discovery.c: handle errors from sscanf()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath/uevent.c: handle errors from setsockopt()
Hannes Reinecke [Wed, 15 Jun 2016 12:05:39 +0000 (14:05 +0200)]
libmultipath/uevent.c: handle errors from setsockopt()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath/devmapper.c: check for errors from sscanf()
Hannes Reinecke [Wed, 15 Jun 2016 12:01:28 +0000 (14:01 +0200)]
libmultipath/devmapper.c: check for errors from sscanf()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath/alias.c: check return value from strchr()
Hannes Reinecke [Wed, 15 Jun 2016 11:32:17 +0000 (13:32 +0200)]
libmultipath/alias.c: check return value from strchr()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath/devmapper.c: Remove unused 'next' argument
Hannes Reinecke [Wed, 15 Jun 2016 11:18:40 +0000 (13:18 +0200)]
libmultipath/devmapper.c: Remove unused 'next' argument

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: remove stale references to fd_ep in uevent_listen()
Hannes Reinecke [Wed, 15 Jun 2016 10:57:12 +0000 (12:57 +0200)]
libmultipath: remove stale references to fd_ep in uevent_listen()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: missing NULL check in set_pgfailback()
Hannes Reinecke [Wed, 15 Jun 2016 10:55:44 +0000 (12:55 +0200)]
libmultipath: missing NULL check in set_pgfailback()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: memory leak in add_map_without_path()
Hannes Reinecke [Wed, 15 Jun 2016 09:32:21 +0000 (11:32 +0200)]
libmultipath: memory leak in add_map_without_path()

If we call add_map_without_path() with an empty alias the
mpp structure is never freed.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: memory leak in remove_feature()
Hannes Reinecke [Wed, 15 Jun 2016 09:29:12 +0000 (11:29 +0200)]
libmultipath: memory leak in remove_feature()

Upon error the 'n' string was never freed.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: free pathgroup in group_by_prio()
Hannes Reinecke [Wed, 15 Jun 2016 09:22:28 +0000 (11:22 +0200)]
libmultipath: free pathgroup in group_by_prio()

If we encounter an error when storing the pathgroup or paths
the pathgroup is never deallocated.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: fixup uninitialized return value in dm_reassign_table()
Hannes Reinecke [Wed, 15 Jun 2016 09:01:18 +0000 (11:01 +0200)]
libmultipath: fixup uninitialized return value in dm_reassign_table()

Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: fixup string copy and comparison
Hannes Reinecke [Thu, 16 Jun 2016 08:38:04 +0000 (10:38 +0200)]
libmultipath: fixup string copy and comparison

When doing a strncpy or strncmp we need to omit the trailing
NULL in the length to avoid any possible overflow.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: correctly free refwwid in cli_add_map()
Hannes Reinecke [Wed, 15 Jun 2016 08:37:07 +0000 (10:37 +0200)]
multipathd: correctly free refwwid in cli_add_map()

We need to free the refwwid only when present.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipath-tools: remove useless init scripts
Xose Vazquez Perez [Fri, 3 Jun 2016 23:54:38 +0000 (01:54 +0200)]
multipath-tools: remove useless init scripts

Nobody uses them, relics.

Cc: Ritesh Raj Sarraf <rrs@debian.org>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
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 years agomultipath-tools: tarballs from gitweb
Xose Vazquez Perez [Fri, 3 Jun 2016 23:54:37 +0000 (01:54 +0200)]
multipath-tools: tarballs from gitweb

Releases can be got also from gitweb, more convenient
for untrained people or w/o a development environment.

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 years agomultipath: validate devmap names
Benjamin Marzinski [Tue, 31 May 2016 23:16:48 +0000 (18:16 -0500)]
multipath: validate devmap names

Any device identifier given to multipath that isn't either a block
device or a major:minor id is assumed to be a multipath alias. This can
cause some confusing messages if the user accidentally enters something
that is clearly a pathname, but isn't a block device. Since multipath
device aliases are not allowed to have a "/" in them, multipath now
checks the identifier for this before assuming that is is a device
alias, and if there is a "/", it errors out with a helpful message.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 years agolibmultipath: remove calls to dm_udev_complete
Benjamin Marzinski [Tue, 31 May 2016 23:16:45 +0000 (18:16 -0500)]
libmultipath: remove calls to dm_udev_complete

There were two places where the code was calling dm_udev_complete, when
dm_task_set_cookie() failed and when a subsequent call dm_task_run()
failed.  It is correct in neither of these cases.  If
dm_task_set_cookie() fails, device mapper will zero out the cookie
before returning, so there is nothing to complete. If it succeeds and
there is a cookie, something has to wait on it, or it will hang around
in the system forever. dm_udev_complete() will not wait on the cookie or
clean it up. Its job is to signal to the waiters that they are done
waiting.  This is called for us when dm_task_run() fails, so calling
dm_udev_wait() then will not block but immediately clean up the cookie.

This patch simply removes all of the dm_udev_complete() calls.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 years agokpartx: fix dos partition rollover error
Benjamin Marzinski [Tue, 31 May 2016 23:16:50 +0000 (18:16 -0500)]
kpartx: fix dos partition rollover error

dos partitions are limited to 2^32 sectors. However these do not have to
be 512 byte sectors, which is what device-mapper tables use.  kpartx
stores the dos sectors in a 32 uint.  This means that on a 4k sector size
device with large enough partitions, when kpartx multiplies the
dos sector count by the sector size multiplier, it can rollover before
it gets stored in 64 bit slice sector count. This patch just changes the
multiplier to a 64 bit uint to match the slice sector count, and avoid
the rollover.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 years agolibmultipath: add Huawei Storage default config
Benjamin Marzinski [Tue, 31 May 2016 23:16:49 +0000 (18:16 -0500)]
libmultipath: add Huawei Storage default config

Add a default device config for the Huawei XSG1 arrary. This config
comes from Huawei.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 years agomultipathd: handler fixes
Benjamin Marzinski [Tue, 31 May 2016 23:16:44 +0000 (18:16 -0500)]
multipathd: handler fixes

We now have unlocked handlers, but these can't be used to call functions
that will access the pathvec, mpvec, or conf, since these are what the
vecs lock protects. cli_list_config and cli_list_blacklist both need to
access conf, so they can't be unlocked handlers.

Also, if parse_cmd fails to lock the vecs->lock when it calls
pthread_mutex_timedlock, we can't call unlock() on it, because unlocking
a mutex you haven't locked causes undefined behviour. So we need to
only execute the handler if didn't timeout trying to acquire the lock.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 years agolibmpathcmd: Fixup FSF address
Hannes Reinecke [Fri, 3 Jun 2016 06:41:57 +0000 (08:41 +0200)]
libmpathcmd: Fixup FSF address

Our build system complained that the header file still
refers to the old FSF snail mail address.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmpathcmd: Do not install header file as executable
Hannes Reinecke [Fri, 3 Jun 2016 06:40:38 +0000 (08:40 +0200)]
libmpathcmd: Do not install header file as executable

Our build system complained that the mpath_cmd.h header file is
installed as executable.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipath-tools: tarballs are not generated anymore
Xose Vazquez Perez [Thu, 2 Jun 2016 12:47:09 +0000 (14:47 +0200)]
multipath-tools: tarballs are not generated anymore

Add info how to get a specific release from git.

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 years agomultipath-tools: remove FAQ
Xose Vazquez Perez [Wed, 27 Apr 2016 15:14:34 +0000 (17:14 +0200)]
multipath-tools: remove FAQ

It's old and incomplete information, website already
has a more complete FAQ

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 years agomultipath-tools: remove ChangeLog README from kpartx dir
Xose Vazquez Perez [Wed, 27 Apr 2016 15:14:33 +0000 (17:14 +0200)]
multipath-tools: remove ChangeLog README from kpartx dir

Right now this information is irrelevant.

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 years agomultipath-tools: fix mistyped kpartx in README
Xose Vazquez Perez [Wed, 27 Apr 2016 15:14:32 +0000 (17:14 +0200)]
multipath-tools: fix mistyped kpartx in README

replace kpartxrtx with kpartx

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 years agomultipath-tools: move AUTHOR to README
Xose Vazquez Perez [Wed, 27 Apr 2016 15:14:31 +0000 (17:14 +0200)]
multipath-tools: move AUTHOR to README

move AUTHOR content to README and delete it

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 years agoadd display of map information in JSON format
Todd Gill [Tue, 24 May 2016 18:03:07 +0000 (14:03 -0400)]
add display of map information in JSON format

The changes add these commands:

multipathd show maps json
multipathd show map $map json

Each command will output the requested map(s) in JSON.

For the "show maps json" command, the change pre-allocates
INITIAL_REPLY_LEN * PRINT_JSON_MULTIPLIER(5) * map count.
The JSON text is about 5x the size of the "show maps topology"
text.  Multiplying by the map count helps decrease the number
of realloc calls.

Signed-off-by: Todd Gill <tgill@redhat.com>
Signed-off-by: Gris Ge <fge@redhat.com>
3 years agoRemove more unused files
Christophe Varoqui [Wed, 1 Jun 2016 14:51:52 +0000 (16:51 +0200)]
Remove more unused files

- suse example sysv init script
- rpm specfile template

3 years agoFix build failure on multiple arches
Ritesh Raj Sarraf [Wed, 1 Jun 2016 13:54:33 +0000 (19:24 +0530)]
Fix build failure on multiple arches

The build seems to be failing on common 32 bit architectures, where
"unsigned long" and "uint64_t" tend to produce a different values.
This anomaly is not seen on the common 64bit architectures.

Build failure
===============

cc -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -static-libgcc -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -g -pipe -Wformat-security -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wunused -Wstrict-prototypes -fPIC -DLIB_STRING=\"/lib\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathpersist -I../libmpathcmd -c -o cli.o cli.c
cli.c:112:1: error: conflicting types for 'set_unlocked_handler_callback'
 set_unlocked_handler_callback (unsigned long fp,int (*fn)(void *, char **, int *, void *))
 ^
In file included from cli.c:16:0:
cli.h:110:5: note: previous declaration of 'set_unlocked_handler_callback' was here
 int set_unlocked_handler_callback (uint64_t fp, int (*fn)(void *, char **, int *, void *));
     ^
../Makefile.inc:74: recipe for target 'cli.o' failed
make[2]: *** [cli.o] Error 1
make[2]: Leaving directory '/«PKGBUILDDIR»/multipathd'
Makefile:42: recipe for target 'recurse' failed
make[1]: *** [recurse] Error 2
make[1]: Leaving directory '/«PKGBUILDDIR»'
debian/rules:45: recipe for target 'build-multipath-udeb-stamp' failed
make: *** [build-multipath-udeb-stamp] Error 2
dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2
────────────────────────────────────────────────────────────────────────────────
Build finished at 20160531-1405

Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
3 years agoMerge Dell MD3XXX hardware table entries
Hannes Reinecke [Mon, 30 Mar 2015 06:23:23 +0000 (08:23 +0200)]
Merge Dell MD3XXX hardware table entries

Remove duplicate entries and merge MD36xxi/MD36xxf into a single
one.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoIncrease kpartx retries
Ritesh Raj Sarraf [Wed, 11 May 2016 17:27:10 +0000 (19:27 +0200)]
Increase kpartx retries

3 years agolibmultipath: use poll() in uevent_listen()
Hannes Reinecke [Wed, 11 May 2016 10:35:53 +0000 (12:35 +0200)]
libmultipath: use poll() in uevent_listen()

As we're not modifying the signal mask anymore we can switch
back to normal 'poll' instead of 'ppoll'.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: move 'filter_devnode' under vector lock
Hannes Reinecke [Wed, 11 May 2016 10:35:41 +0000 (12:35 +0200)]
multipathd: move 'filter_devnode' under vector lock

Ben Marzinski pointed out that filter_devnode() is used
without any lock or configuration settings in uev_trigger(),
and hence might be invalid when processing events during
reconfiguration.
So move it into the individual functions and handle it
with the vector lock held.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agoBump the version code to 0.6.1 0.6.1
Christophe Varoqui [Tue, 10 May 2016 06:12:35 +0000 (08:12 +0200)]
Bump the version code to 0.6.1

3 years agoDrop the multipath.conf.* files
Christophe Varoqui [Tue, 10 May 2016 06:02:19 +0000 (08:02 +0200)]
Drop the multipath.conf.* files

multipath.conf.synthetic is useless.

multipath.conf.defaults can be extracted from a live daemon.

multipath.conf.annotated information is all in the man page.

3 years agolibmultipath: Fixup 'DM_DEVICE_RELOAD' handling
Hannes Reinecke [Mon, 9 May 2016 10:53:05 +0000 (12:53 +0200)]
libmultipath: Fixup 'DM_DEVICE_RELOAD' handling

libdevmapper has the 'quirk' that DM_DEVICE_CREATE is translated
internally into a create/load/resume sequence, and the associated
cookie will wait for the last 'resume' to complete.
However, DM_DEVICE_RELOAD has no such translation, so if there
is a cookie assigned to it the caller _cannot_ wait for it,
as the cookie will only ever be completed upon the next
DM_DEVICE_RESUME.
multipathd already has some provisions for that (but even there
the cookie handling is dodgy), but 'multipath -r' doesn't know
about this.
So to avoid any future irritations this patch updates the
dm_addmad_reload() call to handle the call to DM_DEVICE_RESUME
correctly and removes the special handling from domap().

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agodevmapper: remove 'udev_sync' argument from dm_simplecmd_noflush()
Hannes Reinecke [Mon, 9 May 2016 10:53:04 +0000 (12:53 +0200)]
devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush()

The 'udev_sync' argument is always '1', so we can remove it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: wait for udev in cli_resume()
Hannes Reinecke [Mon, 9 May 2016 10:53:03 +0000 (12:53 +0200)]
multipathd: wait for udev in cli_resume()

When calling 'cli_resume()' we should be waiting for udev to
ensure the device really has been resumed.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agodevmapper: wait for udev in dm_simplecmd_noflush()
Hannes Reinecke [Mon, 9 May 2016 10:53:02 +0000 (12:53 +0200)]
devmapper: wait for udev in dm_simplecmd_noflush()

When calling dm_simplecmd_noflush() with udev_flags set we
need to set the 'need_sync' flag otherwise the udev flags
will never be set.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agoconfigure: Rename ACT_RENAME2 to ACT_FORCERENAME
Hannes Reinecke [Mon, 9 May 2016 10:53:01 +0000 (12:53 +0200)]
configure: Rename ACT_RENAME2 to ACT_FORCERENAME

Use a more descriptive name instead of 'ACT_RENAME2'.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agodevmapper: do not call dm_udev_complete if dm_task_set_cookie() failed
Hannes Reinecke [Mon, 9 May 2016 10:53:00 +0000 (12:53 +0200)]
devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed

As per Benjamin Marzinski libdevice-mapper will take care of cleaning
up the cookie for us.
So there's no need to call dm_udev_complete() if dm_task_set_cookie()
fails.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agodevmapper: do not flush I/O for DM_DEVICE_CREATE
Hannes Reinecke [Mon, 9 May 2016 10:52:59 +0000 (12:52 +0200)]
devmapper: do not flush I/O for DM_DEVICE_CREATE

DM_DEVICE_CREATE loads a new table, so there cannot be any
I/O pending. Hence we should be setting the 'no flush'
and 'skip lockfs' flag to avoid delays during creation.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoRevert 'multipathd: Do not print misleading message "not found in pathvec"'
Hannes Reinecke [Tue, 3 May 2016 09:18:53 +0000 (11:18 +0200)]
Revert 'multipathd: Do not print misleading message "not found in pathvec"'

As discussed on the mailing list the logging messages should remain,
so revert the patch, increase the logging level and update the
message itself to be more instructive.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agoAllow specific CLI commands to run unlocked
Hannes Reinecke [Thu, 24 Jul 2014 12:03:56 +0000 (14:03 +0200)]
Allow specific CLI commands to run unlocked

When multipath is busy with checking paths or processing udev
events it'll take the vector lock, causing the CLI
to become unresponsive.
This patch allows certain CLI commands to not wait for the vector
lock, so that those commands will always succeed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: push down lock in checkerloop()
Hannes Reinecke [Thu, 24 Jul 2014 09:52:26 +0000 (11:52 +0200)]
multipathd: push down lock in checkerloop()

Instead of grabbing the lock at the start of the checkerloop
and releasing it at the end we should be holding it only
during the time when we actually need it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: asynchronous configuration
Hannes Reinecke [Thu, 21 Aug 2014 09:10:23 +0000 (11:10 +0200)]
multipathd: asynchronous configuration

For initial configuration multipathd waits until it has synchronized
with the existing setup. On larger systems this takes up quite
some time (I've measured 80 seconds on a system with 1024 paths)
causing systemd to stall and the system to fail booting.
This patch makes the initial configuration asynchronous, and
using the same codepath as the existing 'reconfigure' CLI
command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: Increase uxclnt timeout
Hannes Reinecke [Fri, 15 Apr 2016 08:45:01 +0000 (10:45 +0200)]
multipathd: Increase uxclnt timeout

When calling uxclnt we need to increase the timeout, otherwise
we will not be able to get a reply if the daemon runs into an
uxlsnr timeout.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: implement 'show map $map format $fmt'
Hannes Reinecke [Mon, 8 Jun 2015 13:59:33 +0000 (15:59 +0200)]
multipathd: implement 'show map $map format $fmt'

Similar to the existing 'show map $map topology', but allowing
formatted content.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: make 'dm_addmap' static
Hannes Reinecke [Tue, 30 Jun 2015 11:55:31 +0000 (13:55 +0200)]
libmultipath: make 'dm_addmap' static

dm_addmap() is only used within devmapper.c, so it can be made
static.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: Provide standard error description on cli failure
Hannes Reinecke [Thu, 18 Dec 2014 10:52:57 +0000 (11:52 +0100)]
multipathd: Provide standard error description on cli failure

When the cli command fails we should be returning the error
in addition to the standard help text.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: strict loop timings
Hannes Reinecke [Mon, 8 Jun 2015 10:47:07 +0000 (12:47 +0200)]
multipathd: strict loop timings

This patch implements a new configuration value 'strict_timing',
which causes each path checker loop to start at exactly one second
after the last one. Longer path checker loops will be properly
accounted, so that each path is guaranteed to be checked within
'polling_interval' seconds.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agodmparser: Use find_path_by_dev()
Hannes Reinecke [Thu, 24 Mar 2016 07:36:10 +0000 (08:36 +0100)]
dmparser: Use find_path_by_dev()

There are two functions for looking up paths, find_path_by_dev() and
find_path_by_devt(). To avoid any inconsistencies we should be
using find_path_by_dev() here and allocate a path with both values.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: sanity check on store_path()
Hannes Reinecke [Mon, 11 Apr 2016 09:22:30 +0000 (11:22 +0200)]
libmultipath: sanity check on store_path()

If a path has neither pp->dev nor pp->dev_t set we cannot
identify the path at all.
So reject any path where this is not the case.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: ensure 'dev_t' is set when store paths
Hannes Reinecke [Wed, 17 Feb 2016 10:03:08 +0000 (11:03 +0100)]
libmultipath: ensure 'dev_t' is set when store paths

We need both, 'pp->dev' and 'pp->dev_t' for correct lookup to
work. So ensure dev_t is always being updated when storing a new path.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: remove 'get_info' argument for adopt_paths()
Hannes Reinecke [Wed, 17 Feb 2016 09:55:36 +0000 (10:55 +0100)]
libmultipath: remove 'get_info' argument for adopt_paths()

The 'get_info' argument was always set to '1', so we can drop it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: Do not switch paths on empty multipath tables
Hannes Reinecke [Mon, 25 Jan 2016 07:36:07 +0000 (08:36 +0100)]
multipathd: Do not switch paths on empty multipath tables

If all paths are removed from a multipath table there is no
point in trying to switch path groups as we don't have any.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: set uxsock_timeout after reconfiguration
Hannes Reinecke [Thu, 14 Apr 2016 07:39:18 +0000 (09:39 +0200)]
multipathd: set uxsock_timeout after reconfiguration

We should be setting the global variable 'uxsock_timeout' after
reconfiguration, not from within the uxsock_listen() function.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agoUse multipath wwid if path wwid is empty
Hannes Reinecke [Wed, 9 Apr 2014 10:01:02 +0000 (12:01 +0200)]
Use multipath wwid if path wwid is empty

During booting udev might not be fully initialized, causing
it to not return any information for a path.
The multipath map, however, would still be present.
In these cases we should use the multipath map as the
path wwid to avoid spurious path failures during boot.
The situation will be corrected anyway as udev will
be sending out the 'real' events very soon after.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: accept zero-size paths in ev_add_path()
Hannes Reinecke [Fri, 19 Jun 2015 13:35:02 +0000 (15:35 +0200)]
multipathd: accept zero-size paths in ev_add_path()

Paths in ALUA 'standby' state are not required to support
READ CAPACITY, and hence might report a size of '0'. However,
they are valid devices and should be added to the existing
topology.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoAlways set DM_UDEV_DISABLE_LIBRARY_FALLBACK
Hannes Reinecke [Fri, 5 Jun 2015 08:38:13 +0000 (10:38 +0200)]
Always set DM_UDEV_DISABLE_LIBRARY_FALLBACK

The 'DM_UDEV_DISABLE_LIBRARY_FALLBACK' should be set always,
as with modern installations udev is responsible for maintaining
the '/dev/mapper' directory.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: remove 'use_uuid' argument from dm_addmap()
Hannes Reinecke [Tue, 30 Jun 2015 11:58:16 +0000 (13:58 +0200)]
libmultipath: remove 'use_uuid' argument from dm_addmap()

'use_uuid' was only ever set for DM_DEVICE_CREATE, so we
can check the task and remove the 'use_uuid' argument.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: remove 'needsync' argument from dm_simplecmd_noflush
Hannes Reinecke [Wed, 13 Apr 2016 09:28:36 +0000 (11:28 +0200)]
libmultipath: remove 'needsync' argument from dm_simplecmd_noflush

Argument is always '1'.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: improve uxlsnr
Hannes Reinecke [Wed, 13 Apr 2016 07:05:30 +0000 (09:05 +0200)]
multipathd: improve uxlsnr

Improve uxlsnr by adding a lock around the poll structure and
not reallocating memory for every poll, thereby significantly
speedup processing.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agomultipathd: skip uninitialized devices during reconfiguration
Hannes Reinecke [Thu, 18 Dec 2014 10:02:08 +0000 (11:02 +0100)]
multipathd: skip uninitialized devices during reconfiguration

libudev has a separate filter setting to skip uninitialized
devices during enumeration.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoOnly filter for udev property if uid_attribute is present
Hannes Reinecke [Tue, 22 Jul 2014 09:37:25 +0000 (11:37 +0200)]
Only filter for udev property if uid_attribute is present

It only makes sense to filter for an existing udev property if the
'uid_attribute' variable is set. Otherwise multipath did not
get the uid from udev and so we might not even have udev information.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: use a shared lock to co-operate with udev
Hannes Reinecke [Tue, 24 Jun 2014 06:49:15 +0000 (08:49 +0200)]
libmultipath: use a shared lock to co-operate with udev

udev since v214 is placing a shared lock on the device node
whenever it's processing the event. This introduces a race
condition with multipathd, as multipathd is processing the
event for the block device at the same time as udev is
processing the events for the partitions.
And a lock on the partitions will also be visible on the
block device itself, hence multipathd won't be able to
lock the device.
When multipath manages to take a lock on the device,
udev will fail, and consequently ignore this entire event.
Which in turn might cause the system to malfunction as it
might have been a crucial event like 'remove' or 'link down'.

So we should better use LOCK_SH here; with that the flock
call in multipathd _and_ udev will succeed and the events
can be processed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoEnsure multipathd is started before systemd-udev-trigger.service
Hannes Reinecke [Wed, 8 Apr 2015 08:59:36 +0000 (10:59 +0200)]
Ensure multipathd is started before systemd-udev-trigger.service

We should be starting multipathd before systemd-udev-trigger
is started to reduce the load on udev during startup.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years ago11-dm-mpath.rules: Only import ID_FS_XXX variables if not set
Hannes Reinecke [Wed, 25 Mar 2015 08:47:40 +0000 (09:47 +0100)]
11-dm-mpath.rules: Only import ID_FS_XXX variables if not set

We should only import ID_FS_XXX variables if they are not set,
otherwise we might be overwriting existing results.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoLoad all device handler modules on startup
Hannes Reinecke [Tue, 17 Mar 2015 13:24:18 +0000 (14:24 +0100)]
Load all device handler modules on startup

Upon multipathd startup the device handler modules are not
necessarily loaded, so we need to load them prior to startup.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoAdd dependency on systemd-udevd.service
Hannes Reinecke [Wed, 18 Mar 2015 10:21:37 +0000 (11:21 +0100)]
Add dependency on systemd-udevd.service

During startup libdevmapper checks if udev is running or not.
And if it finds udev is _not_ running it'll create the device-nodes
internally, regardless on any magic ioctl flags.
This results in the occasionally message 'conflicting device node found'
in the syslog.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipath: move the warning 'failed to get wwid' to lvl4 verbosity
Christophe Varoqui [Tue, 3 May 2016 06:38:41 +0000 (08:38 +0200)]
multipath: move the warning 'failed to get wwid' to lvl4 verbosity

3 years agolibmultipath: avoid double semicolon in lock.h
Hannes Reinecke [Wed, 13 Apr 2016 07:58:29 +0000 (09:58 +0200)]
libmultipath: avoid double semicolon in lock.h

The definitions for lock() already have a semicolon, resulting
in a double semicolon when using the definitions like a normal
statement.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: Do not print misleading message 'not found in pathvec'
Hannes Reinecke [Mon, 14 Dec 2015 10:25:03 +0000 (11:25 +0100)]
multipathd: Do not print misleading message 'not found in pathvec'

When looking up a path in the existing configuration it is perfectly
possible for the path not to be present.
This should not generate a message as it might be errorneously
interpreted as an error.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmpathpersist: Fixup whitespaces in Makefile
Hannes Reinecke [Thu, 14 Apr 2016 12:29:25 +0000 (14:29 +0200)]
libmpathpersist: Fixup whitespaces in Makefile

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: additional logging messages when formatting callout
Hannes Reinecke [Thu, 14 Apr 2016 10:29:32 +0000 (12:29 +0200)]
libmultipath: additional logging messages when formatting callout

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: call get_uid() for all paths
Hannes Reinecke [Mon, 9 Nov 2015 15:44:49 +0000 (16:44 +0100)]
libmultipath: call get_uid() for all paths

When we're reading the device UID off uevents we don't have to
check the path state as we're not actually doing I/O.
So pass in the path_state to get_uid() and evaluate it only
if ->getuid is selected.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: correctly display checker status
Hannes Reinecke [Mon, 3 Aug 2015 09:46:25 +0000 (11:46 +0200)]
libmultipath: correctly display checker status

The '%d chk' message should only be used if there are active paths,
otherwise the path checker most certainly haven't been run.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: correctly initialize pp->sg_id
Hannes Reinecke [Wed, 11 Nov 2015 12:38:57 +0000 (13:38 +0100)]
libmultipath: correctly initialize pp->sg_id

The default SCSI protocol is 'SCSI_PROTOCOL_UNSPEC';
'0' is SCSI_PROTOCOL_FCP.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: print error message for invalid arguments
Hannes Reinecke [Thu, 22 Oct 2015 10:06:16 +0000 (12:06 +0200)]
multipathd: print error message for invalid arguments

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: fixup a crash when invoking CLI commands
Hannes Reinecke [Wed, 15 Jul 2015 12:47:45 +0000 (14:47 +0200)]
multipathd: fixup a crash when invoking CLI commands

The command buffer wasn't cleared, so the CLI might crash on startup.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipathd: fixup queueing mode in 'show maps status'
Hannes Reinecke [Mon, 8 Jun 2015 07:35:22 +0000 (09:35 +0200)]
multipathd: fixup queueing mode in 'show maps status'

When manually disabling queueing via 'disablequeueing map $map'
the queueing status in 'show maps status' is not updated.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolibmultipath: finally fix dev_loss_tmo setting
Hannes Reinecke [Wed, 13 Apr 2016 12:29:06 +0000 (14:29 +0200)]
libmultipath: finally fix dev_loss_tmo setting

We need to take the current value when comparing
'dev_loss_tmo' and 'fast_io_fail', otherwise we still
might be getting an error as we might comparing wrong
values.

Signed-off-by: Hannes Reinecke <hare@suse.com>
3 years agolibmultipath: Do not use 'sscanf' for parsing integers
Hannes Reinecke [Wed, 19 Nov 2014 09:20:39 +0000 (10:20 +0100)]
libmultipath: Do not use 'sscanf' for parsing integers

'sscanf' doesn't really have a way of signalling errors,
so strtoul(l) should be used instead.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoAllow for empty SCSI revision
Hannes Reinecke [Mon, 11 Aug 2014 06:35:55 +0000 (08:35 +0200)]
Allow for empty SCSI revision

Some (broken) SCSI devices return an empty SCSI revision, but
this doesn't indicate a broken device. So allow for an empty
revision string when discover devices.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoAdd LIO-ORG/SUSE RBD backend hardware defaults
Hannes Reinecke [Tue, 1 Dec 2015 08:12:05 +0000 (09:12 +0100)]
Add LIO-ORG/SUSE RBD backend hardware defaults

The LIO-ORG RBD backend always supports ALUA, and should be assigned
the correct values for multipathing.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoAdd HP MSA 2040 to the hardware table
Hannes Reinecke [Mon, 2 Mar 2015 11:18:23 +0000 (12:18 +0100)]
Add HP MSA 2040 to the hardware table

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agokpartx: Install rules file with correct prefix
Hannes Reinecke [Fri, 14 Feb 2014 11:25:21 +0000 (12:25 +0100)]
kpartx: Install rules file with correct prefix

We don't need to swizzle names in the spec file, the Makefile
should be doing it on itself.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agokpartx: parse emulated DASD devices
Hannes Reinecke [Wed, 20 May 2015 10:02:13 +0000 (12:02 +0200)]
kpartx: parse emulated DASD devices

Emulated DASD devices do not support the DASDINFO ioctl, so we
need to generate the information by hand. After all, fdasd
does the same.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agokpartx: handle more than 256 loop devices
Hannes Reinecke [Mon, 27 Oct 2014 09:37:41 +0000 (10:37 +0100)]
kpartx: handle more than 256 loop devices

Update the loop handling code to support more than 256
devices.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agokpartx: Fixup persistent name generation
Hannes Reinecke [Wed, 23 Jul 2014 07:41:11 +0000 (09:41 +0200)]
kpartx: Fixup persistent name generation

kpartx_id would overwrite the 'DM_NAME' variable, which were
causing things to break later on. Seeing that kpartx_id is
only ever used to generate persistent device names I've updated
kpartx_id and kpartx.rules to rely on existing variables where
possible, avoiding any accidental overwrite of existing variables.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agomultipath-tools: update docs hannes
Xose Vazquez Perez [Tue, 19 Apr 2016 15:35:06 +0000 (17:35 +0200)]
multipath-tools: update docs

removes TODO, adds meaningful information to README
and replaces dead urls in ChangeLog.

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 years agomultipath: fix memory leak and segfault in reconfigure
Germano Percossi [Thu, 11 Feb 2016 19:30:54 +0000 (19:30 +0000)]
multipath: fix memory leak and segfault in reconfigure

Within the reconfigure function, the global pointer conf is
stored in a local variable and then assigned NULL.
If load_config should fail, for any reason, we end up with
a memory leak, as soon as we leave the function, and with
the global pointer conf set to NULL, leading to a segfault
as soon as it is dereferenced.

I tested it by calling a reconfigure and making the first
allocation in load_config fail but any failure in load_config
would do.
From a user perspective the CLI reports "fail".

If something like this should happen there are at least 2 possible
scenarios:

1) If a second immediate reconfigure succeeds, the conf now is fine but
   the leak stays
2) If the previous point does not happen, any command trying to access
   "conf" would fail. On my test box a "show conf" segfaulted.

The fix is simple but in case of failure at least the previous
conf is kept in memory without leaks or segfaluts

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
3 years agoUpdate version to 0.6.0 0.6.0
Christophe Varoqui [Mon, 18 Apr 2016 09:32:43 +0000 (11:32 +0200)]
Update version to 0.6.0