summaryrefslogtreecommitdiff
path: root/tools/vgscan.c
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2009-06-05 20:00:52 +0000
committerMilan Broz <mbroz@redhat.com>2009-06-05 20:00:52 +0000
commit66086ce962c17a86bf6a1e984d716ef71b7b3441 (patch)
treefd6d398a3567ebd6a03af3d21de5778c6bdb7e61 /tools/vgscan.c
parent89b7d5cb4c2ebfc0a045a69902257785db3f5b27 (diff)
downloadlvm2-66086ce962c17a86bf6a1e984d716ef71b7b3441.tar.gz
Fix double releasing of vg when repairing of vg is requested.
Several commands calls process_each_vg() and in provided callback it explicitly recovers VG if inconsistent. (vgchange, vgconvert, vgscan) It means that old VG is released and reread but the function above (process_one_vg) tries to unlock and release old VG. Patch moves the repair logic into _process_one_vg() function. It always tries to read vg (even inconsistent) and then decides what to do according new defined parameter. Also patch unifies inconsistent error messages. The only slight change if for vgremove command, where it now tries to repair VG before it removes if force arg is given. (It works similar way before, just the order of operation changed).
Diffstat (limited to 'tools/vgscan.c')
-rw-r--r--tools/vgscan.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/tools/vgscan.c b/tools/vgscan.c
index 3ac0d8491..083cb5af9 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -19,20 +19,6 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
void *handle __attribute((unused)))
{
- if (!vg) {
- log_error("Volume group \"%s\" not found", vg_name);
- return ECMD_FAILED;
- }
-
- if (!consistent) {
- unlock_and_release_vg(cmd, vg, vg_name);
- dev_close_all();
- log_error("Volume group \"%s\" inconsistent", vg_name);
- /* Don't allow partial switch to this program */
- if (!(vg = recover_vg(cmd, vg_name, LCK_VG_WRITE)))
- return ECMD_FAILED;
- }
-
log_print("Found %svolume group \"%s\" using metadata type %s",
(vg_status(vg) & EXPORTED_VG) ? "exported " : "", vg_name,
vg->fid->fmt->name);
@@ -61,7 +47,8 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
log_print("Reading all physical volumes. This may take a while...");
- maxret = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, NULL,
+ maxret = process_each_vg(cmd, argc, argv, LCK_VG_READ,
+ VG_INCONSISTENT_REPAIR, NULL,
&vgscan_single);
if (arg_count(cmd, mknodes_ARG)) {