Revert "Display avg priority as group priority"

This reverts commit 750db1f0dc08bf1d96ce64d32786dfe07b8ae3f9.

Do not compute pathgroup average priority twice on print.
Caught by Mike Christie.
multipath: default fast_io_fail to 5 seconds

This patch sets fast_io_fail to 5 seconds in the defaults section.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: remove default options from built-in

Since changing the path_selector, rr_min_io and rr_min_io_rq options
won't actually break the device configs, there's no reason to set
them equal to the defaults values.  They can just inherit them from
the defaults section.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: change default path_selector to

My testing has showed service-time to be as good and occassionally
noticeably better than round-robin.  So the patch switches the
default selector to give better performance out of the box.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: make devt2devname use lstat to check

dm_reassign wasn't working correctly for me because devt2devname used stat()
to check if /sys/dev/block/major:minor was a symlink.  But stat() never returns
a symlink, if follows it. It needs to use lstat() instead.  Also, I made
multipath log a message when a dm device gets reassigned to use multipath.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: add support for

This adds support for the retain_attached_hw_handler. When this is set to
"yes", if the kernel has already attached a hardware handler to the multipath
path devices, multipath will use that one, instead of its configured one. If
no hardware handler is already attached, multipath use its configured one, if
any.  To properly ignore this on older kernels, I had to makes some changes
to the version checking code.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: remove duplicates from multipath

Added code to remove duplcate entries in the devices section, and the
blacklist devices section of the builtin configuration table. The only
change to setup_default_blist is the addition of _blacklist_device()
to check if the device's bl_product entry already exists.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: add detect_prio option to autodetect

This patch adds a new multipath.conf option, detect_prio.  If set to yes,
multipathd will try to determine the correct prioritizer for the device. If
it finds one, that will be used instead of its configured prioritizer.  If
none is found, the configured prioritizer will be used.  It can currently
only detect ALUA devices.

Also fixed and issue with select_prio where in the devices section, it was
passing in the prio name string instead of the prio args string to prio_get()

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: update netapp config

The netapp config now used the retain_attached_hwhandler and
detect_prio options to automatically configure correctly for both ALUA and
non-ALUA setups. They also requested that dev_loss_tmo be set to
the maximum for netapp devices.

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

Fix set_oom_adj() to work correclty if OOM_ADJUST_MIN isn't
defined.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: rely on udev device creation for kpartx

Since kpartx and multipathd don't wait on udev creating the device, there
was a race between libdevmapper and udev to create the device. This meant
that sometimes the /dev/mapper/ devices were devnodes, and sometimes they
were symlinks. Now, for multipathd and kpartx called without -s,
libdevmapper won't create the device nodes, so that udev will always be
responsible for it.

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

Add some missing options to the documentation.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: make multipathd work with new dm/lvm

multipathd needs to get setup before lvm (lvm2-activation-early.service).
To do this, it needs to get started in sysinit.target like the other
dm services.

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: make reservation_key print out correctly

This patch fixes the reservation_key print functions, so they print
it out like it was in the configuration file.  Also, it keeps
cli_getprstatus() from writing over random memory.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: storagetek 6180 config

New StorageTek default config.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: Fix kpartx and udevd race

Sometimes when kpartx is used to view partition data on disk image files,
udev still has the loop device open when kpartx is trying to tear it down.
This causes the LOOP_CLR_FD ioctl to fail with EBUSY.  kpartx now retries
in this case.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: check for NULL from udev_device_get_*

The udev_device_get_* functions can return NULL, an occassionally do
so in the multipathd code.  multipath needs to check if the result
is NULL before dereferencing it.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: Check blacklists as soon as possible

Multipath does a lot of unnecessary work on devices blacklisted by device
type or wwid before ignoring them.  When dealing with a large number of
devices blacklisted this way, multipath can take long time to complete.
The patch makes sure that multipath is checking the blacklists as soon
as it has the necessary information to do so. To do this, pathinfo() now
takes another flag DI_BLACKLIST, which is only used by store_pathinfo(),
that tells it to check if the device should be blacklisted. Doing this
cleanly also required changing how store_pathinfo() and rlookup_binding()
are called.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath: make path devices readonly again.

Path device fds were changed to be opened read/write when the
mpathpersist code was added. However, I have talked with Vijay, and
this doesn't appear to be necessary for mpathpersist to work correctly.
If the path fds are opened read/write, when the are closed a change
uevent is triggered, which was causing problems during shutdown with
LVM on top of multipath devices. This patch reverts them to being read-only
again.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
explicitly include posix_types.h

to get the correct type for __kernel_old_dev_t

Closes: #558990

Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>