Re: [PATCH v2] libmultipath: is_path_valid(): check if device is in use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2022-12-03 at 00:43 +0100, mwilck@xxxxxxxx wrote:
> From: Martin Wilck <mwilck@xxxxxxxx>
> 
> To check whether we will be able to add a given device can be part
> of a multipath map, we have two tests in check_path_valid():
> released_to_systemd() and the O_EXCL test. The former isn't helpful
> if "multipath -u" is called for the first time for a given device,
> and the latter is only used in the "find_multipaths smart" case,
> because
> actively opening the device with O_EXCL, even for a very short time,
> is prone
> to races with other processes.
> 
> It turns out that this may cause issues in some scenarios. We saw
> problems in
> once case where "find_multipaths greedy" was used with a single
> non-multipahted root disk and a very large number of multipath LUNs.
> The root disk would first be classified as multipath device.
> multipathd
> would try to create a map, fail (because the disk was mounted) and
> trigger another uevent. But because of the very large number of
> multipath
> devices, this event was queued up behind thousands of other events,
> and
> the root device timed out eventually.
> 
> While a simple workaround for the given problem would be proper
> blacklisting
> or using a different find_multipaths mode, I am proposing a different
> solution here. An additional test is added in is_path_valid() which
> checks whether the given device is currently in use by 1. sysfs
> holders,
> 2. mounts (from /proc/self/mountinfo) or 3. swaps (from /proc/swaps).
> 2.
> and 3. are similar to systemd's device detection after switching
> root.
> This must not only be done for the device itself, but also for all
> its
> partitions. For mountinfo and swaps, libmount is utilized.
> 
> With this patch, "multipath -u" will make devices with mounted or
> otherwise
> used partitions available to systemd early, without waiting for
> multipathd
> to fail setting up the map and re-triggering an uevent. This should
> avoid
> the issue described above even without blacklisting. The downside of
> it
> is a longer runtime of "multipath -u" for almost all devices, in
> particular
> for real multipath devices. The runtime required for the new checks
> was in the
> order of 0.1ms-1ms in my tests. Moreover, there is a certain risk
> that devices may
> wrongly classified as non-multipath because of transient mounts or
> holders
> created by other processes.
> 
> To make this code compile on older distributions, we need some
> additional
> checks in create-config.mk.
> 
> Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>

Sorry, I forgot:

Changes RFC -> v2:

 - only make the in-use check for "smart" and "greedy" setups (Ben
Marzinski)
 - remove wrong "break" statements (Ben)
 - add another malloc NULL check (Ben)
 - Add compatibility checks for older versions of libmount (me)

Martin  

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux