67 lines
3.4 KiB
Diff
67 lines
3.4 KiB
Diff
From 466266c1728e3b53b7020e4c0165c3e88576b805 Mon Sep 17 00:00:00 2001
|
|
From: Michal Sekletar <msekleta@redhat.com>
|
|
Date: Tue, 2 Aug 2022 12:38:30 +0200
|
|
Subject: [PATCH] rules: import previous SYSTEMD_READY state for suspended DM
|
|
devices and skip other rules
|
|
|
|
We can't get any FS meta-data from a suspended device. Hence defer
|
|
making any plugged/unplugged decisions, i.e. we just import whatever was
|
|
previous state and skip processing all other rules.
|
|
|
|
Thanks Lennart Poettering <lennart@poettering.net> for suggesting this
|
|
solution.
|
|
---
|
|
rules.d/99-systemd.rules.in | 6 ++++++
|
|
test/fuzz/fuzz-udev-rules/99-systemd.rules | 6 ++++++
|
|
2 files changed, 12 insertions(+)
|
|
|
|
diff --git a/rules.d/99-systemd.rules.in b/rules.d/99-systemd.rules.in
|
|
index 25b8a590a6..3dbba1f850 100644
|
|
--- a/rules.d/99-systemd.rules.in
|
|
+++ b/rules.d/99-systemd.rules.in
|
|
@@ -15,12 +15,18 @@ KERNEL=="vport*", TAG+="systemd"
|
|
SUBSYSTEM=="ubi", TAG+="systemd"
|
|
|
|
SUBSYSTEM=="block", TAG+="systemd"
|
|
+
|
|
+# We can't make any conclusions about suspended DM devices so let's just import previous SYSTEMD_READY state and skip other rules
|
|
+SUBSYSTEM=="block", ENV{DM_SUSPENDED}=="1", IMPORT{db}="SYSTEMD_READY", GOTO="systemd_end"
|
|
SUBSYSTEM=="block", ACTION=="add", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", ENV{SYSTEMD_READY}="0"
|
|
|
|
# Ignore encrypted devices with no identified superblock on it, since
|
|
# we are probably still calling mke2fs or mkswap on it.
|
|
SUBSYSTEM=="block", ENV{DM_UUID}=="CRYPT-*", ENV{ID_PART_TABLE_TYPE}=="", ENV{ID_FS_USAGE}=="", ENV{SYSTEMD_READY}="0"
|
|
|
|
+# Explicitly set SYSTEMD_READY=1 for DM devices that don't have it set yet, so that we always have something to import above
|
|
+SUBSYSTEM=="block", ENV{DM_UUID}=="?*", ENV{SYSTEMD_READY}=="", ENV{SYSTEMD_READY}="1"
|
|
+
|
|
# add symlink to GPT root disk
|
|
SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="gpt-auto-root"
|
|
SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="gpt-auto-root-luks"
|
|
diff --git a/test/fuzz/fuzz-udev-rules/99-systemd.rules b/test/fuzz/fuzz-udev-rules/99-systemd.rules
|
|
index e8a0f5a739..278383b02c 100644
|
|
--- a/test/fuzz/fuzz-udev-rules/99-systemd.rules
|
|
+++ b/test/fuzz/fuzz-udev-rules/99-systemd.rules
|
|
@@ -15,12 +15,18 @@ KERNEL=="vport*", TAG+="systemd"
|
|
SUBSYSTEM=="ubi", TAG+="systemd"
|
|
|
|
SUBSYSTEM=="block", TAG+="systemd"
|
|
+
|
|
+# We can't make any conclusions about suspended DM devices so let's just import previous SYSTEMD_READY state and skip other rules
|
|
+SUBSYSTEM=="block", ENV{DM_SUSPENDED}=="1", IMPORT{db}="SYSTEMD_READY", GOTO="systemd_end"
|
|
SUBSYSTEM=="block", ACTION=="add", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", ENV{SYSTEMD_READY}="0"
|
|
|
|
# Ignore encrypted devices with no identified superblock on it, since
|
|
# we are probably still calling mke2fs or mkswap on it.
|
|
SUBSYSTEM=="block", ENV{DM_UUID}=="CRYPT-*", ENV{ID_PART_TABLE_TYPE}=="", ENV{ID_FS_USAGE}=="", ENV{SYSTEMD_READY}="0"
|
|
|
|
+# Explicitly set SYSTEMD_READY=1 for DM devices that don't have it set yet, so that we always have something to import above
|
|
+SUBSYSTEM=="block", ENV{DM_UUID}=="?*", ENV{SYSTEMD_READY}=="", ENV{SYSTEMD_READY}="1"
|
|
+
|
|
# add symlink to GPT root disk
|
|
SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="gpt-auto-root"
|
|
SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="gpt-auto-root-luks"
|
|
--
|
|
2.33.0
|
|
|