summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2008-01-16 18:15:26 +0000
committerAlasdair Kergon <agk@redhat.com>2008-01-16 18:15:26 +0000
commitfb3226a3ed273e468b17786b33709b287e5f4ea7 (patch)
tree1c9c7853e1c8f775d40afcdcfcaf904a428d1539 /tools
parent6ab424acda10dbe8f530add210e59ab4a1595d2c (diff)
downloadlvm2-fb3226a3ed273e468b17786b33709b287e5f4ea7.tar.gz
lvm2-fb3226a3ed273e468b17786b33709b287e5f4ea7.tar.xz
lvm2-fb3226a3ed273e468b17786b33709b287e5f4ea7.zip
use scan_vgs_for_pvs to detect non-orphans without MDAs
Diffstat (limited to 'tools')
-rw-r--r--tools/lvmcmdline.c1
-rw-r--r--tools/pvcreate.c3
-rw-r--r--tools/pvdisplay.c2
-rw-r--r--tools/toollib.c25
4 files changed, 28 insertions, 3 deletions
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 99a406fb..8c74c5a5 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -584,7 +584,6 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
a->ui64_value = 0;
}
- memset(str, 0, sizeof(str));
/* fill in the short and long opts */
for (i = 0; i < cmd->command->num_args; i++)
_add_getopt_arg(cmd->command->valid_args[i], &ptr, &o);
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 3e12c5c7..b7932316 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -51,7 +51,8 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
* system.
*/
if (pv && is_orphan(pv)) {
- (void) get_vgs(cmd, 1);
+ if (!scan_vgs_for_pvs(cmd))
+ return_0;
pv = pv_read(cmd, name, NULL, NULL, 0);
}
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 7862629c..a2dacf40 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -26,7 +26,7 @@ static int _pvdisplay_single(struct cmd_context *cmd,
const char *pv_name = pv_dev_name(pv);
const char *vg_name = NULL;
- if (!is_orphan(pv) && !vg) {
+ if (!is_orphan(pv) && !vg) {
vg_name = pv_vg_name(pv);
if (!(vg = vg_lock_and_read(cmd, vg_name, (char *)&pv->vgid,
LCK_VG_READ, CLUSTERED, 0))) {
diff --git a/tools/toollib.c b/tools/toollib.c
index ab33e4b2..30c7dce3 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -696,6 +696,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
struct str_list *sll;
char *tagname;
int consistent = 1;
+ int scanned = 0;
list_init(&tags);
@@ -738,6 +739,30 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
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)) {
+ if (!scan_vgs_for_pvs(cmd)) {
+ stack;
+ ret_max = ECMD_FAILED;
+ continue;
+ }
+ scanned = 1;
+ if (!(pv = pv_read(cmd, argv[opt],
+ NULL, NULL, 1))) {
+ log_error("Failed to read "
+ "physical volume "
+ "\"%s\"", argv[opt]);
+ ret_max = ECMD_FAILED;
+ continue;
+ }
+ }
}
ret = process_single(cmd, vg, pv, handle);