diff options
author | Alasdair Kergon <agk@redhat.com> | 2008-07-31 12:38:31 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2008-07-31 12:38:31 +0000 |
commit | 32a478cb1fb4e67da8be53e6c94c5c1c40c707bd (patch) | |
tree | 8b63f3709c2d49d2485cc7a87b80499def2c37fd /tools/pvremove.c | |
parent | 1b8b624661a874847cbe6ce8b53f3211938a9426 (diff) | |
download | lvm2-32a478cb1fb4e67da8be53e6c94c5c1c40c707bd.tar.gz lvm2-32a478cb1fb4e67da8be53e6c94c5c1c40c707bd.tar.xz lvm2-32a478cb1fb4e67da8be53e6c94c5c1c40c707bd.zip |
fix pvremove for pvs without mdas
Diffstat (limited to 'tools/pvremove.c')
-rw-r--r-- | tools/pvremove.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/pvremove.c b/tools/pvremove.c index 96290424..acf598d6 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; |