1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lvchange: make use of command definitions

Reorganize the lvchange code to take advantage of
the command definition, and remove the validation
that is done by the command definintion rules.
This commit is contained in:
David Teigland 2016-11-16 16:05:47 -06:00
parent 9c6c55c314
commit 52c60b7e7b
4 changed files with 470 additions and 492 deletions

View File

@ -239,8 +239,12 @@ OO_LVCHANGE_META: --addtag Tag, --deltag Tag,
--minrecoveryrate SizeKB, --maxrecoveryrate SizeKB,
--writebehind Number, --writemostly WriteMostlyPV, --persistent n
# It's unfortunate that activate needs to be optionally allowed here;
# it should only be used explicitly, but it's been previously allowed
# in combination with unrelated metadata changes.
lvchange OO_LVCHANGE_META VG|LV|Tag|Select ...
OO: OO_LVCHANGE
OO: --activate Active, OO_LVCHANGE
ID: lvchange_properties
DESC: Change a general LV property.
RULE: all not lv_is_pvmove lv_is_mirror_log lv_is_mirror_image
@ -256,8 +260,11 @@ RULE: --permission not lv_is_external_origin lv_is_raid_metadata lv_is_raid_imag
RULE: --alloc --contiguous --metadataprofile --permission --persistent --profile --readahead not lv_is_thick_origin
RULE: --alloc --discards --zero --cachemode --cachepolicy --cachesettings not lv_is_partial
# It's unfortunate that acativate needs to be optionally allowed here,
# like above, it was previouly allowed in combination.
lvchange --resync VG|LV_raid_mirror|Tag|Select ...
OO: OO_LVCHANGE
OO: --activate Active, OO_LVCHANGE
ID: lvchange_resync
DESC: Resyncronize a mirror or raid LV.
RULE: all not lv_is_pvmove lv_is_locked
@ -275,15 +282,14 @@ ID: lvchange_rebuild
DESC: Reconstruct data on specific PVs of a raid LV.
RULE: all not LV_raid0
# try removing the META change options from here?
lvchange --activate Active VG|LV|Tag|Select ...
OO: --activationmode ActivationMode, --partial, --ignoreactivationskip,
--ignorelockingfailure, --sysinit, OO_LVCHANGE_META, OO_LVCHANGE
--ignorelockingfailure, --sysinit, OO_LVCHANGE
ID: lvchange_activate
DESC: Activate or deactivate an LV.
lvchange --refresh VG|LV|Tag|Select ...
OO: --partial, OO_LVCHANGE
OO: --partial, --poll Bool, OO_LVCHANGE
ID: lvchange_refresh
DESC: Reactivate an LV using the latest metadata.

File diff suppressed because it is too large Load Diff

View File

@ -113,6 +113,15 @@ static struct cmdline_context _cmdline;
*/
struct command_function command_functions[COMMAND_ID_COUNT] = {
{ lvmconfig_general_CMD, lvmconfig },
{ lvchange_properties_CMD, lvchange_properties_cmd },
{ lvchange_resync_CMD, lvchange_resync_cmd },
{ lvchange_syncaction_CMD, lvchange_syncaction_cmd },
{ lvchange_rebuild_CMD, lvchange_rebuild_cmd },
{ lvchange_activate_CMD, lvchange_activate_cmd },
{ lvchange_refresh_CMD, lvchange_refresh_cmd },
{ lvchange_monitor_CMD, lvchange_monitor_poll_cmd },
{ lvchange_poll_CMD, lvchange_monitor_poll_cmd },
{ lvchange_persistent_CMD, lvchange_persistent_cmd },
};
#if 0
/* all raid-related type conversions */

View File

@ -242,4 +242,13 @@ int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg
struct lv_props *get_lv_prop(int lvp_enum);
struct lv_types *get_lv_type(int lvt_enum);
int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_refresh_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_resync_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_syncaction_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_rebuild_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_monitor_poll_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv);
#endif