btrfsprogs/0169-btrfs-progs-udev-add-rules-for-dm-devices.patch
David Sterba 036e0e2031 Accepting request 395998 from home:dsterba:branches:filesystems
- update to 4.5.3
- fix build failure on 13.1: conditional default for udevdir
- fix build failure on SLE11SP4: wrong check in makefile

OBS-URL: https://build.opensuse.org/request/show/395998
OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=239
2016-05-16 13:39:09 +00:00

83 lines
3.0 KiB
Diff

From 8bd39e44efa9fdbf221200b3d680b2d8205c89e9 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Fri, 6 May 2016 15:18:32 -0400
Subject: [PATCH v2] btrfs-progs: udev: add rules for dm devices
References: bsc#912170 bsc#888215
Patch-upstream: Submitted to linux-btrfs, 9 May 2016
Systemd's btrfs rule runs btrfs dev ready on each device
as it's discovered. The btrfs command is executed as a builtin
command via an IMPORT{builtin} rule, which means it gets
executed at rule evaluation time, not rule execution time. That
means that the device mapper links haven't been setup yet and the only
nodes that can be depended upon are /dev/dm-#. That we see
/dev/mapper/name names in /proc/mounts is only because we replace the
device name we have cached with the one passed in via mount. If
we have a multi-device file system and the primary device is removed,
the remaining devices will show /dev/dm-#. In addition, if the
udev rule is executed again by someone generating a change event (e.g.
partprobe), the names are also replaced by the /dev/dm-# names.
This patch adds a new rule that adds a run rule that calls btrfs dev
ready again using the device mapper links once they're created.
---
64-btrfs-dm.rules | 10 ++++++++++
Makefile.in | 8 ++++++++
configure.ac | 2 ++
3 files changed, 20 insertions(+)
create mode 100644 64-btrfs-dm.rules
--- /dev/null
+++ b/64-btrfs-dm.rules
@@ -0,0 +1,10 @@
+SUBSYSTEM!="block", GOTO="btrfs_end"
+KERNEL!="dm-[0-9]*", GOTO="btrfs_end"
+ACTION!="add|change", GOTO="btrfs_end"
+ENV{ID_FS_TYPE}!="btrfs", GOTO="btrfs_end"
+
+# Once the device mapper symlink is created, tell btrfs about it
+# so we get the friendly name in /proc/mounts (and tools that read it)
+ENV{DM_NAME}=="?*", RUN{builtin}+="btrfs ready /dev/mapper/$env{DM_NAME}"
+
+LABEL="btrfs_end"
--- a/Makefile.in
+++ b/Makefile.in
@@ -84,11 +84,15 @@ libbtrfs_headers = send-stream.h send-ut
extent_io.h ioctl.h ctree.h btrfsck.h version.h
TESTS = fsck-tests.sh convert-tests.sh
+udev_rules = 64-btrfs-dm.rules
+
prefix ?= @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir ?= @libdir@
incdir = @includedir@/btrfs
+udevdir = @UDEVDIR@
+udevruledir = ${udevdir}/rules.d
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
@@ -390,6 +394,10 @@ install: $(libs) $(progs_install) $(INST
cp -a $(lib_links) $(DESTDIR)$(libdir)
$(INSTALL) -m755 -d $(DESTDIR)$(incdir)
$(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir)
+ifneq ($(udevdir),)
+ $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir)
+ $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
+endif
install-static: $(progs_static) $(INSTALLDIRS)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,8 @@ PKG_STATIC(UUID_LIBS_STATIC, [uuid])
PKG_CHECK_MODULES(ZLIB, [zlib])
PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
+PKG_CHECK_VAR([UDEVDIR], [udev], [udevdir])
+
dnl lzo library does not provide pkg-config, let use classic way
AC_CHECK_LIB([lzo2], [lzo_version], [
LZO2_LIBS="-llzo2"