From fd4231f63897b6d3cc09dff9d19df0d02e326519 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 3 Sep 2021 11:46:33 -0500 Subject: event activation switch During startup, a new service lvm-activate-vgs will run at a fixed point in time to activate all complete VGs. At the same time it enables the pvscan/vgchange in the lvm udev rule to begin event based autoactivation for VGs that become complete after lvm-activate-vgs. --- scripts/lvm-activate-vgs-last.service | 15 +++++++++++++++ scripts/lvm-activate-vgs-main.service | 16 ++++++++++++++++ udev/69-dm-lvm-metad.rules.in | 2 +- udev/69-dm-lvm.rules.in | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 scripts/lvm-activate-vgs-last.service create mode 100644 scripts/lvm-activate-vgs-main.service diff --git a/scripts/lvm-activate-vgs-last.service b/scripts/lvm-activate-vgs-last.service new file mode 100644 index 000000000..42287d1b5 --- /dev/null +++ b/scripts/lvm-activate-vgs-last.service @@ -0,0 +1,15 @@ +[Unit] +Description=Activate LVM Volume Groups (last) +Documentation=man:vgchange(8) +After=lvm-activate-vgs.service multipathd.service cryptsetup.target +Before=local-fs-pre.target shutdown.target +DefaultDependencies=no +Conflicts=shutdown.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/lvm vgchange -aay --vgonline --config devices/hints=none --eventactivation enable +RemainAfterExit=yes + +[Install] +WantedBy=sysinit.target diff --git a/scripts/lvm-activate-vgs-main.service b/scripts/lvm-activate-vgs-main.service new file mode 100644 index 000000000..9d4d5486b --- /dev/null +++ b/scripts/lvm-activate-vgs-main.service @@ -0,0 +1,16 @@ +[Unit] +Description=Activate LVM Volume Groups +Documentation=man:vgchange(8) +After=dm-event.socket dm-event.service +Wants=systemd-udev-settle.service +Before=local-fs-pre.target shutdown.target +DefaultDependencies=no +Conflicts=shutdown.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/lvm vgchange -aay --vgonline --config devices/hints=none +RemainAfterExit=yes + +[Install] +WantedBy=sysinit.target diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in index 78f506520..4727cefc0 100644 --- a/udev/69-dm-lvm-metad.rules.in +++ b/udev/69-dm-lvm-metad.rules.in @@ -121,6 +121,6 @@ LABEL="direct_pvscan" # MD | | X | X* | | # loop | | X | X* | | # other | X | | X | | X -RUN+="(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major $major --minor $minor", ENV{LVM_SCANNED}="1" +RUN+="(LVM_EXEC)/lvm pvscan --background --cache --activate ay --eventactivation check --major $major --minor $minor", ENV{LVM_SCANNED}="1" LABEL="lvm_end" diff --git a/udev/69-dm-lvm.rules.in b/udev/69-dm-lvm.rules.in index 70f2b37e8..5aeb26cac 100644 --- a/udev/69-dm-lvm.rules.in +++ b/udev/69-dm-lvm.rules.in @@ -79,7 +79,7 @@ ENV{SYSTEMD_READY}="1" # 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}" +IMPORT{program}="(LVM_EXEC)/lvm pvscan --cache --listvg --checkcomplete --vgonline --eventactivation check --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 --config devices/hints=none $env{LVM_VG_NAME_COMPLETE}" GOTO="lvm_end" -- cgit v1.2.1