master - pvscan: fix ignoring foreign PVs
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d84134c75bf2f5e9d289da73f68a57d43f5976c3 Commit: d84134c75bf2f5e9d289da73f68a57d43f5976c3 Parent: 9b2b0fef9c6c475a2023b9e5ca9525d850aed1cc Author: David Teigland <[email protected]> AuthorDate: Wed Mar 13 16:03:02 2019 -0500 Committer: David Teigland <[email protected]> CommitterDate: Wed Mar 13 16:03:02 2019 -0500
pvscan: fix ignoring foreign PVs
Fix to previous commit
"pvscan: ignore online for shared and foreign PVs"
which was incorrectly considering a PV foreign if its VG had no system ID when the host did have a system ID.
--- test/shell/pvscan-autoactivate.sh | 27 ++++++++++++++++++++++++--- tools/pvscan.c | 7 ++++++- 2 files changed, 30 insertions(+), 4 deletions(-)
test/shell/pvscan-autoactivate.sh +24 -3
@@ -154,6 +154,7 @@ pvscan --cache -aay "$dev2" check lv_field $vg1/$lv1 lv_active "active" lvchange -an $vg1 +vgremove -f $vg1 # pvscan cache ignores pv that's not used
@@ -174,17 +175,37 @@ not ls "$RUNDIR/lvm/pvs_online/$PVID3" aux lvmconf "global/system_id_source = uname" +_clear_online_files + vgcreate $vg2 "$dev3" -lvcreate -an -n $lv1 -l1 $vg2 +lvcreate -an -n $lv2 -l1 $vg2 pvscan --cache -aay "$dev3" ls "$RUNDIR/lvm/pvs_online/$PVID3" -check lv_field $vg2/$lv1 lv_active "active" +check lv_field $vg2/$lv2 lv_active "active" lvchange -an $vg2 rm "$RUNDIR/lvm/pvs_online/$PVID3" +# a vg without a system id is not foreign, not ignored +vgchange -y --systemid "" "$vg2" + +_clear_online_files +pvscan --cache -aay "$dev3" +ls "$RUNDIR/lvm/pvs_online/$PVID3" +check lv_field $vg2/$lv2 lv_active "active" +lvchange -an $vg2 +rm "$RUNDIR/lvm/pvs_online/$PVID3" + +# make the vg foreign by assigning a system id different from ours vgchange -y --systemid "asdf" "$vg2" +_clear_online_files + pvscan --cache -aay "$dev3" not ls "$RUNDIR/lvm/pvs_online/$PVID3" -check lv_field $vg2/$lv1 lv_active "" --foreign +lvs --foreign $vg2 > tmp +cat tmp +grep $lv2 tmp +check lv_field $vg2/$lv2 lv_active "" --foreign + +
tools/pvscan.c +6 -1
@@ -702,7 +702,12 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,return 1 ; } -if (baton.vg &&vg_is_foreign (baton.vg)) { +if (baton.vg && + baton.vg->system_id && baton.vg->system_id[0 ] && + cmd->system_id && cmd->system_id[0 ] && +vg_is_foreign (baton.vg)) { +log_verbose ("Ignore PV %s with VG system id %s with our system id %s" , +dev_name (dev), baton.vg->system_id, cmd->system_id);log_print ("pvscan[%d] PV %s ignore foreign VG." ,getpid (),dev_name (dev));release_vg (baton.vg);return 1 ;