From: Martin Wilck <mwilck@suse.com>
To: Benjamin Marzinski <bmarzins@redhat.com>,
Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com
Subject: [PATCH v2 31/31] kpartx.rules: move symlink code to other files
Date: Thu, 14 Sep 2017 22:00:10 +0200 [thread overview]
Message-ID: <20170914200010.19129-2-mwilck@suse.com> (raw)
In-Reply-To: <20170914200010.19129-1-mwilck@suse.com>
Current kpartx.rules combines two purposes: setting properties and
creating symlinks for dm partition devices, and creating such
partition devices on top of other devices. This is contrary to
common conventions for udev rules files.
This patch moves the code for properties and symlinks into other
files. The code that generates symlinks for multipath maps is moved
to 11-dm-mpath.rules, and for partitions we introduce a new file
11-dm-parts.rules. Necessarily this results in minor code duplication.
OTOH quite some code is removed because the properties are now set
before 13-dm-disk.rules runs, so we can rely on the latter to create
the symlinks.
The reason I put this last in the series is that it will possibly
require changes in other packages, notably dracut, in order to make
sure partitions mappings are cleanly set up during boot.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
kpartx/Makefile | 2 ++
kpartx/dm-parts.rules | 39 +++++++++++++++++++++++++++++++++++++++
kpartx/kpartx.rules | 44 --------------------------------------------
multipath/11-dm-mpath.rules | 22 +++++++++++++++++++++-
4 files changed, 62 insertions(+), 45 deletions(-)
create mode 100644 kpartx/dm-parts.rules
diff --git a/kpartx/Makefile b/kpartx/Makefile
index da1e1fbddce5..bf7362d95efd 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -29,6 +29,7 @@ install: $(EXEC) $(EXEC).8
$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)
$(INSTALL_PROGRAM) -m 755 kpartx_id $(DESTDIR)$(libudevdir)
$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)/rules.d
+ $(INSTALL_PROGRAM) -m 644 dm-parts.rules $(DESTDIR)$(libudevdir)/rules.d/11-dm-parts.rules
$(INSTALL_PROGRAM) -m 644 kpartx.rules $(DESTDIR)$(libudevdir)/rules.d/66-kpartx.rules
$(INSTALL_PROGRAM) -m 644 del-part-nodes.rules $(DESTDIR)$(libudevdir)/rules.d/68-del-part-nodes.rules
$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
@@ -38,6 +39,7 @@ uninstall:
$(RM) $(DESTDIR)$(bindir)/$(EXEC)
$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz
$(RM) $(DESTDIR)$(libudevdir)/kpartx_id
+ $(RM) $(DESTDIR)$(libudevdir)/rules.d/11-dm-parts.rules
$(RM) $(DESTDIR)$(libudevdir)/rules.d/66-kpartx.rules
$(RM) $(DESTDIR)$(libudevdir)/rules.d/67-kpartx-compat.rules
$(RM) $(DESTDIR)$(libudevdir)/rules.d/68-del-part-nodes.rules
diff --git a/kpartx/dm-parts.rules b/kpartx/dm-parts.rules
new file mode 100644
index 000000000000..235642fd9ae3
--- /dev/null
+++ b/kpartx/dm-parts.rules
@@ -0,0 +1,39 @@
+# Rules for partitions created by kpartx
+
+KERNEL!="dm-*", GOTO="dm_parts_end"
+ACTION!="add|change", GOTO="dm_parts_end"
+ENV{DM_UUID}!="part[0-9]*", GOTO="dm_parts_end"
+
+# We must take care that symlinks don't get lost,
+# even if blkid fails in 13-dm-disk.rules later.
+#
+# Fixme: we have currently no way to avoid calling blkid on
+# partitions of broken mpath maps such as DM_NOSCAN.
+# But when partition devices appear, kpartx has likely read
+# the partition table shortly before, so odds are not bad
+# that blkid will also succeed.
+
+IMPORT{db}="ID_FS_USAGE"
+IMPORT{db}="ID_FS_UUID_ENC"
+IMPORT{db}="ID_FS_LABEL_ENC"
+IMPORT{db}="ID_PART_ENTRY_NAME"
+IMPORT{db}="ID_PART_ENTRY_UUID"
+IMPORT{db}="ID_PART_ENTRY_SCHEME"
+
+# Maps should take precedence over their members.
+ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
+
+# Set some additional symlinks that typically exist for mpath
+# path members, too, and should be overridden.
+#
+# kpartx_id is very robust, it works for suspended maps and maps
+# with 0 dependencies. It sets DM_TYPE, DM_PART, DM_WWN
+IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
+
+# DM_TYPE only has a reasonable value for partitions on multipath.
+ENV{DM_UUID}=="*-mpath-*", ENV{DM_TYPE}=="?*" \
+ SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
+ENV{DM_WWN}=="?*", ENV{DM_PART}=="?*", \
+ SYMLINK+="disk/by-id/wwn-$env{DM_WWN}-part$env{DM_PART}"
+
+LABEL="dm_parts_end"
diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules
index 1cbe94298081..8f9904945f6a 100644
--- a/kpartx/kpartx.rules
+++ b/kpartx/kpartx.rules
@@ -8,50 +8,6 @@ KERNEL!="dm-*", GOTO="kpartx_end"
ACTION!="add|change", GOTO="kpartx_end"
ENV{DM_UUID}!="?*", GOTO="kpartx_end"
-# kpartx_id is very robust, it works for suspended maps and maps
-# with 0 dependencies
-IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
-
-ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
-
-ENV{DM_UUID}=="*mpath-*", ENV{DM_TYPE}=="?*" \
- SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
-
-# Create persistent links for multipath tables
-ENV{DM_WWN}=="?*", ENV{DM_PART}!="?*", \
- SYMLINK+="disk/by-id/wwn-$env{DM_WWN}"
-
-# Create persistent links for partitions
-ENV{DM_WWN}=="?*", ENV{DM_PART}=="?*", \
- SYMLINK+="disk/by-id/wwn-$env{DM_WWN}-part$env{DM_PART}"
-
-# Create persistent by-label/by-uuid links.
-# multipath maps with DM_NOSCAN!=1 are handled in 13-dm-disk.rules.
-DM_UUID=="mpath-*", ENV{DM_NOSCAN}!="1", GOTO="symlink_end"
-
-# For partitions, we don't have DM_NOSCAN.
-# Simply load variables from db if they aren't set.
-# 11-dm-mpath.rules does this for mpath maps.
-# Fixme: we have currently no way to avoid calling blkid on
-# partitions of broken mpath maps.
-ENV{DM_UUID}!="part*-*-*", GOTO="import_end"
-ENV{ID_FS_USAGE}!="?*", IMPORT{db}="ID_FS_USAGE"
-ENV{ID_FS_UUID_ENC}!="?*", IMPORT{db}="ID_FS_UUID_ENC"
-ENV{ID_FS_LABEL_ENC}!="?*", IMPORT{db}="ID_FS_LABEL_ENC"
-ENV{ID_PART_ENTRY_NAME}!="?*", IMPORT{db}="ID_PART_ENTRY_NAME"
-ENV{ID_PART_ENTRY_UUID}!="?*", IMPORT{db}="ID_PART_ENTRY_UUID"
-ENV{ID_PART_ENTRY_SCHEME}!="?*", IMPORT{db}="ID_PART_ENTRY_SCHEME"
-LABEL="import_end"
-
-ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", \
- SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
-ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", \
- SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
-ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
-ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", \
- SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
-LABEL="symlink_end"
-
# Create dm tables for partitions on multipath devices.
ENV{DM_UUID}!="mpath-?*", GOTO="mpath_kpartx_end"
diff --git a/multipath/11-dm-mpath.rules b/multipath/11-dm-mpath.rules
index 4a3f646d264d..132a92345cdc 100644
--- a/multipath/11-dm-mpath.rules
+++ b/multipath/11-dm-mpath.rules
@@ -80,8 +80,12 @@ ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\
ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=""
+# The code to check multipath state ends here. We need to set
+# properties and symlinks regardless whether the map is usable or
+# not. If symlinks get lost, systemd may auto-unmount file systems.
+
LABEL="scan_import"
-ENV{DM_NOSCAN}!="1", GOTO="mpath_end"
+ENV{DM_NOSCAN}!="1", GOTO="import_end"
IMPORT{db}="ID_FS_TYPE"
IMPORT{db}="ID_FS_USAGE"
IMPORT{db}="ID_FS_UUID"
@@ -90,4 +94,20 @@ IMPORT{db}="ID_FS_LABEL"
IMPORT{db}="ID_FS_LABEL_ENC"
IMPORT{db}="ID_FS_VERSION"
+LABEL="import_end"
+
+# Multipath maps should take precedence over their members.
+ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
+
+# Set some additional symlinks that typically exist for mpath
+# path members, too, and should be overridden.
+
+# kpartx_id is very robust, it works for suspended maps and maps
+# with 0 dependencies. It sets DM_TYPE, DM_PART, DM_WWN
+TEST=="/usr/lib/udev/kpartx_id", \
+ IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
+
+ENV{DM_TYPE}=="?*", SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
+ENV{DM_WWN}=="?*", SYMLINK+="disk/by-id/wwn-$env{DM_WWN}"
+
LABEL="mpath_end"
--
2.14.0
prev parent reply other threads:[~2017-09-14 20:00 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-02 22:38 [PATCH 00/31] multipath/kpartx udev rules cleanup, and fixes Martin Wilck
2017-09-02 22:38 ` [PATCH 01/31] libmultipath: fix partition_delimiter config option Martin Wilck
2017-09-02 22:38 ` [PATCH 02/31] kpartx: helper functions for name and uuid generation Martin Wilck
2017-09-02 22:38 ` [PATCH 03/31] kpartx: search partitions by UUID, and rename Martin Wilck
2017-09-02 22:38 ` [PATCH 04/31] test-kpartx: add tests for renaming functionality Martin Wilck
2017-09-02 22:38 ` [PATCH 05/31] kpartx: fix a corner case when renaming partitions Martin Wilck
2017-09-02 22:38 ` [PATCH 06/31] kpartx: fix part deletion without partition table Martin Wilck
2017-09-02 22:38 ` [PATCH 07/31] test-kpartx: test deletion with empty part table Martin Wilck
2017-09-02 22:38 ` [PATCH 08/31] kpartx: only recognize dasd part table on DASD Martin Wilck
2017-09-02 22:38 ` [PATCH 09/31] libmultipath: support MPATH_UDEV_NO_PATHS_FLAG on map creation Martin Wilck
2017-09-13 20:33 ` Benjamin Marzinski
2017-09-14 11:53 ` Martin Wilck
2017-09-02 22:38 ` [PATCH 10/31] libmultipath: add get_udev_device Martin Wilck
2017-09-02 22:38 ` [PATCH 11/31] libmultipath: get_refwwid: use get_udev_device Martin Wilck
2017-09-02 22:38 ` [PATCH 12/31] libmultipath: use const char* in some dm helpers Martin Wilck
2017-09-02 22:38 ` [PATCH 13/31] libmultipath: add DI_NOIO flag for pathinfo Martin Wilck
2017-09-02 22:38 ` [PATCH 14/31] libmultipath: add dm_get_multipath Martin Wilck
2017-09-02 22:38 ` [PATCH 15/31] multipath: implement "check usable paths" (-C/-U) Martin Wilck
2017-09-13 20:53 ` Benjamin Marzinski
2017-09-14 11:47 ` Martin Wilck
2017-09-15 21:06 ` Benjamin Marzinski
2017-09-02 22:38 ` [PATCH 16/31] 11-dm-mpath.rules: multipath -U for READY check Martin Wilck
2017-09-02 22:38 ` [PATCH 17/31] 11-dm-mpath.rules: import more ID_FS_xxx vars from db Martin Wilck
2017-09-02 22:38 ` [PATCH 18/31] 11-dm-mpath.rules: no need to test before IMPORT Martin Wilck
2017-09-02 22:38 ` [PATCH 19/31] 11-dm-mpath.rules: handle new maps with READY==0 Martin Wilck
2017-09-02 22:38 ` [PATCH 20/31] 11-dm-mpath.rules: don't set READY->ACTIVATION Martin Wilck
2017-09-13 21:19 ` Benjamin Marzinski
2017-09-13 21:33 ` Martin Wilck
2017-09-14 12:48 ` Martin Wilck
2017-09-15 20:33 ` Benjamin Marzinski
2017-09-02 22:38 ` [PATCH 21/31] 11-dm-mpath.rules: Remember DM_ACTIVATION Martin Wilck
2017-09-13 21:19 ` Benjamin Marzinski
2017-09-14 13:06 ` Martin Wilck
2017-09-15 20:40 ` Benjamin Marzinski
2017-09-18 19:54 ` Martin Wilck
2017-09-02 22:38 ` [PATCH 22/31] multipath.rules: set ID_FS_TYPE to "mpath_member" Martin Wilck
2017-09-02 22:38 ` [PATCH 23/31] kpartx.rules: don't rely on DM_DEPS and DM_TABLE_STATE Martin Wilck
2017-09-02 22:38 ` [PATCH 24/31] kpartx.rules: respect DM_UDEV_LOW_PRIORITY_FLAG Martin Wilck
2017-09-02 22:38 ` [PATCH 25/31] kpartx.rules: improved logic for by-uuid and by-label links Martin Wilck
2017-09-02 22:38 ` [PATCH 26/31] kpartx.rules: create by-partuuid and by-partlabel symlinks Martin Wilck
2017-09-02 22:38 ` [PATCH 27/31] kpartx.rules: generate type-name links only for multipath devices Martin Wilck
2017-09-02 22:38 ` [PATCH 28/31] kpartx.rules: fix logic for adding partitions Martin Wilck
2017-09-02 22:38 ` [PATCH 29/31] multipath/kpartx rules: avoid superfluous scanning Martin Wilck
2017-09-02 22:38 ` [PATCH 30/31] kpartx/del-part-nodes.rules: new udev file Martin Wilck
2017-09-13 21:23 ` Benjamin Marzinski
2017-09-02 22:39 ` [PATCH 31/31] kpartx.rules: move symlink code to other files Martin Wilck
2017-09-13 21:26 ` Benjamin Marzinski
2017-09-13 21:28 ` [PATCH 00/31] multipath/kpartx udev rules cleanup, and fixes Benjamin Marzinski
2017-09-14 11:56 ` Martin Wilck
2017-09-14 20:00 ` [PATCH v2 30/31] kpartx/del-part-nodes.rules: new udev file Martin Wilck
2017-09-14 20:00 ` Martin Wilck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170914200010.19129-2-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=bmarzins@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox