File 1003-udev-don-t-create-by-partlabel-primary-and-.-logical.patch of Package systemd.34275

From bdc187b0ea65bd0a2436d6db0a78e0151fb87289 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Mon, 16 Apr 2018 23:03:27 +0200
Subject: [PATCH 1003/1016] udev: don't create by-partlabel/primary and
 .../logical symlinks

These links are created by libstorage / parted by default.  They are ambiguous
and may be present hundred- or thousandfold on large systems. They are
meaningless for device identification and may slow down udev processing. They
aren't used anywhere.  Don't create them.

A service has been added to detect at boot cases that likely need to be fixed:
a warning is thrown at both the console and syslog to encourage sysadmin to
consult the relevant TID explaining how to permanently fix the issue.

[fbui: added the detection part]
[fbui: fixes bsc#1089761]
---
 rules.d/60-persistent-storage.rules.in     |  2 +-
 units/detect-part-label-duplicates.service | 16 ++++++++++++++++
 units/meson.build                          |  4 ++++
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 units/detect-part-label-duplicates.service

diff --git a/rules.d/60-persistent-storage.rules.in b/rules.d/60-persistent-storage.rules.in
index d5e0f5f705..345b27a025 100644
--- a/rules.d/60-persistent-storage.rules.in
+++ b/rules.d/60-persistent-storage.rules.in
@@ -154,7 +154,7 @@ ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTE
 
 # by-partlabel/by-partuuid links (partition metadata)
 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}"
+ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", ENV{ID_PART_ENTRY_NAME}!="primary|logical", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
 
 # by-diskseq link (if an app is told to open a path like this, they may parse
 # the diskseq number from the path, then issue BLKGETDISKSEQ to verify they really got
diff --git a/units/detect-part-label-duplicates.service b/units/detect-part-label-duplicates.service
new file mode 100644
index 0000000000..11a187c763
--- /dev/null
+++ b/units/detect-part-label-duplicates.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Detect if the system suffers from bsc#1089761
+ConditionDirectoryNotEmpty=/run/udev/data
+
+[Service]
+RemainAfterExit=true
+StandardOutput=journal+console
+SyslogLevel=warning
+ExecStart=/bin/sh -c " \
+    if [ $(grep -r "E:ID_PART_ENTRY_NAME=primary" /run/udev/data | wc -l) -ge 100 ]; then \
+      echo 'Warning: a high number of partitions uses \"primary\" or \"logical\" as'; \
+      echo 'partition label name, which may cause slow-down in the boot process.'; \
+      echo 'To prevent it, a workaround is temporarly in place but we recommend to'; \
+      echo 'refer to TID #7023057 in order to permanently fix this issue (as the'; \
+      echo 'workaround will be dropped in the future).'; \
+    fi"
diff --git a/units/meson.build b/units/meson.build
index dc7966a772..6a5182cc3a 100644
--- a/units/meson.build
+++ b/units/meson.build
@@ -19,6 +19,10 @@ units = [
           'symlinks' : ['sysinit.target.wants/'],
         },
         { 'file' : 'debug-shell.service.in' },
+        {
+          'file' : 'detect-part-label-duplicates.service',
+          'symlinks' : ['sysinit.target.wants/'],
+        },
         {
           'file' : 'dev-hugepages.mount',
           'symlinks' : ['sysinit.target.wants/'],
-- 
2.35.3

openSUSE Build Service is sponsored by