multipath: bind lifetime of udev context to main thread

We have to tie the lifetime of the udev context to the thread
or program. The current approach by creating it on config_load()
will invalidate the context during reconfiguration, thereby
causing all still existent objects to refer to an invalid pointer.
And resulting in a nice crash.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Document 'infinity' as possible value for dev_loss_tmo

infinity is a valid value for dev_loss_tmo, so we should be
documenting it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: return PATH_DOWN for quiesced paths

When a SCSI device is quiesced we cannot send any I/O requests to
it, so we should be returning 'PATH_DOWN' here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
alua: Do not add preferred path priority for active/optimized

When a path is in active/optimized we should disregard the
'preferred path' bit when calculating the priority.
Otherwise we'll end up with having two different priorities
(one for 'active/optimized (preferred)' and one for
'active/optimized (non-preferred)').
Which will result in two different path groups and a
sub-optimal path usage.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: Implement PATH_TIMEOUT

The tur checker might run into a timeout, eg when a command is
sent but the checker hasn't been able to receive a reply in time.
Use a specific 'PATH_TIMEOUT' state for these cases.

Signed-off-by: Hannes Reinecke <hare@suse.de>
kpartx: create correct symlinks for PATH_FAILED events

The kernel is sending out PATH_FAILED/PATH_REINSTATED events,
upon each of which we need to regenerate the existing symlinks.
However, for an all-paths-down scenario we cannot read from
the disk, so we cannot execute blkid or kpartx.
For these cases we need to import the existing data from the
udev database.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipath: Increase dev_loss_tmo prior to fast_io_fail

There are several constraints when setting fast_io_fail and
dev_loss_tmo.
dev_loss_tmo will be capped automatically when fast_io_fail is
not set. And fast_io_fail can not be raised beyond dev_loss_tmo.

So to increase dev_loss_tmo and fast_io_fail we first need
to increase dev_loss_tmo to the given fast_io_fail
setting, then set fast_io_fail, and then set dev_loss_tmo
to the final setting.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipath: Deprecate 'getuid' configuration variable

Older versions of multipath-tools used the 'getuid_callout'
configuration variable to generate the WWID. So for compatibility
we should be accepting existing configurations, but mark the
variable as 'deprecated'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipath: Add 'Datacore Virtual Disk' to internal hardware table

Add 'Datacore Virtual Disk' to internal hardware table.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Check return value from pathinfo()

pathinfo() has a return value, which should be checked to catch
any abnormal behaviour.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Read directly from sysfs when checking the device size

Device sizes might change, so we need to be reading from sysfs
directly to avoid udev still caching the old value.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Minor fixes for priority handling

When no prio handler was selected we should be setting the
priority to 'PRIO_UNDEF'.
Also fixup a typo in the logging message when selecting
the default prioritizer.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Deprecate pg_timeout

pg_timeout has been removed from dm-multipath, so deprecate it
from userspace, too.

Signed-off-by: Hannes Reinecke <hare@suse.de>
kpartx: support disk with non-512B sectors

libdevmapper expects sector size to be recalculated to 512B, so we need
to teach kpartx to do so if the underlying DM device has different
sector size (for GPT and msods partition tables).

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
multipath.conf.5: clarify 'no_path_retry' default setting

The default setting for 'no_path_retry' is 'unset', so we should
be stating this in the man page.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Correctly print out 'max' for max_fds

If the value specified for 'max_fds' is the system-wide limit
we should be printing out 'max', and not that value.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Correctly set max_fds in case of failure

If we fail to get the system limit for max_fds we should assume
a safe value of 4096.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Correctly set pgfailback

Something weird happened to pgfailback; no default was assigned
when loading the configuration, but then it got set (wrongly)
to the default value when printing the configuration.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipath.conf.annotated: Document rr_min_io_rq

rr_min_io_rq wasn't documented in multipath.conf.annotated.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: read path state directly from sysfs

The 'state' attribute of a SCSI device might change without
generating any udev events, so we need to read it directly
from sysfs.

Signed-off-by: Hannes Reinecke <hare@suse.de>