master - metadata: Fix handling of orphan PV linking & re-linking.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ba6d6f002837d0...
Commit: ba6d6f002837d0fa2f27ad3660cfde7887870401
Parent: 651d5093edde3e0ebee9d75be1c9834efc152d91
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 03:13:59 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:27 2013 +0100
metadata: Fix handling of orphan PV linking & re-linking.
---
lib/metadata/metadata.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index b67d596..fa480c8 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -269,6 +269,12 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
vg->extent_count += pv->pe_count;
vg->free_count += pv->pe_count;
+ dm_list_iterate_items(pvl, &fid->fmt->orphan_vg->pvs)
+ if (pv == pvl->pv) { /* unlink from orphan */
+ dm_list_del(&pvl->list);
+ break;
+ }
+
if (pv->status & UNLABELLED_PV) {
if (!(pvc = dm_pool_zalloc(mem, sizeof(*pvc)))) {
log_error("pv_to_create allocation for '%s' failed", pv_name);
@@ -2810,8 +2816,10 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
struct lvmcache_vginfo *vginfo;
struct volume_group *vg = NULL;
struct _vg_read_orphan_baton baton;
- struct pv_list *pvl;
+ struct pv_list *pvl, *pvl_;
+ struct pv_list head;
+ dm_list_init(&head.list);
lvmcache_label_scan(cmd, 0);
lvmcache_seed_infos_from_lvmetad(cmd);
@@ -2822,14 +2830,31 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
return_NULL;
vg = fmt->orphan_vg;
- dm_list_iterate_items(pvl, &vg->pvs)
- pv_set_fid(pvl->pv, NULL);
+restart:
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (pvl->pv->status & UNLABELLED_PV ) {
+ dm_list_del(&pvl->list);
+ dm_list_add(&head.list, &pvl->list);
+ goto restart;
+ } else
+ pv_set_fid(pvl->pv, NULL);
+ }
dm_list_init(&vg->pvs);
vg->pv_count = 0;
+ vg->extent_count = 0;
+ vg->free_count = 0;
baton.warnings = warnings;
baton.vg = vg;
+ while (!dm_list_empty(&head.list)) {
+ pvl = (struct pv_list *) dm_list_first(&head.list);
+ dm_list_del(&pvl->list);
+ add_pvl_to_vgs(vg, pvl);
+ vg->extent_count += pvl->pv->pe_count;
+ vg->free_count += pvl->pv->pe_count;
+ }
+
if (!lvmcache_foreach_pv(vginfo, _vg_read_orphan_pv, &baton))
return_NULL;
10 years, 5 months
master - metadata: Avoid pv_read in find_pv_by_name.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=651d5093edde3e...
Commit: 651d5093edde3e0ebee9d75be1c9834efc152d91
Parent: 2f5c12e3a88f6bc028e8355c58b6b2c89da301e7
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 02:32:25 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:27 2013 +0100
metadata: Avoid pv_read in find_pv_by_name.
---
lib/metadata/metadata.c | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 869d368..b67d596 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1330,7 +1330,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
/* FIXME Check partition type is LVM unless --force is given */
/* Is there a pv here already? */
- if (!(pv = pv_read(cmd, name, 0, 0)))
+ if (!(pv = find_pv_by_name(cmd, name, 1)))
stack;
/*
@@ -1824,23 +1824,29 @@ struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
const char *pv_name,
int allow_orphan)
{
- struct physical_volume *pv;
+ struct device *dev;
+ struct pv_list *pvl;
+ struct dm_list *pvslist;
+ struct physical_volume *pv = NULL;
+
+ lvmcache_seed_infos_from_lvmetad(cmd);
- if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) {
+ if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
log_error("Physical volume %s not found", pv_name);
- goto bad;
+ return_NULL;
}
- if (is_orphan_vg(pv->vg_name) && dm_list_empty(&pv->fid->metadata_areas_in_use)) {
- /* If a PV has no MDAs - need to search all VGs for it */
- if (!scan_vgs_for_pvs(cmd, 1))
- goto_bad;
- free_pv_fid(pv);
- if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) {
- log_error("Physical volume %s not found", pv_name);
- goto bad;
- }
- }
+ if (!(pvslist = get_pvs(cmd)))
+ return_NULL;
+
+ dm_list_iterate_items(pvl, pvslist)
+ if (pvl->pv->dev == dev)
+ pv = pvl->pv;
+ else
+ free_pv_fid(pvl->pv);
+
+ if (!pv)
+ log_error("Physical volume %s not found", pv_name);
if (pv && !allow_orphan && is_orphan_vg(pv->vg_name)) {
log_error("Physical volume %s not in a volume group", pv_name);
10 years, 5 months
master - pvremove: Avoid using pv_read in favour of scanning.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2f5c12e3a88f6b...
Commit: 2f5c12e3a88f6bc028e8355c58b6b2c89da301e7
Parent: fc02f241789824877d604ca40a56ab6487d7212a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 02:14:51 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:27 2013 +0100
pvremove: Avoid using pv_read in favour of scanning.
---
lib/metadata/pv_manip.c | 76 ++++++++++++++++++++++++----------------------
1 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index b7a4b43..bee7972 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -652,59 +652,63 @@ const char _really_wipe[] =
static int pvremove_check(struct cmd_context *cmd, const char *name,
unsigned force_count, unsigned prompt)
{
- struct physical_volume *pv;
+ struct device *dev;
+ struct label *label;
+ struct pv_list *pvl;
+ struct dm_list *pvslist;
+
+ struct physical_volume *pv = NULL;
+ int r = 0;
/* FIXME Check partition type is LVM unless --force is given */
+ if (!(dev = dev_cache_get(name, cmd->filter))) {
+ log_error("Device %s not found", name);
+ return 0;
+ }
+
/* Is there a pv here already? */
/* If not, this is an error unless you used -f. */
- if (!(pv = pv_read(cmd, name, 1, 0))) {
+ if (!label_read(dev, &label, 0)) {
if (force_count)
return 1;
- log_error("Physical Volume %s not found", name);
+ log_error("No PV label found on %s.", name);
return 0;
}
- /*
- * If a PV has no MDAs it may appear to be an
- * orphan until the metadata is read off
- * another PV in the same VG. Detecting this
- * means checking every VG by scanning every
- * PV on the system.
- */
- if (is_orphan(pv) && dm_list_empty(&pv->fid->metadata_areas_in_use) &&
- dm_list_empty(&pv->fid->metadata_areas_ignored)) {
- if (!scan_vgs_for_pvs(cmd, 0)) {
- log_error("Rescan for PVs without metadata areas "
- "failed.");
- goto bad;
- }
- free_pv_fid(pv);
- if (!(pv = pv_read(cmd, name, 1, 0))) {
- log_error("Failed to read physical volume %s", name);
- goto bad;
- }
+ lvmcache_seed_infos_from_lvmetad(cmd);
+ if (!(pvslist = get_pvs(cmd)))
+ return_0;
+
+ dm_list_iterate_items(pvl, pvslist)
+ if (pvl->pv->dev == dev)
+ pv = pvl->pv;
+
+ if (!pv) {
+ log_error(INTERNAL_ERROR "Physical Volume %s has a label,"
+ " but is neither in a VG nor orphan.", name);
+ goto out; /* better safe than sorry */
}
- /* orphan ? */
if (is_orphan(pv)) {
- free_pv_fid(pv);
- return 1;
+ r = 1;
+ goto out;
}
- /* Allow partial & exported VGs to be destroyed. */
/* we must have -ff to overwrite a non orphan */
if (force_count < 2) {
log_error("PV %s belongs to Volume Group %s so please use vgreduce first.", name, pv_vg_name(pv));
log_error("(If you are certain you need pvremove, then confirm by using --force twice.)");
- goto bad;
+ goto out;
}
/* prompt */
if (!prompt &&
- yes_no_prompt(_really_wipe, name, pv_vg_name(pv)) == 'n') {
+ yes_no_prompt("Really WIPE LABELS from physical volume \"%s\" "
+ "of volume group \"%s\" [y/n]? ",
+ name, pv_vg_name(pv)) == 'n') {
log_error("%s: physical volume label not removed", name);
- goto bad;
+ goto out;
}
if (force_count) {
@@ -715,17 +719,17 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
!is_orphan(pv) ? "\"" : "");
}
- free_pv_fid(pv);
- return 1;
-
-bad:
- free_pv_fid(pv);
- return 0;
+ r = 1;
+out:
+ if (pvslist)
+ dm_list_iterate_items(pvl, pvslist)
+ free_pv_fid(pvl->pv);
+ return r;
}
int pvremove_single(struct cmd_context *cmd, const char *pv_name,
void *handle __attribute__((unused)), unsigned force_count,
- unsigned prompt)
+ unsigned prompt)
{
struct device *dev;
int r = 0;
10 years, 5 months
master - test: Fix fallout from pv_read changes.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fc02f241789824...
Commit: fc02f241789824877d604ca40a56ab6487d7212a
Parent: 603b45e0ed1032875f587eda3391c47b6652303c
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 01:56:51 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:27 2013 +0100
test: Fix fallout from pv_read changes.
---
test/shell/pv-duplicate.sh | 2 +-
test/shell/pvcreate-operation-md.sh | 35 +++++++++++++++++++++--------------
2 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/test/shell/pv-duplicate.sh b/test/shell/pv-duplicate.sh
index 6b9f309..40d1f68 100644
--- a/test/shell/pv-duplicate.sh
+++ b/test/shell/pv-duplicate.sh
@@ -21,5 +21,5 @@ vgcreate --metadatasize 128k $vg1 "$dev1"
dd if="$dev1" of="$dev2" bs=256K count=1
dd if="$dev1" of="$dev3" bs=256K count=1
-pvs "$dev1"
+pvs "$dev3"
vgs $vg1
diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh
index 5e2a28d..9cad745 100644
--- a/test/shell/pvcreate-operation-md.sh
+++ b/test/shell/pvcreate-operation-md.sh
@@ -58,21 +58,24 @@ test -b "$mddev" && skip
mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 64 "$dev1" "$dev2"
trap 'cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test
test -b "$mddev" || skip
+cp -LR "$mddev" "$DM_DEV_DIR" # so that LVM/DM can see the device
+lvmdev="$DM_DEV_DIR/md_lvm_test0"
# Test alignment of PV on MD without any MD-aware or topology-aware detection
# - should treat $mddev just like any other block device
pv_align="1.00m"
pvcreate --metadatasize 128k \
--config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \
- "$mddev"
-check pv_field "$mddev" pe_start $pv_align
+ "$lvmdev"
+
+check pv_field "$lvmdev" pe_start $pv_align
# Test md_chunk_alignment independent of topology-aware detection
pv_align="1.00m"
pvcreate --metadatasize 128k \
--config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \
- "$mddev"
-check pv_field "$mddev" pe_start $pv_align
+ "$lvmdev"
+check pv_field "$lvmdev" pe_start $pv_align
# Test newer topology-aware alignment detection
@@ -81,8 +84,8 @@ if kernel_at_least 2 6 33 ; then
pv_align="1.00m"
# optimal_io_size=131072, minimum_io_size=65536
pvcreate --metadatasize 128k \
- --config 'devices { md_chunk_alignment=0 }' "$mddev"
- check pv_field "$mddev" pe_start $pv_align
+ --config 'devices { md_chunk_alignment=0 }' "$lvmdev"
+ check pv_field "$lvmdev" pe_start $pv_align
fi
# partition MD array directly, depends on blkext in Linux >= 2.6.28
@@ -91,9 +94,10 @@ if kernel_at_least 2 6 28 ; then
sfdisk "$mddev" <<EOF
,,83
EOF
+ pvscan
# make sure partition on MD is _not_ removed
# - tests partition -> parent lookup via sysfs paths
- not pvcreate --metadatasize 128k "$mddev"
+ not pvcreate --metadatasize 128k "$lvmdev"
# verify alignment_offset is accounted for in pe_start
# - topology infrastructure is available in Linux >= 2.6.31
@@ -109,6 +113,8 @@ EOF
# wait here for created device node on tmpfs
aux udev_wait "$mddev_p"
test -b "$mddev_p" || skip
+ cp -LR "$mddev_p" "$DM_DEV_DIR"
+ lvmdev_p="$DM_DEV_DIR/$base_mddev_p"
# Checking for 'alignment_offset' in sysfs implies Linux >= 2.6.31
# but reliable alignment_offset support requires kernel.org Linux >= 2.6.33
@@ -120,9 +126,9 @@ EOF
if [ $alignment_offset -gt 0 ]; then
# default alignment is 1M, add alignment_offset
pv_align=$((1048576+$alignment_offset))B
- pvcreate --metadatasize 128k "$mddev_p"
- check pv_field "$mddev_p" pe_start $pv_align --units b
- pvremove "$mddev_p"
+ pvcreate --metadatasize 128k "$lvmdev_p"
+ check pv_field "$lvmdev_p" pe_start $pv_align --units b
+ pvremove "$lvmdev_p"
fi
fi
@@ -140,12 +146,13 @@ if kernel_at_least 2 6 33 ; then
# optimal_io_size=2097152, minimum_io_size=1048576
pv_align="2.00m"
pvcreate --metadatasize 128k \
- --config 'devices { md_chunk_alignment=0 }' "$mddev"
- check pv_field "$mddev" pe_start $pv_align
+ --config 'devices { md_chunk_alignment=0 }' "$lvmdev"
+ pvscan # Something is seriously broken.
+ check pv_field "$lvmdev" pe_start $pv_align
# now verify pe_start alignment override using --dataalignment
pv_align="192.00k"
pvcreate --dataalignment 64k --metadatasize 128k \
- --config 'devices { md_chunk_alignment=0 }' "$mddev"
- check pv_field "$mddev" pe_start $pv_align
+ --config 'devices { md_chunk_alignment=0 }' "$lvmdev"
+ check pv_field "$lvmdev" pe_start $pv_align
fi
10 years, 5 months
master - pvresize: Do not use pv_read (get the PV from orphan VG).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=603b45e0ed1032...
Commit: 603b45e0ed1032875f587eda3391c47b6652303c
Parent: 0a59305c44e992831d66da50f5058f154a795d3a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 01:54:34 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:27 2013 +0100
pvresize: Do not use pv_read (get the PV from orphan VG).
---
lib/metadata/pv_manip.c | 51 ++++++++++++++++------------------------------
1 files changed, 18 insertions(+), 33 deletions(-)
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index fb29ef4..b7a4b43 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -549,9 +549,9 @@ static int pv_resize(struct physical_volume *pv,
}
int pv_resize_single(struct cmd_context *cmd,
- struct volume_group *vg,
- struct physical_volume *pv,
- const uint64_t new_size)
+ struct volume_group *vg,
+ struct physical_volume *pv,
+ const uint64_t new_size)
{
struct pv_list *pvl;
uint64_t size = 0;
@@ -561,38 +561,25 @@ int pv_resize_single(struct cmd_context *cmd,
struct volume_group *old_vg = vg;
int vg_needs_pv_write = 0;
- if (is_orphan_vg(vg_name)) {
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
- log_error("Can't get lock for orphans");
- return 0;
- }
-
- if (!(pv = pv_read(cmd, pv_name, 1, 0))) {
- unlock_vg(cmd, vg_name);
- log_error("Unable to read PV \"%s\"", pv_name);
- return 0;
- }
- } else {
- vg = vg_read_for_update(cmd, vg_name, NULL, 0);
+ vg = vg_read_for_update(cmd, vg_name, NULL, 0);
- if (vg_read_error(vg)) {
- release_vg(vg);
- log_error("Unable to read volume group \"%s\".",
- vg_name);
- return 0;
- }
+ if (vg_read_error(vg)) {
+ release_vg(vg);
+ log_error("Unable to read volume group \"%s\".",
+ vg_name);
+ return 0;
+ }
- if (!(pvl = find_pv_in_vg(vg, pv_name))) {
- log_error("Unable to find \"%s\" in volume group \"%s\"",
- pv_name, vg->name);
- goto out;
- }
+ if (!(pvl = find_pv_in_vg(vg, pv_name))) {
+ log_error("Unable to find \"%s\" in volume group \"%s\"",
+ pv_name, vg->name);
+ goto out;
+ }
- pv = pvl->pv;
+ pv = pvl->pv;
- if (!archive(vg))
- goto out;
- }
+ if (!archive(vg))
+ goto out;
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
log_error("Physical volume %s format does not support resizing.",
@@ -650,8 +637,6 @@ out:
log_error("Use pvcreate and vgcfgrestore "
"to repair from archived metadata.");
unlock_vg(cmd, vg_name);
- if (is_orphan_vg(vg_name))
- free_pv_fid(pv);
if (!old_vg)
release_vg(vg);
return r;
10 years, 5 months
master - test: Add a test for the failing pv_read optimisation.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0a59305c44e992...
Commit: 0a59305c44e992831d66da50f5058f154a795d3a
Parent: 7e685e6c70e5b738e5740b920e6080b9a13c2556
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jun 11 09:13:39 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:26 2013 +0100
test: Add a test for the failing pv_read optimisation.
---
test/shell/mda-rollback.sh | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/test/shell/mda-rollback.sh b/test/shell/mda-rollback.sh
new file mode 100644
index 0000000..d47eb8a
--- /dev/null
+++ b/test/shell/mda-rollback.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/test
+
+aux prepare_devs 3
+
+vgcreate --metadatasize 128k $vg1 "$dev1" "$dev2" "$dev3"
+
+vgreduce $vg1 $dev1
+dd if="$dev1" of=badmda bs=256K count=1
+vgextend $vg1 $dev1
+
+dd if=badmda of="$dev1" bs=256K count=1
+
+# dev1 is part of vg1 (as witnessed by metadata on dev2 and dev3), but its mda
+# was corrupt (written over by a backup from time dev1 was an orphan)
+check pv_field $dev1 vg_name $vg1
10 years, 5 months
master - toollib: Drop the pv_read optimisation.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7e685e6c70e5b7...
Commit: 7e685e6c70e5b738e5740b920e6080b9a13c2556
Parent: e1a63905d14cc73352b905c70cb4084b7e521e33
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 00:12:30 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:26 2013 +0100
toollib: Drop the pv_read optimisation.
Only reading a single PV works correctly only in very limited circumstances.
Moreover, we can't rely on the MDA available on the PV either, since it may be
out of date in some circumstances (until now, we believed that PVs that have an
empty MDA are always orphans, but this is not 100% reliable either).
---
tools/toollib.c | 93 +++++++++++++++++++++++++++----------------------------
1 files changed, 46 insertions(+), 47 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index bc8b33c..127dd66 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -744,6 +744,8 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
static int _process_all_devs(struct cmd_context *cmd, void *handle,
process_single_pv_fn_t process_single_pv)
{
+ struct pv_list *pvl;
+ struct dm_list *pvslist;
struct physical_volume *pv;
struct physical_volume pv_dummy;
struct dev_iter *iter;
@@ -752,7 +754,8 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
int ret_max = ECMD_PROCESSED;
int ret;
- if (!scan_vgs_for_pvs(cmd, 1))
+ lvmcache_seed_infos_from_lvmetad(cmd);
+ if (!(pvslist = get_pvs(cmd)))
return_ECMD_FAILED;
if (!(iter = dev_iter_create(cmd->filter, 1))) {
@@ -760,20 +763,28 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
return ECMD_FAILED;
}
- while ((dev = dev_iter_get(iter))) {
+ while ((dev = dev_iter_get(iter)))
+ {
if (sigint_caught()) {
ret_max = ECMD_FAILED;
stack;
break;
}
- if (!(pv = pv_read(cmd, dev_name(dev), 0, 0))) {
- memset(&pv_dummy, 0, sizeof(pv_dummy));
- dm_list_init(&pv_dummy.tags);
- dm_list_init(&pv_dummy.segments);
- pv_dummy.dev = dev;
- pv = &pv_dummy;
- }
+ memset(&pv_dummy, 0, sizeof(pv_dummy));
+ dm_list_init(&pv_dummy.tags);
+ dm_list_init(&pv_dummy.segments);
+ pv_dummy.dev = dev;
+ pv = &pv_dummy;
+
+ /* TODO use a device-indexed hash here */
+ dm_list_iterate_items(pvl, pvslist)
+ if (pvl->pv->dev == dev)
+ pv = pvl->pv;
+
+ ret = process_single_pv(cmd, NULL, pv, handle);
+
+ free_pv_fid(pv);
ret = process_single_pv(cmd, NULL, pv, handle);
if (ret > ret_max)
@@ -804,11 +815,11 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
struct pv_list *pvl;
struct physical_volume *pv;
- struct dm_list *pvslist, *vgnames;
+ struct dm_list *pvslist = NULL, *vgnames;
struct dm_list tags;
struct str_list *sll;
char *at_sign, *tagname;
- int scanned = 0;
+ struct device *dev;
dm_list_init(&tags);
@@ -854,52 +865,36 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
}
pv = pvl->pv;
} else {
- if (!(pv = pv_read(cmd, argv[opt],
- 1, scan_label_only))) {
- log_error("Failed to read physical "
- "volume \"%s\"", argv[opt]);
+ if (!pvslist) {
+ lvmcache_seed_infos_from_lvmetad(cmd);
+ if (!(pvslist = get_pvs(cmd)))
+ goto bad;
+ }
+
+ if (!(dev = dev_cache_get(argv[opt], cmd->filter))) {
+ log_error("Failed to find device "
+ "\"%s\"", argv[opt]);
ret_max = ECMD_FAILED;
continue;
}
- /*
- * If a PV has no MDAs it may appear to be an
- * orphan until the metadata is read off
- * another PV in the same VG. Detecting this
- * means checking every VG by scanning every
- * PV on the system.
- */
- if (!scanned && is_orphan(pv) &&
- dm_list_empty(&pv->fid->metadata_areas_in_use)) {
- if (!scan_label_only &&
- !scan_vgs_for_pvs(cmd, 1)) {
- stack;
- ret_max = ECMD_FAILED;
- continue;
- }
- scanned = 1;
- free_pv_fid(pv);
- if (!(pv = pv_read(cmd, argv[opt],
- 1,
- scan_label_only))) {
- log_error("Failed to read "
- "physical volume "
- "\"%s\"", argv[opt]);
- ret_max = ECMD_FAILED;
- continue;
- }
+ pv = NULL;
+ dm_list_iterate_items(pvl, pvslist)
+ if (pvl->pv->dev == dev)
+ pv = pvl->pv;
+
+ if (!pv) {
+ log_error("Failed to find physical volume "
+ "\"%s\"", argv[opt]);
+ ret_max = ECMD_FAILED;
+ continue;
}
}
ret = process_single_pv(cmd, vg, pv, handle);
+
if (ret > ret_max)
ret_max = ret;
- /*
- * Free PV only if we called pv_read before,
- * otherwise the PV structure is part of the VG.
- */
- if (!vg)
- free_pv_fid(pv);
}
if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 1)) &&
!dm_list_empty(vgnames)) {
@@ -954,6 +949,10 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
}
}
out:
+ if (pvslist)
+ dm_list_iterate_items(pvl, pvslist)
+ free_pv_fid(pvl->pv);
+
if (lock_global)
unlock_vg(cmd, VG_GLOBAL);
return ret_max;
10 years, 5 months
master - metadata: Do not try to check vg_name of a NULL PV.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e1a63905d14cc7...
Commit: e1a63905d14cc73352b905c70cb4084b7e521e33
Parent: 803f8ca7146c548c271c04d432a3c68726a0d37d
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Mar 20 14:34:05 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:26 2013 +0100
metadata: Do not try to check vg_name of a NULL PV.
---
lib/metadata/metadata.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 8571e0a..869d368 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1842,7 +1842,7 @@ struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
}
}
- if (!allow_orphan && is_orphan_vg(pv->vg_name)) {
+ if (pv && !allow_orphan && is_orphan_vg(pv->vg_name)) {
log_error("Physical volume %s not in a volume group", pv_name);
goto bad;
}
10 years, 5 months
master - tests: used -n for fsck
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=803f8ca7146c54...
Commit: 803f8ca7146c548c271c04d432a3c68726a0d37d
Parent: 3716e9535455c5fb012511f820d0525e4aa48bc8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 11 17:19:26 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 15 12:38:37 2013 +0100
tests: used -n for fsck
---
test/shell/lvcreate-thin-snap.sh | 4 ++--
test/shell/lvcreate-thin.sh | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh
index a223469..b7511e7 100644
--- a/test/shell/lvcreate-thin-snap.sh
+++ b/test/shell/lvcreate-thin-snap.sh
@@ -37,7 +37,7 @@ mkfs.ext4 $DM_DEV_DIR/$vg/$lv1
# create thin snapshot of thin LV
lvcreate -K -s $vg/$lv1 --name snap
# check snapshot filesystem was properly frozen before snapping
-fsck -p $DM_DEV_DIR/$vg/snap
+fsck -n $DM_DEV_DIR/$vg/snap
lvcreate -K -s $vg/$lv1 --name $lv2
lvcreate -K -s $vg/$lv1 --name $vg/$lv3
lvcreate --type snapshot $vg/$lv1
@@ -59,6 +59,6 @@ lvremove -ff $vg
lvcreate -L10M --zero n -T $vg/pool -V10M --name $lv1
mkfs.ext4 $DM_DEV_DIR/$vg/$lv1
lvcreate -K -s $vg/$lv1 --name snap
-fsck -p $DM_DEV_DIR/$vg/snap
+fsck -n $DM_DEV_DIR/$vg/snap
vgremove -ff $vg
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index d2e3022..98ab7eb 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -138,7 +138,7 @@ check vg_field $vg lv_count 0
lvcreate -L10M -V10M -T $vg/pool --name lv1
mkfs.ext4 $DM_DEV_DIR/$vg/lv1
lvcreate -K -s $vg/lv1 --name snap_lv1
-fsck -p $DM_DEV_DIR/$vg/snap_lv1
+fsck -n $DM_DEV_DIR/$vg/snap_lv1
lvcreate -s $vg/lv1 --name lv2
lvcreate -s $vg/lv1 --name $vg/lv3
lvcreate --type snapshot $vg/lv1 --name lv6
10 years, 5 months
master - tests: indent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3716e9535455c5...
Commit: 3716e9535455c5fb012511f820d0525e4aa48bc8
Parent: 89a8c7bea6df1d52818837f5a6778d7ae3e9626c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 4 15:06:55 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 15 12:38:37 2013 +0100
tests: indent
---
test/api/vglist.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/api/vglist.c b/test/api/vglist.c
index 3d23369..01f52ec 100644
--- a/test/api/vglist.c
+++ b/test/api/vglist.c
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
lvm_str_list_t *str;
int i = 0;
struct dm_list *vgnames;
- struct dm_list *vgids;
+ struct dm_list *vgids;
if (argc != 3)
abort();
10 years, 5 months