fix an issue for the symlink of the by-uuid file lost

Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
(cherry picked from commit 5c525c8c8b365d69f07ef0885cd072dfd2834f18)
This commit is contained in:
wangzhiqiang 2023-11-14 20:52:57 +08:00 committed by openeuler-sync-bot
parent 164ddc2f8f
commit 83d624abd9
3 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,43 @@
From 0ffad44e2b768a09be410b7d0decceb6404c46d1 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Fri, 28 Jan 2022 14:42:29 +0100
Subject: [PATCH 1/2] udev: create symlinks and watch even in suspended state
If a dm device is suspended, we can't run blkid on it. But earlier
rules (e.g. 11-dm-parts.rules) might have imported previously scanned
properties from the udev db, in particular if the device had been correctly
set up beforehand (DM_UDEV_PRIMARY_SOURCE_FLAG==1). Symlinks for existing
ID_FS_xyz properties must be preserved in this case. Otherwise lower-priority
devices (such as multipath components) might take over the symlink
temporarily.
Likewise, we should't stop watching a temporarily suspended, but previously
correctly configured dm device.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
udev/13-dm-disk.rules.in | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
index fcb2f37..18254b4 100644
--- a/udev/13-dm-disk.rules.in
+++ b/udev/13-dm-disk.rules.in
@@ -17,10 +17,14 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
ENV{DM_NAME}=="?*", SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
+ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link"
+ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link"
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
(BLKID_RULE)
+
+LABEL="dm_link"
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
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}"
--
2.33.0

View File

@ -0,0 +1,55 @@
From 05176a06cf24cd9be00bd98c76466398841008b9 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Thu, 2 Feb 2023 00:28:12 +0900
Subject: [PATCH 2/2] udev: import previous results of blkid when in suspended
state
Follow-up for e10f67e91728f1e576803df884049ecbd92874d0.
The commit e10f67e91728f1e576803df884049ecbd92874d0 tries to keep device
node symlinks even if the device is in the suspended state. However,
necessary properties that may previously obtained by the blkid command
were not imported at least in the .rules file. So, unless ID_FS_xyz
properties are imported by another earlier .rules file, the device node
symlinks are still lost when event is processed in the suspended state.
Let's explicitly import the necessary properties.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2158628
GHPR: https://github.com/lvmteam/lvm2/pull/105
---
udev/13-dm-disk.rules.in | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
index 18254b4..0ca0d57 100644
--- a/udev/13-dm-disk.rules.in
+++ b/udev/13-dm-disk.rules.in
@@ -17,12 +17,22 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
ENV{DM_NAME}=="?*", SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
-ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link"
-ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link"
+ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_import"
+ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_import"
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
(BLKID_RULE)
+GOTO="dm_link"
+
+LABEL="dm_import"
+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"
+IMPORT{db}="ID_PART_GPT_AUTO_ROOT"
LABEL="dm_link"
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
--
2.33.0

View File

@ -43,7 +43,7 @@
Name: lvm2
Version: 2.03.09
Release: 13
Release: 14
Epoch: 8
Summary: Tools for logical volume management
License: GPLv2+ and LGPLv2.1 and BSD
@ -71,6 +71,8 @@ Patch19: 0019-devices-simplify-md-superblock-checking-code.patch
Patch20: 0020-gcc-calc-size-in-compile-time.patch
Patch21: 0021-fix-check-for-md-raid-imsm-signature-on-4k-devices.patch
Patch22: 0022-clang-remove-unused-assignment.patch
Patch23: 0023-udev-create-symlinks-and-watch-even-in-suspended-sta.patch
Patch24: 0024-udev-import-previous-results-of-blkid-when-in-suspen.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -496,6 +498,9 @@ fi
%changelog
* Tue Nov 14 2023 wangzhiqiang <wangzhiqiang95@huawei.com> - 8:2.03.09-14
- fix an issue for the symlink of the by-uuid file lost
* Sat Oct 29 2022 Xiaole He <hexiaole@kylinos.cn> - 8:2.03.09-13
- backport patches:18-22 for supporting intel vroc raid(virtual raid on cpu)