From 3385b673759832715d5f16d116bbf7e30f2be375 Mon Sep 17 00:00:00 2001 From: xujing Date: Tue, 19 Dec 2023 10:57:35 +0800 Subject: [PATCH] fix /boot unmounted issue when the device is suspended during boot time (cherry picked from commit 919736f2fa4e781e0756ab50709a74f447d43742) --- ...end-of-rules-indeed-when-dm-is-suspe.patch | 48 ++++++++++++++ ...vious-SYSTEMD_READY-state-for-suspen.patch | 66 +++++++++++++++++++ systemd.spec | 7 +- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch create mode 100644 backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.patch diff --git a/backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch b/backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch new file mode 100644 index 0000000..3c8674b --- /dev/null +++ b/backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch @@ -0,0 +1,48 @@ +From c1a2ada89708d6aeeada496712cb24a4a58e75cc Mon Sep 17 00:00:00 2001 +From: janana <40876700+jiayi0118@users.noreply.github.com> +Date: Wed, 29 Nov 2023 11:36:52 +0800 +Subject: [PATCH] rules: go to the end of rules indeed when dm is suspended + +The previous patch 466266c does not make sense indeed, that is to say, if the SYSTEMD_READY is not recorded in the database, the GOTO="systemd_end" will not be applied. + +The IMPORT{db} is actually a matching token, it returns false when there is no SYSTEMD_READY recorded in the database. + +The previous patch 466266c tended to inherit the state of SYSTEMD_READY from the database and skip to the end of current rule file. But when the database does not contain SYSTEMD_READY, e.g., the dm-* is not set db_persistent during initrd and the database will be cleared after switching root, the following rules will still be applied not as expected. +--- + rules.d/99-systemd.rules.in | 4 +++- + test/fuzz/fuzz-udev-rules/99-systemd.rules | 4 +++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/rules.d/99-systemd.rules.in b/rules.d/99-systemd.rules.in +index 9bf02a705f..455a2368eb 100644 +--- a/rules.d/99-systemd.rules.in ++++ b/rules.d/99-systemd.rules.in +@@ -19,7 +19,9 @@ 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", ENV{DM_SUSPENDED}=="1", IMPORT{db}="SYSTEMD_READY" ++SUBSYSTEM=="block", ENV{DM_SUSPENDED}=="1", 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 +diff --git a/test/fuzz/fuzz-udev-rules/99-systemd.rules b/test/fuzz/fuzz-udev-rules/99-systemd.rules +index 278383b02c..5f29d709ae 100644 +--- a/test/fuzz/fuzz-udev-rules/99-systemd.rules ++++ b/test/fuzz/fuzz-udev-rules/99-systemd.rules +@@ -17,7 +17,9 @@ 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", ENV{DM_SUSPENDED}=="1", IMPORT{db}="SYSTEMD_READY" ++SUBSYSTEM=="block", ENV{DM_SUSPENDED}=="1", 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 +-- +2.33.0 + diff --git a/backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.patch b/backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.patch new file mode 100644 index 0000000..2fdf50c --- /dev/null +++ b/backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.patch @@ -0,0 +1,66 @@ +From 466266c1728e3b53b7020e4c0165c3e88576b805 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +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 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 + diff --git a/systemd.spec b/systemd.spec index 3e7a56e..5950d60 100644 --- a/systemd.spec +++ b/systemd.spec @@ -21,7 +21,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 249 -Release: 61 +Release: 62 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -609,6 +609,8 @@ Patch6560: backport-test-shorten-code-a-bit.patch Patch6561: backport-test-add-several-tests-for-track-item.patch Patch6562: backport-sd-bus-switch-to-a-manual-overflow-check-in.patch Patch6563: backport-Use-dummy-allocator-to-make-accesses-defined-as-per-standard.patch +Patch6564: backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.patch +Patch6565: backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch Patch9001: update-rtc-with-system-clock-when-shutdown.patch Patch9002: udev-add-actions-while-rename-netif-failed.patch @@ -2105,6 +2107,9 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null && %{_libdir}/security/pam_systemd.so %changelog +* Thu Dec 21 2023 xujing - 249-62 +- backport: fix /boot unmounted issue when the device is suspended during boot time + * Mon Dec 18 2023 hongjinghao - 249-61 - add: backport-json-use-unsigned-for-refernce-counter.patch backport-macro-check-over-flow-in-reference-counter.patch