Compare commits

...

No commits in common. "c8" and "c9-beta" have entirely different histories.
c8 ... c9-beta

143 changed files with 1814 additions and 17939 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/LVM2.2.03.14.tgz
SOURCES/LVM2.2.03.24.tgz

View File

@ -1 +1 @@
e5d4364e823d72b9a08b3aecc13cd677972830f0 SOURCES/LVM2.2.03.14.tgz
7c2dcac585dc89dbd0070216262a3a8446e7f222 SOURCES/LVM2.2.03.24.tgz

78
SOURCES/0001-RHEL9.patch Normal file
View File

@ -0,0 +1,78 @@
From 645992ca32dfd41b07997a97b2aef81563ad6f02 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 16 May 2024 12:12:06 +0200
Subject: [PATCH 1/7] RHEL9
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 4 ++++
WHATS_NEW_DM | 4 ++++
doc/release-notes/2.03.24.mdwn | 8 ++------
5 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/VERSION b/VERSION
index c41928e80..794c58868 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.03.24(2) (2024-05-16)
+2.03.24(2)-RHEL9 (2024-05-16)
diff --git a/VERSION_DM b/VERSION_DM
index 63629f72c..8dea6c328 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.198 (2024-05-16)
+1.02.198-RHEL9 (2024-05-16)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1c5f4b223..c7de3914a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.03.25 -
+==================
+
Version 2.03.24 - 16th May 2024
===============================
Lvconvert supports VDO options for thin-pool with vdo conversion.
@@ -5450,3 +5453,4 @@ Display output. Some metadata information cannot yet be displayed.
Recovery tools to salvage "lost" metadata directly from the disks:
but we hope the new format will mean such tools are hardly ever needed!
+
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index b1508f08f..a2277c53b 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.199 -
+===================
+
Version 1.02.198 - 16th May 2024
================================
Fix static only compilation of libdevmapper.a and dmsetup tool.
@@ -1554,3 +1557,4 @@ Version 1.00.08 - 27 Feb 2004
Updated README/INSTALL to reflect move to sources.redhat.com.
Updated autoconf files to 2003-06-17.
+
diff --git a/doc/release-notes/2.03.24.mdwn b/doc/release-notes/2.03.24.mdwn
index 71aa8add7..4d2c57497 100644
--- a/doc/release-notes/2.03.24.mdwn
+++ b/doc/release-notes/2.03.24.mdwn
@@ -72,9 +72,5 @@ Also few more minor improvements:
"""]]
-<!-- remove the pending tag on release, remove draft tag once editing is complete -->
-[[!tag draft pending]]
-<!--
-For old releases add Release Timestamp like this, date from git show $COMMIT is fine.
-\[[!meta date="Tue Nov 21 14:26:07 2023 +0100"]]
--->
+[[!tag]]
+[[meta date="Thu May 16 12:12:06 2024 +0200"]]
--
2.44.0

View File

@ -1,545 +0,0 @@
From 63c4458aaf67d114c677baf657a7e9e43440f349 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 20 Dec 2021 14:22:02 -0600
Subject: [PATCH 01/54] Revert "new udev autoactivation"
This reverts commit 67722b312390cdab29c076c912e14bd739c5c0f6.
---
scripts/Makefile.in | 1 +
test/shell/udev-pvscan-vgchange.sh | 403 -----------------------------
udev/69-dm-lvm.rules.in | 87 -------
udev/Makefile.in | 2 +-
5 files changed, 4 insertions(+), 492 deletions(-)
delete mode 100644 test/shell/udev-pvscan-vgchange.sh
delete mode 100644 udev/69-dm-lvm.rules.in
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 0d7f45680..ee0acb6f6 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -92,6 +92,7 @@ install_systemd_generators:
install_systemd_units: install_dbus_service
@echo " [INSTALL] systemd_units"
$(Q) $(INSTALL_DIR) $(systemd_unit_dir)
+ $(Q) $(INSTALL_DATA) lvm2-pvscan.service $(systemd_unit_dir)/lvm2-pvscan@.service
ifeq ("@BUILD_DMEVENTD@", "yes")
$(Q) $(INSTALL_DATA) dm_event_systemd_red_hat.socket $(systemd_unit_dir)/dm-event.socket
$(Q) $(INSTALL_DATA) dm_event_systemd_red_hat.service $(systemd_unit_dir)/dm-event.service
diff --git a/test/shell/udev-pvscan-vgchange.sh b/test/shell/udev-pvscan-vgchange.sh
deleted file mode 100644
index c81acf0ce..000000000
--- a/test/shell/udev-pvscan-vgchange.sh
+++ /dev/null
@@ -1,403 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2021 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-test_description='udev rule and systemd unit run vgchange'
-
-SKIP_WITH_LVMPOLLD=1
-SKIP_WITH_LVMLOCKD=1
-
-. lib/inittest
-
-#
-# $ cat /tmp/devs
-# /dev/sdb
-# /dev/sdc
-# /dev/sdd
-#
-# Specify this file as LVM_TEST_DEVICE_LIST=/tmp/devs
-# when running the test.
-#
-# This test will wipe these devices.
-#
-
-if [ -z ${LVM_TEST_DEVICE_LIST+x} ]; then echo "LVM_TEST_DEVICE_LIST is unset" && skip; else echo "LVM_TEST_DEVICE_LIST is set to '$LVM_TEST_DEVICE_LIST'"; fi
-
-test -e "$LVM_TEST_DEVICE_LIST" || skip
-
-num_devs=$(cat $LVM_TEST_DEVICE_LIST | wc -l)
-
-RUNDIR="/run"
-test -d "$RUNDIR" || RUNDIR="/var/run"
-PVS_ONLINE_DIR="$RUNDIR/lvm/pvs_online"
-VGS_ONLINE_DIR="$RUNDIR/lvm/vgs_online"
-PVS_LOOKUP_DIR="$RUNDIR/lvm/pvs_lookup"
-
-_clear_online_files() {
- # wait till udev is finished
- aux udev_wait
- rm -f "$PVS_ONLINE_DIR"/*
- rm -f "$VGS_ONLINE_DIR"/*
- rm -f "$PVS_LOOKUP_DIR"/*
-}
-
-test -d "$PVS_ONLINE_DIR" || mkdir -p "$PVS_ONLINE_DIR"
-test -d "$VGS_ONLINE_DIR" || mkdir -p "$VGS_ONLINE_DIR"
-test -d "$PVS_LOOKUP_DIR" || mkdir -p "$PVS_LOOKUP_DIR"
-_clear_online_files
-
-aux prepare_real_devs
-
-aux lvmconf 'devices/dir = "/dev"'
-aux lvmconf 'devices/use_devicesfile = 1'
-DFDIR="$LVM_SYSTEM_DIR/devices"
-DF="$DFDIR/system.devices"
-mkdir $DFDIR || true
-not ls $DF
-
-get_real_devs
-
-wipe_all() {
- for dev in "${REAL_DEVICES[@]}"; do
- wipefs -a $dev
- done
-}
-
-# udevadm trigger runs udev rule which runs systemd-run --no-wait vgchange -aay
-# Because of --no-wait, we need to wait for the transient systemd
-# service to be gone before checking the effects of the vgchange.
-
-wait_lvm_activate() {
- local vgw=$1
- local wait=0
-
- while systemctl status lvm-activate-$vgw > /dev/null && test "$wait" -le 30; do
- sleep .2
- wait=$(( wait + 1 ))
- done
-}
-
-# Test requires 3 devs
-test $num_devs -gt 2 || skip
-BDEV1=$(basename "$dev1")
-BDEV2=$(basename "$dev2")
-BDEV3=$(basename "$dev3")
-
-wipe_all
-touch $DF
-for dev in "${REAL_DEVICES[@]}"; do
- pvcreate $dev
-done
-
-# 1 dev, 1 vg, 1 lv
-
-vgcreate $vg1 "$dev1"
-lvcreate -l1 -an -n $lv1 $vg1 "$dev1"
-
-PVID1=$(pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}')
-
-_clear_online_files
-udevadm trigger --settle -c add /sys/block/$BDEV1
-
-wait_lvm_activate $vg1
-
-ls "$RUNDIR/lvm/pvs_online/$PVID1"
-ls "$RUNDIR/lvm/vgs_online/$vg1"
-journalctl -u lvm-activate-$vg1 | tee out || true
-grep "now active" out
-check lv_field $vg1/$lv1 lv_active "active"
-
-vgchange -an $vg1
-vgremove -y $vg1
-
-
-# 2 devs, 1 vg, 2 lvs
-
-vgcreate $vg2 "$dev1" "$dev2"
-lvcreate -l1 -an -n $lv1 $vg2 "$dev1"
-lvcreate -l1 -an -n $lv2 $vg2 "$dev2"
-
-PVID1=$(pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}')
-PVID2=$(pvs "$dev2" --noheading -o uuid | tr -d - | awk '{print $1}')
-
-_clear_online_files
-
-udevadm trigger --settle -c add /sys/block/$BDEV1
-ls "$RUNDIR/lvm/pvs_online/$PVID1"
-not ls "$RUNDIR/lvm/vgs_online/$vg2"
-journalctl -u lvm-activate-$vg2 | tee out || true
-not grep "now active" out
-check lv_field $vg2/$lv1 lv_active ""
-check lv_field $vg2/$lv2 lv_active ""
-
-udevadm trigger --settle -c add /sys/block/$BDEV2
-ls "$RUNDIR/lvm/pvs_online/$PVID2"
-ls "$RUNDIR/lvm/vgs_online/$vg2"
-
-wait_lvm_activate $vg2
-
-journalctl -u lvm-activate-$vg2 | tee out || true
-grep "now active" out
-check lv_field $vg2/$lv1 lv_active "active"
-check lv_field $vg2/$lv2 lv_active "active"
-
-vgchange -an $vg2
-vgremove -y $vg2
-
-
-# 3 devs, 1 vg, 4 lvs, concurrent pvscans
-# (attempting to have the pvscans run concurrently and race
-# to activate the VG)
-
-vgcreate $vg3 "$dev1" "$dev2" "$dev3"
-lvcreate -l1 -an -n $lv1 $vg3 "$dev1"
-lvcreate -l1 -an -n $lv2 $vg3 "$dev2"
-lvcreate -l1 -an -n $lv3 $vg3 "$dev3"
-lvcreate -l8 -an -n $lv4 -i 2 $vg3 "$dev1" "$dev2"
-
-PVID1=$(pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}')
-PVID2=$(pvs "$dev2" --noheading -o uuid | tr -d - | awk '{print $1}')
-PVID3=$(pvs "$dev3" --noheading -o uuid | tr -d - | awk '{print $1}')
-
-_clear_online_files
-
-udevadm trigger -c add /sys/block/$BDEV1 &
-udevadm trigger -c add /sys/block/$BDEV2 &
-udevadm trigger -c add /sys/block/$BDEV3
-
-aux udev_wait
-wait_lvm_activate $vg3
-
-ls "$RUNDIR/lvm/pvs_online/$PVID1"
-ls "$RUNDIR/lvm/pvs_online/$PVID2"
-ls "$RUNDIR/lvm/pvs_online/$PVID3"
-ls "$RUNDIR/lvm/vgs_online/$vg3"
-journalctl -u lvm-activate-$vg3 | tee out || true
-grep "now active" out
-check lv_field $vg3/$lv1 lv_active "active"
-check lv_field $vg3/$lv2 lv_active "active"
-check lv_field $vg3/$lv3 lv_active "active"
-check lv_field $vg3/$lv4 lv_active "active"
-
-vgchange -an $vg3
-vgremove -y $vg3
-
-
-# 3 devs, 1 vg, 4 lvs, concurrent pvscans, metadata on only 1 PV
-
-wipe_all
-rm $DF
-touch $DF
-pvcreate --metadatacopies 0 "$dev1"
-pvcreate --metadatacopies 0 "$dev2"
-pvcreate "$dev3"
-
-vgcreate $vg4 "$dev1" "$dev2" "$dev3"
-lvcreate -l1 -an -n $lv1 $vg4 "$dev1"
-lvcreate -l1 -an -n $lv2 $vg4 "$dev2"
-lvcreate -l1 -an -n $lv3 $vg4 "$dev3"
-lvcreate -l8 -an -n $lv4 -i 2 $vg4 "$dev1" "$dev2"
-
-PVID1=$(pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}')
-PVID2=$(pvs "$dev2" --noheading -o uuid | tr -d - | awk '{print $1}')
-PVID3=$(pvs "$dev3" --noheading -o uuid | tr -d - | awk '{print $1}')
-
-_clear_online_files
-
-udevadm trigger -c add /sys/block/$BDEV1 &
-udevadm trigger -c add /sys/block/$BDEV2 &
-udevadm trigger -c add /sys/block/$BDEV3
-
-aux udev_wait
-wait_lvm_activate $vg4
-
-ls "$RUNDIR/lvm/pvs_online/$PVID1"
-ls "$RUNDIR/lvm/pvs_online/$PVID2"
-ls "$RUNDIR/lvm/pvs_online/$PVID3"
-ls "$RUNDIR/lvm/vgs_online/$vg4"
-journalctl -u lvm-activate-$vg4 | tee out || true
-grep "now active" out
-check lv_field $vg4/$lv1 lv_active "active"
-check lv_field $vg4/$lv2 lv_active "active"
-check lv_field $vg4/$lv3 lv_active "active"
-check lv_field $vg4/$lv4 lv_active "active"
-
-vgchange -an $vg4
-vgremove -y $vg4
-
-
-# 3 devs, 3 vgs, 2 lvs in each vg, concurrent pvscans
-
-wipe_all
-rm $DF
-touch $DF
-
-vgcreate $vg5 "$dev1"
-vgcreate $vg6 "$dev2"
-vgcreate $vg7 "$dev3"
-lvcreate -l1 -an -n $lv1 $vg5
-lvcreate -l1 -an -n $lv2 $vg5
-lvcreate -l1 -an -n $lv1 $vg6
-lvcreate -l1 -an -n $lv2 $vg6
-lvcreate -l1 -an -n $lv1 $vg7
-lvcreate -l1 -an -n $lv2 $vg7
-
-_clear_online_files
-
-udevadm trigger -c add /sys/block/$BDEV1 &
-udevadm trigger -c add /sys/block/$BDEV2 &
-udevadm trigger -c add /sys/block/$BDEV3
-
-aux udev_wait
-wait_lvm_activate $vg5
-wait_lvm_activate $vg6
-wait_lvm_activate $vg7
-
-ls "$RUNDIR/lvm/vgs_online/$vg5"
-ls "$RUNDIR/lvm/vgs_online/$vg6"
-ls "$RUNDIR/lvm/vgs_online/$vg7"
-journalctl -u lvm-activate-$vg5 | tee out || true
-grep "now active" out
-journalctl -u lvm-activate-$vg6 | tee out || true
-grep "now active" out
-journalctl -u lvm-activate-$vg7 | tee out || true
-grep "now active" out
-check lv_field $vg5/$lv1 lv_active "active"
-check lv_field $vg5/$lv2 lv_active "active"
-check lv_field $vg6/$lv1 lv_active "active"
-check lv_field $vg6/$lv2 lv_active "active"
-check lv_field $vg7/$lv1 lv_active "active"
-check lv_field $vg7/$lv2 lv_active "active"
-
-vgchange -an $vg5
-vgremove -y $vg5
-vgchange -an $vg6
-vgremove -y $vg6
-vgchange -an $vg7
-vgremove -y $vg7
-
-# 3 devs, 1 vg, 1000 LVs
-
-wipe_all
-rm $DF
-touch $DF
-pvcreate --metadatacopies 0 "$dev1"
-pvcreate "$dev2"
-pvcreate "$dev3"
-vgcreate -s 128K $vg8 "$dev1" "$dev2" "$dev3"
-
-# Number of LVs to create
-TEST_DEVS=1000
-# On low-memory boxes let's not stress too much
-test "$(aux total_mem)" -gt 524288 || TEST_DEVS=256
-
-vgcfgbackup -f data $vg8
-
-# Generate a lot of devices (size of 1 extent)
-awk -v TEST_DEVS=$TEST_DEVS '/^\t\}/ {
- printf("\t}\n\tlogical_volumes {\n");
- cnt=0;
- for (i = 0; i < TEST_DEVS; i++) {
- printf("\t\tlvol%06d {\n", i);
- printf("\t\t\tid = \"%06d-1111-2222-3333-2222-1111-%06d\"\n", i, i);
- print "\t\t\tstatus = [\"READ\", \"WRITE\", \"VISIBLE\"]";
- print "\t\t\tsegment_count = 1";
- print "\t\t\tsegment1 {";
- print "\t\t\t\tstart_extent = 0";
- print "\t\t\t\textent_count = 1";
- print "\t\t\t\ttype = \"striped\"";
- print "\t\t\t\tstripe_count = 1";
- print "\t\t\t\tstripes = [";
- print "\t\t\t\t\t\"pv0\", " cnt++;
- printf("\t\t\t\t]\n\t\t\t}\n\t\t}\n");
- }
- }
- {print}
-' data >data_new
-
-vgcfgrestore -f data_new $vg8
-
-_clear_online_files
-
-udevadm trigger -c add /sys/block/$BDEV1 &
-udevadm trigger -c add /sys/block/$BDEV2 &
-udevadm trigger -c add /sys/block/$BDEV3
-
-aux udev_wait
-wait_lvm_activate $vg8
-
-ls "$RUNDIR/lvm/vgs_online/$vg8"
-journalctl -u lvm-activate-$vg8 | tee out || true
-grep "now active" out
-
-num_active=$(lvs $vg8 --noheading -o active | grep active | wc -l)
-
-test $num_active -eq $TEST_DEVS
-
-vgchange -an $vg8
-vgremove -y $vg8
-
-# 1 pv on an md dev, 1 vg
-
-wait_md_create() {
- local md=$1
-
- while :; do
- if ! grep "$(basename $md)" /proc/mdstat; then
- echo "$md not ready"
- cat /proc/mdstat
- sleep 2
- else
- break
- fi
- done
- echo "$md" > WAIT_MD_DEV
-}
-
-test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
- modprobe raid1 || skip
-
-mddev="/dev/md33"
-not grep $mddev /proc/mdstat || skip
-
-wipe_all
-rm $DF
-touch $DF
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-wait_md_create "$mddev"
-vgcreate $vg9 "$mddev"
-
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-BDEVMD=$(basename "$mddev")
-
-lvcreate -l1 -an -n $lv1 $vg9
-lvcreate -l1 -an -n $lv2 $vg9
-
-_clear_online_files
-
-udevadm trigger --settle -c add /sys/block/$BDEVMD
-
-wait_lvm_activate $vg9
-
-ls "$RUNDIR/lvm/vgs_online/$vg9"
-journalctl -u lvm-activate-$vg9 | tee out || true
-grep "now active" out
-check lv_field $vg9/$lv1 lv_active "active"
-check lv_field $vg9/$lv2 lv_active "active"
-
-vgchange -an $vg9
-vgremove -y $vg9
-
-mdadm --stop "$mddev"
-aux udev_wait
-wipe_all
-
diff --git a/udev/69-dm-lvm.rules.in b/udev/69-dm-lvm.rules.in
deleted file mode 100644
index 39e5b9807..000000000
--- a/udev/69-dm-lvm.rules.in
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) 2012,2021 Red Hat, Inc. All rights reserved.
-#
-# This file is part of LVM.
-#
-# This rule requires blkid to be called on block devices before so only devices
-# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member").
-
-SUBSYSTEM!="block", GOTO="lvm_end"
-(LVM_EXEC_RULE)
-
-ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end"
-
-# Only process devices already marked as a PV - this requires blkid to be called before.
-ENV{ID_FS_TYPE}!="LVM2_member", GOTO="lvm_end"
-ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end"
-ACTION=="remove", GOTO="lvm_end"
-
-# Create /dev/disk/by-id/lvm-pv-uuid-<PV_UUID> symlink for each PV
-ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-id/lvm-pv-uuid-$env{ID_FS_UUID_ENC}"
-
-# If the PV is a special device listed below, scan only if the device is
-# properly activated. These devices are not usable after an ADD event,
-# but they require an extra setup and they are ready after a CHANGE event.
-# Also support coldplugging with ADD event but only if the device is already
-# properly activated.
-# This logic should be eventually moved to rules where those particular
-# devices are processed primarily (MD and loop).
-
-# DM device:
-KERNEL!="dm-[0-9]*", GOTO="next"
-ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan"
-GOTO="lvm_end"
-
-# MD device:
-LABEL="next"
-KERNEL!="md[0-9]*", GOTO="next"
-IMPORT{db}="LVM_MD_PV_ACTIVATED"
-ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan"
-ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan"
-ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan"
-ENV{LVM_MD_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
-GOTO="lvm_end"
-
-# Loop device:
-LABEL="next"
-KERNEL!="loop[0-9]*", GOTO="next"
-ACTION=="add", ENV{LVM_LOOP_PV_ACTIVATED}=="1", GOTO="lvm_scan"
-ACTION=="change", ENV{LVM_LOOP_PV_ACTIVATED}!="1", TEST=="loop/backing_file", ENV{LVM_LOOP_PV_ACTIVATED}="1", GOTO="lvm_scan"
-ENV{LVM_LOOP_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
-GOTO="lvm_end"
-
-LABEL="next"
-ACTION!="add", GOTO="lvm_end"
-
-LABEL="lvm_scan"
-
-ENV{SYSTEMD_READY}="1"
-
-# pvscan will check if this device completes a VG,
-# i.e. all PVs in the VG are now present with the
-# arrival of this PV. If so, it prints to stdout:
-# LVM_VG_NAME_COMPLETE='foo'
-#
-# When the VG is complete it can be activated, so
-# vgchange -aay <vgname> is run. It is run via
-# systemd since it can take longer to run than
-# udev wants to block when processing rules.
-# (if there are hundreds of LVs to activate,
-# the vgchange can take many seconds.)
-#
-# pvscan only reads the single device specified,
-# and uses temp files under /run/lvm to check if
-# other PVs in the VG are present.
-#
-# If event_activation=0 in lvm.conf, this pvscan
-# (using checkcomplete) will do nothing, so that
-# no event-based autoactivation will be happen.
-#
-# TODO: adjust the output of vgchange -aay so that
-# it's better suited to appearing in the journal.
-
-IMPORT{program}="(LVM_EXEC)/lvm pvscan --cache --listvg --checkcomplete --vgonline --udevoutput --journal=output $env{DEVNAME}"
-ENV{LVM_VG_NAME_COMPLETE}=="?*", RUN+="/usr/bin/systemd-run -r --no-block --property DefaultDependencies=no --unit lvm-activate-$env{LVM_VG_NAME_COMPLETE} lvm vgchange -aay --nohints $env{LVM_VG_NAME_COMPLETE}"
-GOTO="lvm_end"
-
-LABEL="lvm_end"
-
diff --git a/udev/Makefile.in b/udev/Makefile.in
index e777dda16..e32cba921 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -18,7 +18,7 @@ top_builddir = @top_builddir@
include $(top_builddir)/make.tmpl
DM_RULES=10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
-LVM_RULES=11-dm-lvm.rules 69-dm-lvm.rules
+LVM_RULES=11-dm-lvm.rules 69-dm-lvm-metad.rules
DM_DIR=$(shell $(GREP) "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | $(AWK) '{print $$3}')
--
2.34.3

View File

@ -0,0 +1,50 @@
From d6b3f4f4dd526a5a4413e84f4cccb2e92699d1d8 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 16 May 2024 15:30:02 +0200
Subject: [PATCH 2/7] Revert "10-dm.rules: bump DM_UDEV_RULES_VSN to 3"
This reverts commit 038f9254d9554654197b59c160e3f775af27cdb1.
---
udev/10-dm.rules.in | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index db4ee771d..ca255c793 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -12,9 +12,6 @@
# DM_NAME - actual DM device's name
# DM_UUID - UUID set for DM device (blank if not specified)
# DM_UDEV_RULES_VSN - DM udev rules version
-# DM_UDEV_DISABLE_OTHER_RULES_FLAG - a flag that indicates that
-# stacked layers shouldn't attempt to probe the device, and
-# should try to import relevant properties from the udev db.
#
# These rules cover only basic device-mapper functionality in udev.
#
@@ -25,11 +22,6 @@
# 11-dm-lvm.rules for LVM subsystem
# 11-dm-mpath.rules for multipath subsystem (since version 0.6.0, recommended!)
#
-# 11-dm<subsystem_name>.rules may use other DM related properties besides
-# those listed above, like .DM_SUSPENDED. These properties are considered
-# internal to device mapper, and subject to change without notice.
-# Rules that are executed after 13-dm-disk.rules shouldn't use them.
-#
# Even more specific rules may be required by subsystems so always
# check subsystem's upstream repository for recent set of rules.
# Also, keep in mind that recent rules may also require recent
@@ -152,9 +144,7 @@ LABEL="dm_suspended_set"
# possible future changes.
# VSN 1 - original rules
# VSN 2 - add support for synthesized events
-# VSN 3 - use DM_UDEV_DISABLE_OTHER_RULES_FLAG as the only "API"
-# to be consumed by non-dm rules.
-ENV{DM_UDEV_RULES_VSN}="3"
+ENV{DM_UDEV_RULES_VSN}="2"
ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="(DM_DIR)/$env{DM_NAME}"
--
2.44.0

View File

@ -1,450 +0,0 @@
From 2091305b796d5552fd991c527a0359a0b4d8fde0 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 20 Dec 2021 13:38:23 -0600
Subject: [PATCH 02/54] Revert "pvscan: only add device args to dev cache"
This reverts commit 33e47182f773c1a902b533580b63a803906de55d.
---
lib/device/dev-cache.c | 204 +++-----------------------------
lib/device/dev-cache.h | 6 +-
lib/device/device_id.c | 27 ++---
lib/device/device_id.h | 1 -
test/shell/devicesfile-basic.sh | 2 +-
tools/pvscan.c | 58 ++++-----
6 files changed, 52 insertions(+), 246 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 33b75a9a9..c6e5f68cf 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1852,7 +1852,7 @@ int setup_devices_file(struct cmd_context *cmd)
* Add all system devices to dev-cache, and attempt to
* match all devices_file entries to dev-cache entries.
*/
-int setup_devices(struct cmd_context *cmd)
+static int _setup_devices(struct cmd_context *cmd, int no_file_match)
{
int file_exists;
int lock_mode = 0;
@@ -1979,6 +1979,13 @@ int setup_devices(struct cmd_context *cmd)
*/
dev_cache_scan(cmd);
+ /*
+ * The caller uses "no_file_match" if it wants to match specific devs
+ * itself, instead of matching everything in device_ids_match.
+ */
+ if (no_file_match && cmd->enable_devices_file)
+ return 1;
+
/*
* Match entries from cmd->use_devices with device structs in dev-cache.
*/
@@ -1987,6 +1994,16 @@ int setup_devices(struct cmd_context *cmd)
return 1;
}
+int setup_devices(struct cmd_context *cmd)
+{
+ return _setup_devices(cmd, 0);
+}
+
+int setup_devices_no_file_match(struct cmd_context *cmd)
+{
+ return _setup_devices(cmd, 1);
+}
+
/*
* The alternative to setup_devices() when the command is interested
* in using only one PV.
@@ -2055,188 +2072,3 @@ int setup_device(struct cmd_context *cmd, const char *devname)
return 1;
}
-/*
- * pvscan --cache is specialized/optimized to look only at command args,
- * so this just sets up the devices file, then individual devices are
- * added to dev-cache and matched with device_ids later in pvscan.
- */
-
-int setup_devices_for_pvscan_cache(struct cmd_context *cmd)
-{
- if (cmd->enable_devices_list) {
- if (!_setup_devices_list(cmd))
- return_0;
- return 1;
- }
-
- if (!setup_devices_file(cmd))
- return_0;
-
- if (!cmd->enable_devices_file)
- return 1;
-
- if (!devices_file_exists(cmd)) {
- log_debug("Devices file not found, ignoring.");
- cmd->enable_devices_file = 0;
- return 1;
- }
-
- if (!lock_devices_file(cmd, LOCK_SH)) {
- log_error("Failed to lock the devices file to read.");
- return 0;
- }
-
- if (!device_ids_read(cmd)) {
- log_error("Failed to read the devices file.");
- unlock_devices_file(cmd);
- return 0;
- }
-
- unlock_devices_file(cmd);
- return 1;
-}
-
-
-/* Get a device name from a devno. */
-
-static char *_get_devname_from_devno(struct cmd_context *cmd, dev_t devno)
-{
- char path[PATH_MAX];
- char devname[PATH_MAX];
- char namebuf[NAME_LEN];
- char line[1024];
- int major = MAJOR(devno);
- int minor = MINOR(devno);
- int line_major;
- int line_minor;
- uint64_t line_blocks;
- DIR *dir;
- struct dirent *dirent;
- FILE *fp;
-
- /*
- * $ ls /sys/dev/block/8:0/device/block/
- * sda
- */
- if (major_is_scsi_device(cmd->dev_types, major)) {
- if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/device/block",
- dm_sysfs_dir(), major, minor) < 0) {
- return NULL;
- }
-
- if (!(dir = opendir(path)))
- return NULL;
-
- while ((dirent = readdir(dir))) {
- if (dirent->d_name[0] == '.')
- continue;
- if (dm_snprintf(devname, sizeof(devname), "/dev/%s", dirent->d_name) < 0) {
- devname[0] = '\0';
- stack;
- }
- break;
- }
- closedir(dir);
-
- if (devname[0]) {
- log_debug("Found %s for %d:%d from sys", devname, major, minor);
- return _strdup(devname);
- }
- return NULL;
- }
-
- /*
- * $ cat /sys/dev/block/253:3/dm/name
- * mpatha
- */
- if (major == cmd->dev_types->device_mapper_major) {
- if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/dm/name",
- dm_sysfs_dir(), major, minor) < 0) {
- return NULL;
- }
-
- if (!get_sysfs_value(path, namebuf, sizeof(namebuf), 0))
- return NULL;
-
- if (dm_snprintf(devname, sizeof(devname), "/dev/mapper/%s", namebuf) < 0) {
- devname[0] = '\0';
- stack;
- }
-
- if (devname[0]) {
- log_debug("Found %s for %d:%d from sys", devname, major, minor);
- return _strdup(devname);
- }
- return NULL;
- }
-
- /*
- * /proc/partitions lists
- * major minor #blocks name
- */
-
- if (!(fp = fopen("/proc/partitions", "r")))
- return NULL;
-
- while (fgets(line, sizeof(line), fp)) {
- if (sscanf(line, "%u %u %llu %s", &line_major, &line_minor, (unsigned long long *)&line_blocks, namebuf) != 4)
- continue;
- if (line_major != major)
- continue;
- if (line_minor != minor)
- continue;
-
- if (dm_snprintf(devname, sizeof(devname), "/dev/%s", namebuf) < 0) {
- devname[0] = '\0';
- stack;
- }
- break;
- }
- fclose(fp);
-
- if (devname[0]) {
- log_debug("Found %s for %d:%d from proc", devname, major, minor);
- return _strdup(devname);
- }
-
- /*
- * If necessary, this could continue searching by stat'ing /dev entries.
- */
-
- return NULL;
-}
-
-int setup_devname_in_dev_cache(struct cmd_context *cmd, const char *devname)
-{
- struct stat buf;
- struct device *dev;
-
- if (stat(devname, &buf) < 0) {
- log_error("Cannot access device %s.", devname);
- return 0;
- }
-
- if (!S_ISBLK(buf.st_mode)) {
- log_error("Invaild device type %s.", devname);
- return 0;
- }
-
- if (!_insert_dev(devname, buf.st_rdev))
- return_0;
-
- if (!(dev = (struct device *) dm_hash_lookup(_cache.names, devname)))
- return_0;
-
- return 1;
-}
-
-int setup_devno_in_dev_cache(struct cmd_context *cmd, dev_t devno)
-{
- const char *devname;
-
- if (!(devname = _get_devname_from_devno(cmd, devno)))
- return_0;
-
- return setup_devname_in_dev_cache(cmd, devname);
-}
-
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 143848d6d..635dc4fc9 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -77,11 +77,7 @@ int get_dm_uuid_from_sysfs(char *buf, size_t buf_size, int major, int minor);
int setup_devices_file(struct cmd_context *cmd);
int setup_devices(struct cmd_context *cmd);
+int setup_devices_no_file_match(struct cmd_context *cmd);
int setup_device(struct cmd_context *cmd, const char *devname);
-/* Normal device setup functions are split up for pvscan optimization. */
-int setup_devices_for_pvscan_cache(struct cmd_context *cmd);
-int setup_devname_in_dev_cache(struct cmd_context *cmd, const char *devname);
-int setup_devno_in_dev_cache(struct cmd_context *cmd, dev_t devno);
-
#endif
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 167bf661b..eb06109ff 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1534,22 +1534,6 @@ int device_ids_match_dev(struct cmd_context *cmd, struct device *dev)
* passes the filter.
*/
-void device_ids_match_device_list(struct cmd_context *cmd)
-{
- struct dev_use *du;
-
- dm_list_iterate_items(du, &cmd->use_devices) {
- if (du->dev)
- continue;
- if (!(du->dev = dev_cache_get(cmd, du->devname, NULL))) {
- log_warn("Device not found for %s.", du->devname);
- } else {
- /* Should we set dev->id? Which idtype? Use --deviceidtype? */
- du->dev->flags |= DEV_MATCHED_USE_ID;
- }
- }
-}
-
void device_ids_match(struct cmd_context *cmd)
{
struct dev_iter *iter;
@@ -1557,7 +1541,16 @@ void device_ids_match(struct cmd_context *cmd)
struct device *dev;
if (cmd->enable_devices_list) {
- device_ids_match_device_list(cmd);
+ dm_list_iterate_items(du, &cmd->use_devices) {
+ if (du->dev)
+ continue;
+ if (!(du->dev = dev_cache_get(cmd, du->devname, NULL))) {
+ log_warn("Device not found for %s.", du->devname);
+ } else {
+ /* Should we set dev->id? Which idtype? Use --deviceidtype? */
+ du->dev->flags |= DEV_MATCHED_USE_ID;
+ }
+ }
return;
}
diff --git a/lib/device/device_id.h b/lib/device/device_id.h
index 0ada35c94..939b3a0f4 100644
--- a/lib/device/device_id.h
+++ b/lib/device/device_id.h
@@ -32,7 +32,6 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid,
void device_id_pvremove(struct cmd_context *cmd, struct device *dev);
void device_ids_match(struct cmd_context *cmd);
int device_ids_match_dev(struct cmd_context *cmd, struct device *dev);
-void device_ids_match_device_list(struct cmd_context *cmd);
void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, int *device_ids_invalid, int noupdate);
int device_ids_version_unchanged(struct cmd_context *cmd);
void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_list, int *search_count, int noupdate);
diff --git a/test/shell/devicesfile-basic.sh b/test/shell/devicesfile-basic.sh
index 9c3455c76..7ba9e2c7f 100644
--- a/test/shell/devicesfile-basic.sh
+++ b/test/shell/devicesfile-basic.sh
@@ -283,7 +283,7 @@ not ls "$RUNDIR/lvm/pvs_online/$PVID3"
# arg in devices list
_clear_online_files
pvscan --devices "$dev3" --cache -aay "$dev3"
-pvscan --devices "$dev4","$dev3" --cache -aay "$dev4"
+pvscan --devices "$dev4" --cache -aay "$dev4"
check lv_field $vg2/$lv2 lv_active "active"
vgchange -an $vg2
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 95d593d57..8e2611361 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -857,21 +857,11 @@ static int _get_devs_from_saved_vg(struct cmd_context *cmd, const char *vgname,
devno = MKDEV(file_major, file_minor);
- if (!setup_devno_in_dev_cache(cmd, devno)) {
- log_error_pvscan(cmd, "No device set up for %d:%d PVID %s", file_major, file_minor, pvid);
- goto bad;
- }
-
if (!(dev = dev_cache_get_by_devt(cmd, devno, NULL, NULL))) {
log_error_pvscan(cmd, "No device found for %d:%d PVID %s", file_major, file_minor, pvid);
goto bad;
}
- /*
- * Do not need to match device_id here, see comment after
- * get_devs_from_saved_vg about relying on pvid online file.
- */
-
name1 = dev_name(dev);
name2 = pvl->pv->device_hint;
@@ -1109,11 +1099,17 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
* PROCESS_SKIP_SCAN: we have already done lvmcache_label_scan
* so tell process_each to skip it.
*/
+ if (do_all)
+ read_flags |= PROCESS_SKIP_SCAN;
+ /*
+ * When the command is processing specific devs (not all), it
+ * has done setup_devices_no_file_match() to avoid matching ids
+ * fo all devs unnecessarily, but now that we're falling back
+ * to process_each_vg() we need to complete the id matching.
+ */
if (!do_all)
- lvmcache_label_scan(cmd);
-
- read_flags |= PROCESS_SKIP_SCAN;
+ device_ids_match(cmd);
ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, read_flags, 0, handle, _pvscan_aa_single);
}
@@ -1196,15 +1192,11 @@ static int _get_args_devs(struct cmd_context *cmd, struct dm_list *pvscan_args,
/* in common usage, no dev will be found for a devno */
dm_list_iterate_items(arg, pvscan_args) {
- if (arg->devname) {
- if (!setup_devname_in_dev_cache(cmd, arg->devname))
- log_error_pvscan(cmd, "No device set up for name arg %s", arg->devname);
+ if (arg->devname)
arg->dev = dev_cache_get(cmd, arg->devname, NULL);
- } else if (arg->devno) {
- if (!setup_devno_in_dev_cache(cmd, arg->devno))
- log_error_pvscan(cmd, "No device set up for devno arg %d", (int)arg->devno);
+ else if (arg->devno)
arg->dev = dev_cache_get_by_devt(cmd, arg->devno, NULL, NULL);
- } else
+ else
return_0;
}
@@ -1680,13 +1672,11 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
cmd->pvscan_cache_single = 1;
/*
- * Special pvscan-specific setup steps to avoid looking
- * at any devices except for device args.
- * Read devices file and determine if devices file will be used.
- * Does not do dev_cache_scan (adds nothing to dev-cache), and
- * does not do any device id matching.
+ * "no_file_match" means that when the devices file is used,
+ * setup_devices will skip matching devs to devices file entries.
+ * Specific devs must be matched later with device_ids_match_dev().
*/
- if (!setup_devices_for_pvscan_cache(cmd)) {
+ if (!setup_devices_no_file_match(cmd)) {
log_error_pvscan(cmd, "Failed to set up devices.");
return 0;
}
@@ -1745,21 +1735,17 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
log_debug("pvscan_cache_args: filter devs nodata");
/*
- * Match dev args with the devices file because special/optimized
- * device setup was used above which does not check the devices file.
- * If a match fails here do not exclude it, that will be done below by
- * passes_filter() which runs filter-deviceid. The
- * relax_deviceid_filter case needs to be able to work around
+ * Match dev args with the devices file because
+ * setup_devices_no_file_match() was used above which skipped checking
+ * the devices file. If a match fails here do not exclude it, that
+ * will be done below by passes_filter() which runs filter-deviceid.
+ * The relax_deviceid_filter case needs to be able to work around
* unmatching devs.
*/
-
if (cmd->enable_devices_file) {
- dm_list_iterate_items(devl, &pvscan_devs)
+ dm_list_iterate_items_safe(devl, devl2, &pvscan_devs)
device_ids_match_dev(cmd, devl->dev);
-
}
- if (cmd->enable_devices_list)
- device_ids_match_device_list(cmd);
if (cmd->enable_devices_file && device_ids_use_devname(cmd)) {
relax_deviceid_filter = 1;
--
2.34.3

View File

@ -0,0 +1,43 @@
From da6319b9f5d263a210cf51b471fdbf1c343facf3 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 16 May 2024 15:30:15 +0200
Subject: [PATCH 3/7] Revert "dm udev rules: don't export and save DM_NOSCAN"
This reverts commit a196752969320cfc34a97cc97afa1978fa57da73.
---
udev/11-dm-lvm.rules.in | 2 +-
udev/13-dm-disk.rules.in | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in
index cfc022489..5b0cc5242 100644
--- a/udev/11-dm-lvm.rules.in
+++ b/udev/11-dm-lvm.rules.in
@@ -30,7 +30,7 @@ IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows
# so those selected rules are surely skipped.
# We don't need to save and restore the previous of DM_UDEV_DISABLE_OTHER_RULES_FLAG,
# that's taken care of in 10-dm.rules.
-ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{.DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
+ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
index b53bb62de..b748cc909 100644
--- a/udev/13-dm-disk.rules.in
+++ b/udev/13-dm-disk.rules.in
@@ -18,9 +18,9 @@ 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_import"
-ENV{.DM_NOSCAN}=="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"
+ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
(BLKID_RULE)
GOTO="dm_link"
--
2.44.0

View File

@ -1,34 +0,0 @@
From a5a2d5fa1ec47a5a548db4cf435dc84de7ce7c31 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 20 Oct 2021 16:12:41 -0500
Subject: [PATCH 03/54] pvscan: fix messages from coverity changes
---
tools/pvscan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 8e2611361..f60c4a2ca 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1354,7 +1354,7 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
devsize = dev->size;
if (!devsize &&
!dev_get_size(dev, &devsize)) {
- log_print("pvscan[%d] PV %s can get device size.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "PV %s missing device size.", dev_name(dev));
release_vg(vg);
continue;
}
@@ -1786,7 +1786,7 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
int has_pvid;
if (!label_read_pvid(devl->dev, &has_pvid)) {
- log_print("pvscan[%d] %s cannot read.", getpid(), dev_name(devl->dev));
+ log_print_pvscan(cmd, "%s cannot read label.", dev_name(devl->dev));
dm_list_del(&devl->list);
continue;
}
--
2.34.3

View File

@ -0,0 +1,88 @@
From 2e2303dd559fda3fb7d97f79094d04c3ccd9d519 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 16 May 2024 15:30:24 +0200
Subject: [PATCH 4/7] Revert "dm udev rules: don't export and save
DM_SUSPENDED"
This reverts commit 21ca92c4325b6b161fb1e1f10942ad9f8d23c144.
---
udev/10-dm.rules.in | 14 ++++++--------
udev/12-dm-permissions.rules | 1 +
udev/13-dm-disk.rules.in | 4 ++--
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index ca255c793..29fe71527 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -11,6 +11,7 @@
# for use in later rules:
# DM_NAME - actual DM device's name
# DM_UUID - UUID set for DM device (blank if not specified)
+# DM_SUSPENDED - suspended state of DM device (0 or 1)
# DM_UDEV_RULES_VSN - DM udev rules version
#
# These rules cover only basic device-mapper functionality in udev.
@@ -122,18 +123,15 @@ LABEL="dm_no_coldplug"
# The "suspended" item was added even later (kernels >= 2.6.31),
# so we also have to call dmsetup if the kernel version used
# is in between these releases.
-TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{.DM_SUSPENDED}="$attr{dm/suspended}"
+TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{DM_SUSPENDED}="$attr{dm/suspended}"
TEST!="dm", IMPORT{program}="(DM_EXEC)/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended"
+ENV{DM_SUSPENDED}!="?*", IMPORT{program}="(DM_EXEC)/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
-ENV{.DM_SUSPENDED}=="?*", GOTO="dm_suspended_set"
-TEST=="dm", IMPORT{program}="(DM_EXEC)/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
# dmsetup tool provides suspended state information in textual
# form with values "Suspended"/"Active". We translate it to
# 0/1 respectively to be consistent with sysfs values.
-ENV{DM_SUSPENDED}=="Active", ENV{.DM_SUSPENDED}="0"
-ENV{DM_SUSPENDED}=="Suspended", ENV{.DM_SUSPENDED}="1"
-ENV{DM_SUSPENDED}=""
-LABEL="dm_suspended_set"
+ENV{DM_SUSPENDED}=="Active", ENV{DM_SUSPENDED}="0"
+ENV{DM_SUSPENDED}=="Suspended", ENV{DM_SUSPENDED}="1"
# This variable provides a reliable way to check that device-mapper
# rules were installed. It means that all needed variables are set
@@ -151,7 +149,7 @@ ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="(DM_DIR)/
# Avoid processing and scanning a DM device in the other (foreign)
# rules if it is in suspended state. However, we still keep 'disk'
# and 'DM subsystem' related rules enabled in this case.
-ENV{.DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
+ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
GOTO="dm_end"
diff --git a/udev/12-dm-permissions.rules b/udev/12-dm-permissions.rules
index 9624ddc5e..8d3bc224a 100644
--- a/udev/12-dm-permissions.rules
+++ b/udev/12-dm-permissions.rules
@@ -14,6 +14,7 @@
# DM_UDEV_RULES_VSN - DM udev rules version
# DM_NAME - actual DM device's name
# DM_UUID - UUID set for DM device (blank if not specified)
+# DM_SUSPENDED - suspended state of DM device (0 or 1)
# DM_LV_NAME - logical volume name (not set if LVM device not present)
# DM_VG_NAME - volume group name (not set if LVM device not present)
# DM_LV_LAYER - logical volume layer (not set if LVM device not present)
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
index b748cc909..183693bf1 100644
--- a/udev/13-dm-disk.rules.in
+++ b/udev/13-dm-disk.rules.in
@@ -17,9 +17,9 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
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_import"
+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_SUSPENDED}=="1", GOTO="dm_end"
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
(BLKID_RULE)
--
2.44.0

View File

@ -1,39 +0,0 @@
From 074fce5c73c55e7a1547d5efff65a9f96e6db3b1 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 25 Oct 2021 12:11:17 -0500
Subject: [PATCH 04/54] vgimportdevices: skip lvmlockd locking
Help bootstrapping existing shared vgs into the devices file.
Reading the vg in vgimportdevices would require locking to be
started, but vgchange lockstart won't see the vg if it's not
in the devices file. The lvmlockd locks are not protecting
vg modifications so skipping them here won't be a problem.
---
tools/vgimportdevices.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index 3f315f98f..2580613c4 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -172,6 +172,17 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
cmd->filter_regex_with_devices_file = 1;
cmd->create_edit_devices_file = 1;
+ /*
+ * This helps a user bootstrap existing shared VGs into the devices
+ * file. Reading the vg to import devices requires locking, but
+ * lockstart won't find the vg before it's in the devices file.
+ * So, allow importing devices without an lvmlockd lock (in a
+ * a shared vg the vg metadata won't be updated with device ids,
+ * so the lvmlockd lock isn't protecting vg modification.)
+ */
+ cmd->lockd_gl_disable = 1;
+ cmd->lockd_vg_disable = 1;
+
/*
* For each VG:
* device_id_add() each PV in the VG
--
2.34.3

View File

@ -0,0 +1,38 @@
From cc3214c24425eb283dd46435345c28e5398b3570 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 16 May 2024 15:30:37 +0200
Subject: [PATCH 5/7] Revert "11-dm-lvm.rules: don't restore
DM_UDEV_DISABLE_OTHER_RULES_FLAG from db"
This reverts commit 2b2f11a74cd5cc05f266fd0c65f0e55eb8bafd9f.
---
udev/11-dm-lvm.rules.in | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in
index 5b0cc5242..5f04ab329 100644
--- a/udev/11-dm-lvm.rules.in
+++ b/udev/11-dm-lvm.rules.in
@@ -26,11 +26,14 @@ IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows
# to zero any stale metadata found within the LV data area. Such stale
# metadata could cause false claim of the LV device, keeping it open etc.
#
-# If the NOSCAN flag is present, set DM_UDEV_DISABLE_OTHER_RULES_FLAG
-# so those selected rules are surely skipped.
-# We don't need to save and restore the previous of DM_UDEV_DISABLE_OTHER_RULES_FLAG,
-# that's taken care of in 10-dm.rules.
-ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
+# If the NOSCAN flag is present, backup selected existing flags used to
+# disable rules, then set them firmly so those selected rules are surely skipped.
+# Restore these flags once the NOSCAN flag is dropped (which is normally any
+# uevent that follows for this LV, even an artificially generated one).
+ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
+ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
+ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \
+ ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="", ENV{DM_NOSCAN}=""
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
--
2.44.0

View File

@ -1,95 +0,0 @@
From 00ebabfe6e1ebfceffcef335d44a6156a1c15418 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 1 Nov 2021 16:01:09 -0500
Subject: [PATCH 05/54] hints: remove the cmd hints list
which is no longer used after commit
"toollib: remove all devices list from process_each_pv"
---
lib/commands/toolcontext.c | 2 --
lib/commands/toolcontext.h | 1 -
lib/label/hints.c | 1 -
lib/label/label.c | 8 ++------
4 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 105aecd5d..1b7170de1 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1605,7 +1605,6 @@ struct cmd_context *create_config_context(void)
dm_list_init(&cmd->config_files);
dm_list_init(&cmd->tags);
- dm_list_init(&cmd->hints);
if (!_init_lvm_conf(cmd))
goto_out;
@@ -1670,7 +1669,6 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
dm_list_init(&cmd->formats);
dm_list_init(&cmd->segtypes);
dm_list_init(&cmd->tags);
- dm_list_init(&cmd->hints);
dm_list_init(&cmd->config_files);
label_init();
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 701b7a739..356c79f8a 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -206,7 +206,6 @@ struct cmd_context {
* Devices and filtering.
*/
struct dev_filter *filter;
- struct dm_list hints;
struct dm_list use_devices; /* struct dev_use for each entry in devices file */
const char *md_component_checks;
const char *search_for_devnames; /* config file setting */
diff --git a/lib/label/hints.c b/lib/label/hints.c
index 3dba9f8ec..e444a0c82 100644
--- a/lib/label/hints.c
+++ b/lib/label/hints.c
@@ -365,7 +365,6 @@ static void _unlock_hints(struct cmd_context *cmd)
void hints_exit(struct cmd_context *cmd)
{
- free_hints(&cmd->hints);
if (_hints_fd == -1)
return;
_unlock_hints(cmd);
diff --git a/lib/label/label.c b/lib/label/label.c
index 3cd912270..479a5037a 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1207,8 +1207,6 @@ int label_scan(struct cmd_context *cmd)
(unsigned long long)want_size_kb);
}
- dm_list_init(&cmd->hints);
-
/*
* If we're using hints to limit which devs we scanned, verify
* that those hints were valid, and if not we need to scan the
@@ -1220,18 +1218,16 @@ int label_scan(struct cmd_context *cmd)
_scan_list(cmd, cmd->filter, &all_devs, 0, NULL);
/* scan_devs are the devs that have been scanned */
dm_list_splice(&scan_devs, &all_devs);
- free_hints(&hints_list);
using_hints = 0;
create_hints = 0;
/* invalid hints means a new dev probably appeared and
we should search for any missing pvids again. */
unlink_searched_devnames(cmd);
- } else {
- /* The hints may be used by another device iteration. */
- dm_list_splice(&cmd->hints, &hints_list);
}
}
+ free_hints(&hints_list);
+
/*
* Check if the devices_file content is up to date and
* if not update it.
--
2.34.3

View File

@ -0,0 +1,49 @@
From 147498a07fd4e7dd0698b443bbcf15cfe6a6e104 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 16 May 2024 15:30:48 +0200
Subject: [PATCH 6/7] Revert "10-dm-rules: don't restore
DM_UDEV_DISABLE_OTHER_RULES_FLAG from db"
This reverts commit f98d020eadafe7d8db7bec1f5a26915615e5a6a9.
---
udev/10-dm.rules.in | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index 29fe71527..2c6903da7 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -53,14 +53,7 @@ OPTIONS+="db_persist"
# These flags are encoded in DM_COOKIE variable that was introduced in
# kernel version 2.6.31. Therefore, we can use this feature with
# kernels >= 2.6.31 only. Cookie is not decoded for remove event.
-ENV{DM_COOKIE}!="?*", GOTO="dm_no_cookie"
-IMPORT{program}="(DM_EXEC)/dmsetup udevflags $env{DM_COOKIE}"
-
-# Store the original flag from the cookie as DM_COOKIE_DISABLE_OTHER_RULES_FLAG
-# in the udev db. DM_UDEV_DISABLE_OTHER_RULES_FLAG will be or'd with other
-# conditions for use by upper, non-dm layers.
-ENV{DM_COOKIE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}"
-LABEL="dm_no_cookie"
+ENV{DM_COOKIE}=="?*", IMPORT{program}="(DM_EXEC)/dmsetup udevflags $env{DM_COOKIE}"
# There is no cookie set nor any flags encoded in events not originating
# in libdevmapper so we need to detect this and try to behave correctly.
@@ -70,13 +63,12 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}="1", GOTO="dm_flags_do
IMPORT{db}="DM_UDEV_DISABLE_DM_RULES_FLAG"
IMPORT{db}="DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG"
IMPORT{db}="DM_UDEV_DISABLE_DISK_RULES_FLAG"
-IMPORT{db}="DM_COOKIE_DISABLE_OTHER_RULES_FLAG"
+IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG"
IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG"
IMPORT{db}="DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG"
IMPORT{db}="DM_UDEV_PRIMARY_SOURCE_FLAG"
IMPORT{db}="DM_UDEV_FLAG7"
IMPORT{db}="DM_UDEV_RULES_VSN"
-ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_COOKIE_DISABLE_OTHER_RULES_FLAG}"
LABEL="dm_flags_done"
# If DISK_RO is set, it's an uevent that changes the ro attribute of the device.
--
2.44.0

View File

@ -1,422 +0,0 @@
From f73be4480a5dd104a77e3ef84d7dcc80b834e593 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 2 Nov 2021 15:42:26 -0500
Subject: [PATCH 06/54] filter-sysfs: skip when device id is set
When a device id is set for a device, using an idtype other
than devname, it means that sysfs has been used with the device
to match the device id. So, checking for a sysfs entry for the
device in filter-sysfs is redundant. For any other cases not
covered by this (e.g. devname ids), have filter-sysfs simply
stat /sys/dev/block/major:minor to test if the device exists
in sysfs.
The extensive processing done by filter-sysfs init is removed.
It was taking an immense amount of time with many devices, e.g.
. 1024 PVs in 520 VGs
. 520 concurrent vgchange -ay <vgname> commands
. vgchange scans only PVs in the named VG (based on pvs_online
files from a pending patch)
A large number of the vgchange commands were taking over 1 min,
and nearly half of that time was used by filter-sysfs init.
With this patch, the vgchange commands take about half the time.
---
lib/commands/toolcontext.c | 24 ++-
lib/filters/filter-sysfs.c | 296 +++----------------------------------
2 files changed, 32 insertions(+), 288 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 1b7170de1..a0c78ddd6 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1143,19 +1143,6 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
* Update MAX_FILTERS definition above when adding new filters.
*/
- /*
- * sysfs filter. Only available on 2.6 kernels. Non-critical.
- * Listed first because it's very efficient at eliminating
- * unavailable devices.
- *
- * TODO: I suspect that using the lvm_type and device_id
- * filters before this one may be more efficient.
- */
- if (find_config_tree_bool(cmd, devices_sysfs_scan_CFG, NULL)) {
- if ((filters[nr_filt] = sysfs_filter_create()))
- nr_filt++;
- }
-
/* internal filter used by command processing. */
if (!(filters[nr_filt] = internal_filter_create())) {
log_error("Failed to create internal device filter");
@@ -1195,6 +1182,17 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
}
nr_filt++;
+ /*
+ * sysfs filter. Only available on 2.6 kernels. Non-critical.
+ * Eliminates unavailable devices.
+ * TODO: this may be unnecessary now with device ids
+ * (currently not used for devs match to device id using syfs)
+ */
+ if (find_config_tree_bool(cmd, devices_sysfs_scan_CFG, NULL)) {
+ if ((filters[nr_filt] = sysfs_filter_create()))
+ nr_filt++;
+ }
+
/* usable device filter. Required. */
if (!(filters[nr_filt] = usable_filter_create(cmd, cmd->dev_types, FILTER_MODE_NO_LVMETAD))) {
log_error("Failed to create usabled device filter");
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
index 32ac324dd..672211057 100644
--- a/lib/filters/filter-sysfs.c
+++ b/lib/filters/filter-sysfs.c
@@ -17,288 +17,49 @@
#ifdef __linux__
-#include <sys/sysmacros.h>
-#include <dirent.h>
-
-static int _locate_sysfs_blocks(const char *sysfs_dir, char *path, size_t len,
- unsigned *sysfs_depth)
+static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name)
{
+ char path[PATH_MAX];
+ const char *sysfs_dir;
struct stat info;
- unsigned i;
- static const struct dir_class {
- const char path[32];
- int depth;
- } classes[] = {
- /*
- * unified classification directory for all kernel subsystems
- *
- * /sys/subsystem/block/devices
- * |-- sda -> ../../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
- * |-- sda1 -> ../../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1
- * `-- sr0 -> ../../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
- *
- */
- { "subsystem/block/devices", 0 },
-
- /*
- * block subsystem as a class
- *
- * /sys/class/block
- * |-- sda -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
- * |-- sda1 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1
- * `-- sr0 -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
- *
- */
- { "class/block", 0 },
-
- /*
- * old block subsystem layout with nested directories
- *