Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.3:Update
btrfsprogs.24931
0002-btrfs-progs-ignore-devices-representing-pa...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-btrfs-progs-ignore-devices-representing-paths-in-mul.patch of Package btrfsprogs.24931
From bf8274db7ebbfc6fb5c1aa09ba2564efe531199e Mon Sep 17 00:00:00 2001 From: Nikolay Borisov <nborisov@suse.com> Date: Thu, 30 Sep 2021 15:06:33 +0300 Subject: [PATCH 2/3] btrfs-progs: ignore devices representing paths in multipath Currently btrfs-progs will happily enumerate any device which has a btrfs filesystem on it irrespective of its type. For the majority of use cases that's fine and there haven't been any problems with that. However, there was a recent report that in multipath scenario when running "btrfs fi show" after a path flap (path going down and then coming back up) instead of the multipath device being show the device which represents the flapped path is shown. So a multipath filesystem might look like: Label: none uuid: d3c1261f-18be-4015-9fef-6b35759dfdba Total devices 1 FS bytes used 192.00KiB devid 1 size 10.00GiB used 536.00MiB path /dev/mapper/3600140501cc1f49e5364f0093869c763 /dev/mapper/xxx is actually backed by an arbitrary number of paths, which in turn are presented to the system as ordinary SCSI devices i.e /dev/sdX. If a path flaps and a user re-runs 'btrfs fi show' the output would look like: Label: none uuid: d3c1261f-18be-4015-9fef-6b35759dfdba Total devices 1 FS bytes used 192.00KiB devid 1 size 10.00GiB used 536.00MiB path /dev/sdd This only occurs on unmounted filesystems as those are enumerated by btrfs-progs, for mounted filesystem the kernel properly deals only with the actual multipath device. Turns out the output of this command is consumed by libraries and the presence of a path device rather than the actual multipath causes issues. Fix this by checking for the presence of DM_MULTIPATH_DEVICE_PATH udev attribute as multipath path devices are tagged with this attribute by the multipath udev scripts. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> --- utils.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/utils.c b/utils.c index 3a4bc92a66ac..e63ec84df83a 100644 --- a/utils.c +++ b/utils.c @@ -17,6 +17,10 @@ * Boston, MA 021110-1307, USA. */ +#ifdef STATIC_BUILD +#undef HAVE_LIBUDEV +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -26,6 +30,10 @@ #include <sys/stat.h> #include <sys/sysinfo.h> #include <uuid/uuid.h> +#ifdef HAVE_LIBUDEV +#include <sys/stat.h> +#include <libudev.h> +#endif #include <fcntl.h> #include <unistd.h> #include <mntent.h> @@ -1966,6 +1974,42 @@ int group_profile_max_safe_loss(u64 flags) } } +#ifdef HAVE_LIBUDEV +static bool is_path_device(char *device_path) +{ + struct udev *udev = NULL; + struct udev_device *dev = NULL; + struct stat dev_stat; + const char *val; + bool ret = false; + + if (stat(device_path, &dev_stat) < 0) + return false; + + udev = udev_new(); + if (!udev) + goto out; + + dev = udev_device_new_from_devnum(udev, 'b', dev_stat.st_rdev); + if (!dev) + goto out; + + val = udev_device_get_property_value(dev, "DM_MULTIPATH_DEVICE_PATH"); + if (val && atoi(val) > 0) + ret = true; +out: + udev_device_unref(dev); + udev_unref(udev); + + return ret; +} +#else +static bool is_path_device(char *device_path) +{ + return false; +} +#endif + int btrfs_scan_devices(void) { int fd = -1; @@ -1994,6 +2038,9 @@ int btrfs_scan_devices(void) /* if we are here its definitely a btrfs disk*/ strncpy_null(path, blkid_dev_devname(dev)); + if (is_path_device(path)) + continue; + fd = open(path, O_RDONLY); if (fd < 0) { error("cannot open %s: %m", path); -- 2.25.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor