From: Dave Wysochanski Date: Mon, 28 Jun 2010 20:37:37 +0000 (+0000) Subject: Update vgchange tool to accept --vgmetadatacopies. X-Git-Tag: v2_02_91~1782 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=1779cc34d13352476a8fbacfd56b3e2996e4df83;p=lvm2.git Update vgchange tool to accept --vgmetadatacopies. 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 --- diff --git a/tools/args.h b/tools/args.h index d343689da..60d99d15e 100644 --- a/tools/args.h +++ b/tools/args.h @@ -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) diff --git a/tools/commands.h b/tools/commands.h index 6d8d2c07e..62a684be7 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -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, diff --git a/tools/vgchange.c b/tools/vgchange.c index 40f64eb27..074aa38f2 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -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; }