Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cc9e683adcb6c563…
Commit: cc9e683adcb6c56332d708baf02dec63eba4fba9
Parent: 0000db7f98a07aa31c5b1cf13938b612e7f2821b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Feb 15 15:11:54 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 15 15:17:36 2016 +0100
toollib: skip PV if system ID is used and PV marked as used but metadata missing
If we know that a PV belongs to some VG and we're missing metadata
(because we have only those PV(s) from VG present in the system that
don't have metadata areas), we should skip such PV when processing
under system ID.
This is because we know that the PV belongs to some VG, but we
really can't decide whether it matches system ID unless the VG
metadata is present again.
---
WHATS_NEW | 1 +
tools/toollib.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 47eb735..48f2fb3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.143 -
=====================================
+ If PV belongs to some VG and metadata missing, skip it if system ID is used.
Automatically change PV header extension to latest version if writing PV/VG.
Identify used PVs in pv_attr field by new 'u' character.
Add pv_in_use reporting field to report if PV is used or not.
diff --git a/tools/toollib.c b/tools/toollib.c
index 7f8c2eb..1bdc113 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3067,6 +3067,12 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
pv = pvl->pv;
pv_name = pv_dev_name(pv);
+ if (cmd->system_id && is_orphan(pv) && is_used_pv(pv)) {
+ log_verbose("PV %s is belonging to a VG but its metadata is missing.", pv_name);
+ log_verbose("Skipping PV %s because it's not possible to decide whether it matches system id.", pv_name);
+ continue;
+ }
+
process_pv = process_all_pvs;
/* Remove each arg_devices entry as it is processed. */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0000db7f98a07aa3…
Commit: 0000db7f98a07aa31c5b1cf13938b612e7f2821b
Parent: abbaeef096251c4191e6da2518e646dd78b82da8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Feb 15 14:46:31 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 15 14:46:31 2016 +0100
pv: mark fake PVs as not used
Some of the PVs are not even orphan PVs - they're fake PVs - this can
happen if we're listing all devices with "pvs -a". Such PV must not
be marked as used.
---
lib/metadata/pv.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c
index 260eb9b..d5820b5 100644
--- a/lib/metadata/pv.c
+++ b/lib/metadata/pv.c
@@ -213,6 +213,9 @@ int is_used_pv(const struct physical_volume *pv)
struct lvmcache_info *info;
uint32_t ext_flags;
+ if (!pv->vg)
+ return 0;
+
if (!is_orphan(pv))
return 1;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=698e0eb851b28079…
Commit: 698e0eb851b280796e3fbe17fbe9a9158b6344c7
Parent: 8ad93874d63d67ea375b37b7014d782476dab88d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Feb 15 13:07:35 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 15 13:07:35 2016 +0100
WHATS_NEW: PV_EXT_USED flag and related
---
WHATS_NEW | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c7ffcf7..47eb735 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,10 @@
Version 2.02.143 -
=====================================
+ Automatically change PV header extension to latest version if writing PV/VG.
+ Identify used PVs in pv_attr field by new 'u' character.
+ Add pv_in_use reporting field to report if PV is used or not.
+ Add pv_ext_vsn reporting field to report PV header extension version.
+ Add protective flag marking PVs as used even if no metadata available.
Version 2.02.142 - 15th February 2016
=====================================
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4e25f4381284967…
Commit: a4e25f4381284967467a1103d67e3cdbdd2cdf82
Parent: 2f00d57e6f7e1066448f93af0b67a378da29a4d0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Apr 7 13:50:54 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 15 12:44:46 2016 +0100
tests: add pv-ext-flags.sh test
Testing PV extension flags. Currently, there's only one PV extension
flag present - the PV_EXT_USED flag (marking PV as used in a VG).
---
test/shell/pv-ext-flags.sh | 163 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 163 insertions(+), 0 deletions(-)
diff --git a/test/shell/pv-ext-flags.sh b/test/shell/pv-ext-flags.sh
new file mode 100644
index 0000000..072ec2c
--- /dev/null
+++ b/test/shell/pv-ext-flags.sh
@@ -0,0 +1,163 @@
+#!/bin/sh
+# Copyright (C) 2016 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
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_devs 2
+
+# PV_EXT_USED flag
+MARKED_AS_USED_MSG="marked as belonging to a VG but its metadata is missing"
+
+######################################
+### CHECK PV WITH 0 METADATA AREAS ###
+######################################
+
+pvcreate -ff -y --metadatacopies 0 "$dev1"
+pvcreate -ff -y --metadatacopies 1 "$dev2"
+
+# $dev1 and $dev2 not in any VG - pv_in_use field should be blank
+check pv_field "$dev1" pv_in_use ""
+check pv_field "$dev2" pv_in_use ""
+
+# $dev1 and $dev now in a VG - pv_in_use should display "used"
+vgcreate $vg1 "$dev1" "$dev2"
+check pv_field "$dev1" pv_in_use "used"
+check pv_field "$dev2" pv_in_use "used"
+
+# disable $dev2 and dev1 with 0 MDAs remains, but still
+# marked as used, so pvcreate/vgcreate/pvremove should fail
+aux disable_dev "$dev2"
+pvscan --cache
+
+check pv_field "$dev1" pv_in_use "used"
+not pvcreate "$dev1" 2>err
+cat err
+grep "$MARKED_AS_USED_MSG" err
+not pvchange -u "$dev1" 2>err
+grep "$MARKED_AS_USED_MSG" err
+not vgcreate $vg2 "$dev1" 2>err
+grep "$MARKED_AS_USED" err
+not pvremove "$dev1" 2>err
+grep "$MARKED_AS_USED_MSG" err
+
+# save PV signature from dev1 for reuse later on in this
+# test so we don't need to initialize all the VG stuff again
+dd if="$dev1" of=dev1_backup bs=1M
+
+# pvcreate and pvremove can be forced even if the PV is marked as used
+pvremove -ff "$dev1"
+dd if=dev1_backup of="$dev1" bs=1M
+pvcreate -ff "$dev1"
+dd if=dev1_backup of="$dev1" bs=1M
+
+# prepare a VG with $dev1 and $dev both having 1 MDA
+aux enable_dev "$dev2"
+vgremove -ff $vg1
+pvcreate --metadatacopies 1 "$dev1"
+vgcreate $vg1 "$dev1" "$dev2"
+
+# disable $dev1, then repair the VG - $dev1 is removed from VG
+aux disable_dev "$dev1"
+vgreduce --removemissing $vg1
+# now, enable $dev1, automatic repair will happen on pvs call
+# (or any other lvm command that does vg_read with repair inside)
+aux enable_dev "$dev1"
+
+# FIXME: once persistent cache does not cause races with timestamps
+# causing LVM tools to not see the VG inconsistency and once
+# VG repair is always done, delete this line which removes
+# persistent .cache as a workaround
+rm -f $TESTDIR/etc/.cache
+
+vgck $vg1
+# check $dev1 does not contain the PV_EXT_FLAG anymore - it
+# should be removed as part of the repaid during vg_read since
+# $dev1 is not part of $vg1 anymore
+check pv_field "$dev1" pv_in_use ""
+
+#############################################
+### CHECK PV WITH DISABLED METADATA AREAS ###
+#############################################
+
+pvcreate -ff -y --metadatacopies 1 "$dev1"
+pvcreate -ff -y --metadatacopies 1 "$dev2"
+
+# $dev1 and $dev2 not in any VG - pv_in_use field should be blank
+check pv_field "$dev1" pv_in_use ""
+check pv_field "$dev2" pv_in_use ""
+
+# $dev1 and $dev now in a VG - pv_in_use should display "used"
+vgcreate $vg1 "$dev1" "$dev2"
+check pv_field "$dev1" pv_in_use "used"
+check pv_field "$dev2" pv_in_use "used"
+
+pvchange --metadataignore y "$dev1"
+aux disable_dev "$dev2"
+pvscan --cache
+
+check pv_field "$dev1" pv_in_use "used"
+not pvcreate "$dev1" 2>err
+grep "$MARKED_AS_USED_MSG" err
+not pvchange -u "$dev1" 2>err
+grep "$MARKED_AS_USED_MSG" err
+not vgcreate $vg2 "$dev1" 2>err
+grep "$MARKED_AS_USED" err
+not pvremove "$dev1" 2>err
+grep "$MARKED_AS_USED_MSG" err
+
+# save PV signature from dev1 for reuse later on in this
+# test so we don't need to initialize all the VG stuff again
+dd if="$dev1" of=dev1_backup bs=1M
+
+# pvcreate and pvremove can be forced even if the PV is marked as used
+pvremove -ff "$dev1"
+dd if=dev1_backup of="$dev1" bs=1M
+pvcreate -ff "$dev1"
+dd if=dev1_backup of="$dev1" bs=1M
+
+# prepare a VG with $dev1 and $dev both having 1 MDA
+aux enable_dev "$dev2"
+vgremove -ff $vg1
+pvcreate --metadatacopies 1 "$dev1"
+vgcreate $vg1 "$dev1" "$dev2"
+
+# disable $dev1, then repair the VG - $dev1 is removed from VG
+aux disable_dev "$dev1"
+vgreduce --removemissing $vg1
+# now, enable $dev1, automatic repair will happen on pvs call
+# (or any other lvm command that does vg_read with repair inside)
+aux enable_dev "$dev1"
+
+# FIXME: once persistent cache does not cause races with timestamps
+# causing LVM tools to not see the VG inconsistency and once
+# VG repair is always done, delete this line which removes
+# persistent .cache as a workaround
+rm -f $TESTDIR/etc/.cache
+
+vgck $vg1
+# check $dev1 does not contain the PV_EXT_FLAG anymore - it
+# should be removed as part of the repaid during vg_read since
+# $dev1 is not part of $vg1 anymore
+check pv_field "$dev1" pv_in_use ""
+
+###########################
+# OTHER PV-RELATED CHECKS #
+###########################
+
+# vgcfgrestore should also set PV_EXT_FLAG on PVs where VG is restored
+vgcfgbackup -f vg_backup $vg1
+check pv_field "$dev2" pv_in_use "used"
+vgremove -ff $vg1
+check pv_field "$dev2" pv_in_use ""
+vgcfgrestore -f vg_backup $vg1
+check pv_field "$dev2" pv_in_use "used"