[multipathd] Declaration of envp variable in child function is missing
Add multipath path format wildcard

This adds a new format wildcard, 'm', to be used with

multipathd show paths format

It prints the multipath device associated with the path.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Fix multipath rename from user_friendly_name to wwid

When multipath was selecting an alias for a device on reload, if it
didn't have an explicit alias, and user_friendly_names wasn't set,
multipath would use the existing alias, if one existed.  This made it
impossible to turn off user_friendly_names, and then reconfigure to
change the device names back to wwids.

Instead, multipath should just use the wwid as an alias, if that's
what it's configured to do, regardless of the existing name.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Turn off user_friendly_names for netapp devices

Netapp has requested that even if user friendly names is enabled in the
defaults section, they would like it disabled for their devices.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Don't detect prioritizers that don't work

The current method used by detect_prio was selecting the ALUA
prioritizer for devices that didn't have ALUA enabled.  This patch
makes detect_prio go through all the steps to get a priority with the
ALUA prioritizer.  If it is able to successfully get a priority, then
it selects the ALUA proritizer for the device.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Only load a multipath device RO if RW load fails with EROFS

If a transient error keeps multipath from being able to reload a
multipath device read/write, it will retry the reload with the
device set to read-only.  This can suddenly turn a read/write
multipath device read-only.  If device-mapper cannot load the
device read/write because a path device can't be opened for writing,
it will return EROFS.  This is the only time it makes sense to
reload the device read-only.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
signal waiter thread to stop waiting on dm events

The ioctl syscall is not a pthread cancellation point. So, when
device-mapper is waiting on events, pthread_cancel won't cancel
the waiter thread.  This patch makes the waiter threads handle
SIGUSR2, and has stop_waiter_thread() signal it to break out of
waiting on dm events. Unfortunately, there is still a possibility
of the signal arriving before the ioctl, and the waiter thread
still hanging until the devices are reloaded.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
fix mutipath -W on empty wwids file

When multipath tries to open the wwids file and finds it empty or
missing, it writes the header to the file.  When it tried to wipe
the wwids from an empty or missing file, it didn't seek back to the
start of the file after truncating it.  This caused the the wwids
file to have a patch of zeroed bytes at the start. This patch fixes
this by always seeking back to the start of the file before rewriting
the header.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath: try to deal with bindings file hand editting

Unfortunately, instead of adding aliases to /etc/multipath.conf like they
should, some users add aliases to the bindings file. If they add aliases
that look like user_friendly_names, like mpathfoo, they interfere with
the code to find the next available user_friendly_name (giving you
mpathfop as the next user_friendly_name in this case).  This patch
will fix this by giving the next name available name after an unbroken
string of names starting with the smallest possible name. It order to keep
the choice quick, it won't handle situation where the list of names
starting at the smallest possible is not in order.  There are a number
of ways to do a better job finding the smallest possible name, but this
will fix most of the cases I've seen, without slowing things down at all.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
kpartx: Make kpartx able to create read-only loop devices

This just passes the read-only value into set_loop, and falls back
to read-only mapping on EACCESS to handle immutable files.

Signed-off-by: Till Maas <opensource@till.name>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath: show default configurations

"multipathd show config" should show the current configuration, even if
the current values match the default values.  Omitting the values when
they match the compiled in defaults just makes it harder for users to
see how multipath configured.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipathd: Don't touch the multipath device after setup_multipath fails

If setup_multipath fails, it removes the device. multipath always needs
to check its return value and not touch the device if setup_multipath
failed.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
kpartx: fix strict aliasing warning

Compiling with strict aliasing throws warnings about aliasing
volume_label_t to an array of unsigned ints. Adding __may_alias__
lets it know that we meant to do this.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath: blacklist blktap devices

Multipath can't run on top of blktap devices, so it should just ignore them.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipathd: allow /dev/<devnode> to be used for multipathd commands

Multipathd expects that path and map names used in its interactive
commands are sysfs names with no directory.  However, users often try
used /dev names instead.  This patch makes multipathd convert the /dev
names to sysfs names like the multipath command does.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
kpartx: autoload loop module on loop partition creation

Currently kpartx doesn't do anything to force the loop module to
autoload, so creating partitions over files fails if the loop module
isn't already loaded.  This patch makes kpartx try to find the next
available loop device by ioctling /dev/loop-control, which will
autoload kpartx.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>