dev-peter-config-profiles - tools: add support for changing configuration profile for existing volumes (vgchange/lvchange)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1d6b2534876615584899cbfb94a4cece8d5a1644 Commit: 1d6b2534876615584899cbfb94a4cece8d5a1644 Parent: 1ef90eba33fb8b5d646e422c1fd43d6da990d63e Author: Peter Rajnoha <[email protected]> AuthorDate: Tue Jun 25 12:33:06 2013 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Wed Jun 26 16:53:51 2013 +0200
tools: add support for changing configuration profile for existing volumes (vgchange/lvchange)
"vgchange/lvchange --profile <profile_name>" changes the profile for existing VG/LV "vgchange/lvchange --detachprofile" detaches any existing profile from VG/LV
--- tools/args.h | 1 + tools/commands.h | 24 +++++++++++++----------- tools/lvchange.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- tools/vgchange.c | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 97 insertions(+), 17 deletions(-)
tools/args.h +1 -0
@@ -92,6 +92,7 @@ arg(writebehind_ARG, '\0', "writebehind", int_arg, 0) arg(minrecoveryrate_ARG, '\0', "minrecoveryrate", size_kb_arg, 0) arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", size_kb_arg, 0) arg(profile_ARG, '\0', "profile", string_arg, 0) +arg (detachprofile_ARG,'\0' ,"detachprofile" ,NULL ,0 ) /* Allow some variations */arg (resizable_ARG,'\0' ,"resizable" , yes_no_arg,0 )
tools/commands.h +13 -11
@@ -76,6 +76,7 @@ xx(lvchange,"\t[-C|--contiguous y|n]\n" "\t[-d|--debug]\n" "\t[--deltag Tag]\n" +"\t[--detachprofile]\n" "\t[-f|--force]\n" "\t[-h|--help]\n" "\t[--discards {ignore|nopassdown|passdown}]\n"
@@ -104,12 +105,12 @@ xx(lvchange, "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n", alloc_ARG, autobackup_ARG, activate_ARG, available_ARG, contiguous_ARG, - discards_ARG, force_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG, - major_ARG, minor_ARG, monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, - noudevsync_ARG, partial_ARG, - permission_ARG, persistent_ARG, poll_ARG, readahead_ARG, resync_ARG, - refresh_ARG, addtag_ARG, deltag_ARG, syncaction_ARG, sysinit_ARG, test_ARG, - writebehind_ARG, writemostly_ARG, zero_ARG) + discards_ARG, detachprofile_ARG, force_ARG, ignorelockingfailure_ARG, + ignoremonitoring_ARG, major_ARG, minor_ARG, monitor_ARG, minrecoveryrate_ARG, + maxrecoveryrate_ARG, noudevsync_ARG, partial_ARG, permission_ARG, + persistent_ARG, poll_ARG, readahead_ARG, resync_ARG, refresh_ARG, addtag_ARG, + deltag_ARG, syncaction_ARG, sysinit_ARG, test_ARG, writebehind_ARG, + writemostly_ARG, zero_ARG) xx(lvconvert, "Change logical volume layout",
@@ -770,6 +771,7 @@ xx(vgchange,"\t[--alloc AllocationPolicy] " "\n" "\t[-P|--partial] " "\n" "\t[-d|--debug] " "\n" +"\t[--detachprofile] " "\n" "\t[-h|--help] " "\n" "\t[--ignorelockingfailure]\n" "\t[--ignoremonitoring]\n"
@@ -794,11 +796,11 @@ xx(vgchange, "\t[VolumeGroupName...]\n", addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, activate_ARG, - available_ARG, clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, - ignoremonitoring_ARG, logicalvolume_ARG, maxphysicalvolumes_ARG, - monitor_ARG, noudevsync_ARG, metadatacopies_ARG, vgmetadatacopies_ARG, - partial_ARG, physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG, - resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG) + available_ARG, clustered_ARG, deltag_ARG, detachprofile_ARG, + ignorelockingfailure_ARG, ignoremonitoring_ARG, logicalvolume_ARG, + maxphysicalvolumes_ARG, monitor_ARG, noudevsync_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, "Check the consistency of volume group(s)",
tools/lvchange.c +49 -5
90 lines not on this page · raw message
tools/vgchange.c +34 -1
@@ -421,6 +421,30 @@ static int _vgchange_metadata_copies(struct cmd_context *cmd,return 1 ; } +static int _vgchange_profile (struct cmd_context *cmd, +struct volume_group *vg) +{ +const char *old_profile_name, *new_profile_name; +struct profile *new_profile; + + old_profile_name = vg->profile ? vg->profile->name :"(no profile)" ; + +if (arg_count (cmd, detachprofile_ARG)) { + new_profile_name ="(no profile)" ; + vg->profile =NULL ; + }else { + new_profile_name =arg_str_value (cmd, profile_ARG,NULL ); +if (!(new_profile =load_profile (cmd, new_profile_name))) + return_0; + vg->profile = new_profile; + } + +log_verbose ("Changing configuration profile for VG %s: %s -> %s." , + vg->name, old_profile_name, new_profile_name); + +return 1 ; +} +static int vgchange_single (struct cmd_context *cmd,const char *vg_name,struct volume_group *vg,void *handle __attribute__((unused)))
@@ -442,6 +466,8 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name, { alloc_ARG, &_vgchange_alloc }, { clustered_ARG, &_vgchange_clustered }, { vgmetadatacopies_ARG, &_vgchange_metadata_copies }, + { profile_ARG, &_vgchange_profile}, + { detachprofile_ARG, &_vgchange_profile}, { -1, NULL }, };
@@ -521,7 +547,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)/* Update commands that can be combined */ int update_partial_safe =arg_count (cmd, deltag_ARG) || -arg_count (cmd, addtag_ARG); +arg_count (cmd, addtag_ARG) || +arg_count (cmd, profile_ARG) || +arg_count (cmd, detachprofile_ARG);int update_partial_unsafe =arg_count (cmd, logicalvolume_ARG) || arg_count(cmd, maxphysicalvolumes_ARG) ||
@@ -545,6 +573,11 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } +if (arg_count (cmd, profile_ARG) &&arg_count (cmd, detachprofile_ARG)) { +log_error ("Only one of --profile and --detachprofile permitted." ); +return EINVALID_CMD_LINE ; + } +if (arg_count (cmd, activate_ARG) &&arg_count (cmd, refresh_ARG)) {log_error ("Only one of -a and --refresh permitted." );return EINVALID_CMD_LINE ;