summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WHATS_NEW2
-rw-r--r--tools/pvremove.c24
2 files changed, 24 insertions, 2 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index cce7f8e9f..cf570d834 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,6 @@
Version 2.02.40 -
================================
- Fix pvchange to handle PVs without mdas.
+ Fix pvchange and pvremove to handle PVs without mdas.
Refactor _text_pv_read and always return mda list if requested.
Fix configure to work w/o readline unless --enable-readline used. (2.02.39)
Remove is_lvm_partition template which has not yet been coded.
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 96290424f..acf598d6c 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -25,18 +25,40 @@ const char _really_wipe[] =
static int pvremove_check(struct cmd_context *cmd, const char *name)
{
struct physical_volume *pv;
+ struct list mdas;
+
+ list_init(&mdas);
/* FIXME Check partition type is LVM unless --force is given */
/* Is there a pv here already? */
/* If not, this is an error unless you used -f. */
- if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+ if (!(pv = pv_read(cmd, name, &mdas, NULL, 1))) {
if (arg_count(cmd, force_ARG))
return 1;
log_error("Physical Volume %s not found", 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) && !list_size(&mdas)) {
+ if (!scan_vgs_for_pvs(cmd)) {
+ log_error("Rescan for PVs without metadata areas "
+ "failed.");
+ return 0;
+ }
+ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+ log_error("Failed to read physical volume %s", name);
+ return 0;
+ }
+ }
+
/* orphan ? */
if (is_orphan(pv))
return 1;