master - pvscan: handle case of scanning PV without metadata last
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa75b31db54782fb24b6b7e3c681a61b3579117c Commit: aa75b31db54782fb24b6b7e3c681a61b3579117c Parent: 41ba2b568b3d3ad1d1ee2a26cf9f44a2b2e77e8f Author: David Teigland <[email protected]> AuthorDate: Mon Apr 15 11:27:49 2019 -0500 Committer: David Teigland <[email protected]> CommitterDate: Mon Apr 15 11:27:49 2019 -0500
pvscan: handle case of scanning PV without metadata last
Handle the case where pvscan --cache -aay (with no dev args) gets to the final PV, completing the VG, but that final PV does not have VG metadata. In this case, we need to use VG metadata from a previously scanned PV in the same VG, which we saved for this possibility. Using this saved metadata, we can find which VG this PVID belongs to, and then check if that VG is now complete, and if so add the VG name to the list of complete VGs to be autoactivated.
--- test/shell/pvscan-autoactivate.sh | 66 ++++++++++++++++++------ tools/pvscan.c | 99 +++++++++++++++++++++++++++++++++++- 2 files changed, 145 insertions(+), 20 deletions(-)
test/shell/pvscan-autoactivate.sh +49 -17
@@ -27,7 +27,7 @@ _clear_online_files() { . lib/inittest -aux prepare_pvs 3 +aux prepare_pvs 8 vgcreate $vg1 "$dev1" "$dev2" lvcreate -n $lv1 -l 4 -a n $vg1
@@ -59,6 +59,19 @@ pvscan --cache -aay "$dev1" "$dev2" check lv_field $vg1/$lv1 lv_active "active" lvchange -an $vg1 +# check that a cache command without aay will +# just record online state, and that a following +# pvscan cache aay that does not record any new +# online files will activate the vg +_clear_online_files +pvscan --cache "$dev1" +check lv_field $vg1/$lv1 lv_active "" +pvscan --cache "$dev2" +check lv_field $vg1/$lv1 lv_active "" +pvscan --cache -aay +check lv_field $vg1/$lv1 lv_active "active" +lvchange -an $vg1 + # Set up tests where one dev has no metadata vgchange -an $vg1
@@ -94,22 +107,6 @@ lvchange -an $vg1 # is online without the -aay option to # activate until after they are online -# This part is disabled because it doesn't work if the -# 'pvscan --cache -aay' without args ends up scanning -# dev1 (without metadata) after dev2. - -#_clear_online_files - -#pvscan --cache "$dev1" -#check lv_field $vg1/$lv1 lv_active "" -#pvscan --cache "$dev2" -#check lv_field $vg1/$lv1 lv_active "" -#pvscan --cache -aay -#check lv_field $vg1/$lv1 lv_active "active" -#lvchange -an $vg1 - -# like previous - _clear_online_files pvscan --cache "$dev1"
@@ -172,4 +169,39 @@ grep $lv2 tmp check lv_field $vg2/$lv2 lv_active "" --foreign +# Test the case where pvscan --cache -aay (with no devs) +# gets the final PV to complete the VG, where that final PV +# does not hold VG metadata. In this case it needs to rely +# on VG metadata that has been saved from a previously +# scanned PV from the same VG. +# +# We can't control which order of devices pvscan will see, +# so create several PVs without metadata surrounding one +# PV with metadata, to make it likely that pvscan will +# get a final PV without metadata. + +pvcreate --metadatacopies 0 "$dev4" +pvcreate --metadatacopies 0 "$dev5" +pvcreate --metadatacopies 1 "$dev6" +pvcreate --metadatacopies 0 "$dev7" +pvcreate --metadatacopies 0 "$dev8" +vgcreate $vg3 "$dev4" "$dev5" "$dev6" "$dev7" "$dev8" +lvcreate -n $lv1 -l 4 -a n $vg3 + +_clear_online_files + +check lv_field $vg3/$lv1 lv_active "" +pvscan --cache "$dev4" +check lv_field $vg3/$lv1 lv_active "" +pvscan --cache "$dev5" +check lv_field $vg3/$lv1 lv_active "" +pvscan --cache "$dev6" +check lv_field $vg3/$lv1 lv_active "" +pvscan --cache "$dev7" +check lv_field $vg3/$lv1 lv_active "" +pvscan --cache "$dev8" +check lv_field $vg3/$lv1 lv_active "" +pvscan --cache -aay +check lv_field $vg3/$lv1 lv_active "active" +lvchange -an $vg3
tools/pvscan.c +96 -3
145 lines not on this page · raw message