]> sourceware.org Git - lvm2.git/commitdiff
Update vgchange tool to accept --vgmetadatacopies.
authorDave Wysochanski <dwysocha@redhat.com>
Mon, 28 Jun 2010 20:37:37 +0000 (20:37 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Mon, 28 Jun 2010 20:37:37 +0000 (20:37 +0000)
Update logic in vgchange to handle --vgmetadatacopies, allow
--metadatacopies as a synonym to --vgmetadatacopies,
and add these parameters to args.h and commands.h
Forbit both --vgmetadatacopies and --metadatacopies as only
one allowed.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
tools/args.h
tools/commands.h
tools/vgchange.c

index d343689da2079164f8770e9630b60b1a4420b448..60d99d15e792bfa67ad1771d57cdf6fd40b359e6 100644 (file)
@@ -23,6 +23,7 @@ arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
 arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
 arg(nolocking_ARG, '\0', "nolocking", NULL, 0)
 arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0)
+arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", int_arg, 0)
 arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg, 0)
 arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
 arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0)
index 6d8d2c07ef9aaa855ec14fed4676258da538859f..62a684be7f8061da96b70038156423c124c6182a 100644 (file)
@@ -710,6 +710,7 @@ xx(vgchange,
    "\t[--ignorelockingfailure]\n"
    "\t[--ignoremonitoring]\n"
    "\t[--monitor {y|n}]\n"
+   "\t[--[vg]metadatacopies #copies] " "\n"
    "\t[--poll {y|n}]\n"
    "\t[--noudevsync]\n"
    "\t[--refresh]\n"
@@ -731,7 +732,8 @@ xx(vgchange,
    addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG,
    clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG,
    logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, noudevsync_ARG,
-   partial_ARG, physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG,
+   metadatacopies_ARG, vgmetadatacopies_ARG, partial_ARG,
+   physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG,
    resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG)
 
 xx(vgck,
index 40f64eb2752672b94bd224fd9350f8540766635b..074aa38f21f8d606d6d8c77b81d8bcf7071773d2 100644 (file)
@@ -525,6 +525,45 @@ static int _vgchange_refresh(struct cmd_context *cmd, struct volume_group *vg)
        return ECMD_PROCESSED;
 }
 
+static int _vgchange_metadata_copies(struct cmd_context *cmd,
+                                    struct volume_group *vg)
+{
+       uint32_t mda_copies;
+
+       if (arg_count(cmd, vgmetadatacopies_ARG))
+               mda_copies = arg_uint_value(cmd, vgmetadatacopies_ARG,
+                       DEFAULT_VGMETADATACOPIES);
+       else if (arg_count(cmd, metadatacopies_ARG))
+               mda_copies = arg_uint_value(cmd, metadatacopies_ARG,
+                       DEFAULT_VGMETADATACOPIES);
+       if (mda_copies == vg_mda_copies(vg)) {
+               log_error("Metadata copies of VG %s is already %u",
+                         vg->name, mda_copies);
+               return ECMD_PROCESSED;
+       }
+
+       if (!archive(vg)) {
+               stack;
+               return ECMD_FAILED;
+       }
+
+       if (!vg_set_mda_copies(vg, mda_copies)) {
+               stack;
+               return EINVALID_CMD_LINE;
+       }
+
+       if (!vg_write(vg) || !vg_commit(vg)) {
+               stack;
+               return ECMD_FAILED;
+       }
+
+       backup(vg);
+
+       log_print("Volume group \"%s\" successfully changed", vg->name);
+
+       return ECMD_PROCESSED;
+}
+
 static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
                           struct volume_group *vg,
                           void *handle __attribute((unused)))
@@ -593,6 +632,10 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
        else if (arg_count(cmd, refresh_ARG))
                r = _vgchange_refresh(cmd, vg);
 
+       else if (arg_count(cmd, vgmetadatacopies_ARG) ||
+                arg_count(cmd, metadatacopies_ARG))
+               r = _vgchange_metadata_copies(cmd, vg);
+
        return r;
 }
 
@@ -606,10 +649,12 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
             arg_count(cmd, physicalextentsize_ARG) +
             arg_count(cmd, clustered_ARG) + arg_count(cmd, alloc_ARG) +
             arg_count(cmd, monitor_ARG) + arg_count(cmd, poll_ARG) +
-            arg_count(cmd, refresh_ARG))) {
+            arg_count(cmd, refresh_ARG) + arg_count(cmd, metadatacopies_ARG) +
+            arg_count(cmd, vgmetadatacopies_ARG))) {
                log_error("Need 1 or more of -a, -c, -l, -p, -s, -x, "
                          "--refresh, --uuid, --alloc, --addtag, --deltag, "
-                         "--monitor or --poll");
+                         "--monitor, --poll, --vgmetadatacopies or "
+                         "--metadatacopies");
                return EINVALID_CMD_LINE;
        }
 
This page took 0.044511 seconds and 5 git commands to generate.