mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
pvscan: rework to improve PVs without metadata
Restructure the pvscan code, and add new temporary files that list pvids in a VG, used for processing PVs that have no metadata. The new temp files, in /run/lvm/pvs_lookup/<vgname>, allow a proper pvscan --cache to be done on PVs that have no metadata. pvscan --cache <dev> is only supposed to read <dev>, but when <dev> has no metadata, this had not been possible. The command had to fall back to scanning all devices to read all VG metadata to get the list of all PVIDs needed to check for a complete VG. Now, the temp file can be used in place of reading metadata from all PVs on the system.
This commit is contained in:
parent
a7f195b7e8
commit
f3b723cd8d
@ -330,7 +330,7 @@ rm $HINTS $PREV
|
||||
pvs
|
||||
cp $HINTS $PREV
|
||||
# this next pvscan creates newhints to trigger a refresh
|
||||
pvscan --cache "$dev5"
|
||||
pvscan --cache "$dev4"
|
||||
cat $NEWHINTS
|
||||
# this next pvs creates new hints
|
||||
pvs
|
||||
|
@ -297,20 +297,13 @@ vgchange -an $vg
|
||||
_clear_online_files
|
||||
|
||||
# pvscan of one dev with bad metadata will result
|
||||
# in the dev acting like a PV without metadata,
|
||||
# which causes pvscan to scan all devs to find the
|
||||
# VG it belongs to. In this case it finds all the
|
||||
# other devs in the VG are online and activates the
|
||||
# VG.
|
||||
# in the pvid online file being created but the
|
||||
# VG will not be known.
|
||||
pvscan --cache -aay "$dev1"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID1"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID2"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID3"
|
||||
ls "$RUNDIR/lvm/vgs_online/$vg"
|
||||
|
||||
lvs $vg
|
||||
check lv_field $vg/$lv1 lv_active "active"
|
||||
vgchange -an $vg
|
||||
not ls "$RUNDIR/lvm/pvs_online/$PVID2"
|
||||
not ls "$RUNDIR/lvm/pvs_online/$PVID3"
|
||||
not ls "$RUNDIR/lvm/vgs_online/$vg"
|
||||
|
||||
_clear_online_files
|
||||
|
||||
@ -321,18 +314,6 @@ not ls "$RUNDIR/lvm/pvs_online/$PVID2"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID3"
|
||||
not ls "$RUNDIR/lvm/vgs_online/$vg"
|
||||
|
||||
# scan the next pv with bad metadata, causes pvscan to scan
|
||||
# and find all PVs and activate
|
||||
pvscan --cache -aay "$dev2"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID1"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID2"
|
||||
ls "$RUNDIR/lvm/pvs_online/$PVID3"
|
||||
ls "$RUNDIR/lvm/vgs_online/$vg"
|
||||
|
||||
check lv_field $vg/$lv1 lv_active "active"
|
||||
vgchange -an $vg
|
||||
|
||||
|
||||
vgck --updatemetadata $vg
|
||||
|
||||
pvs 2>&1 | tee out
|
||||
|
@ -16,6 +16,7 @@ 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"
|
||||
|
||||
# FIXME: kills logic for running system
|
||||
_clear_online_files() {
|
||||
@ -23,6 +24,7 @@ _clear_online_files() {
|
||||
aux udev_wait
|
||||
rm -f "$PVS_ONLINE_DIR"/*
|
||||
rm -f "$VGS_ONLINE_DIR"/*
|
||||
rm -f "$PVS_LOOKUP_DIR"/*
|
||||
}
|
||||
|
||||
. lib/inittest
|
||||
@ -34,6 +36,7 @@ lvcreate -n $lv1 -l 4 -a n $vg1
|
||||
|
||||
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
|
||||
|
||||
# check pvscan with no args scans and activates all
|
||||
@ -93,12 +96,9 @@ pvscan --cache -aay "$dev1"
|
||||
check lv_field $vg1/$lv1 lv_active "active"
|
||||
lvchange -an $vg1
|
||||
|
||||
# test case where dev without metadata is scanned first
|
||||
# which triggers scanning all, which finds both
|
||||
|
||||
_clear_online_files
|
||||
pvscan --cache -aay "$dev1"
|
||||
check lv_field $vg1/$lv1 lv_active "active"
|
||||
check lv_field $vg1/$lv1 lv_active ""
|
||||
pvscan --cache -aay "$dev2"
|
||||
check lv_field $vg1/$lv1 lv_active "active"
|
||||
lvchange -an $vg1
|
||||
|
1358
tools/pvscan.c
1358
tools/pvscan.c
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user