1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

toollib: Split --cachesettings from --cachepolicy.

This commit is contained in:
Petr Rockai 2014-11-20 11:30:19 +01:00
parent 310beb73a8
commit 4b9b8e1282
5 changed files with 36 additions and 32 deletions

View File

@ -18,9 +18,10 @@ lvcreate --type cache-pool -an -v -L 2 -n cpool $vg
lvcreate -H -L 4 -n corigin --cachepool $vg/cpool lvcreate -H -L 4 -n corigin --cachepool $vg/cpool
lvcreate -n noncache -l 1 $vg lvcreate -n noncache -l 1 $vg
not lvchange --cachepolicy policy=mq $vg/noncache not lvchange --cachepolicy mq $vg/noncache
not lvchange --cachesettings foo=bar $vg/noncache
lvchange --cachepolicy policy=mq --cachepolicy migration_threshold=333 $vg/corigin lvchange --cachepolicy mq --cachesettings migration_threshold=333 $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333' dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
lvchange --refresh $vg/corigin lvchange --refresh $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333' dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
@ -28,7 +29,7 @@ lvchange -an $vg
lvchange -ay $vg lvchange -ay $vg
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333' dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
lvchange --cachepolicy 'migration_threshold = 233 sequential_threshold = 13' $vg/corigin lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13' $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 233' dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13' dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'

View File

@ -104,7 +104,8 @@ arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
arg(type_ARG, '\0', "type", segtype_arg, 0) arg(type_ARG, '\0', "type", segtype_arg, 0)
arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0) arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
arg(uncache_ARG, '\0', "uncache", NULL, 0) arg(uncache_ARG, '\0', "uncache", NULL, 0)
arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, ARG_GROUPABLE) arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, 0)
arg(cachesettings_ARG, '\0', "cachesettings", string_arg, ARG_GROUPABLE)
arg(units_ARG, '\0', "units", string_arg, 0) arg(units_ARG, '\0', "units", string_arg, 0)
arg(unquoted_ARG, '\0', "unquoted", NULL, 0) arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
arg(use_policies_ARG, '\0', "use-policies", NULL, 0) arg(use_policies_ARG, '\0', "use-policies", NULL, 0)

View File

@ -106,7 +106,7 @@ xx(lvchange,
"\t[--addtag Tag]\n" "\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n" "\t[--alloc AllocationPolicy]\n"
"\t[-C|--contiguous y|n]\n" "\t[-C|--contiguous y|n]\n"
"\t[--cachepolicy policy=type] [--cachepolicy parameter=value]\n" "\t[--cachepolicy policyname] [--cachesettings parameter=value]\n"
"\t[--commandprofile ProfileName]\n" "\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n" "\t[-d|--debug]\n"
"\t[--deltag Tag]\n" "\t[--deltag Tag]\n"
@ -144,7 +144,7 @@ xx(lvchange,
activationmode_ARG, addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, activationmode_ARG, addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG,
available_ARG, available_ARG,
cachepolicy_ARG, contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG, cachepolicy_ARG, cachesettings_ARG, contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
ignorelockingfailure_ARG, ignoremonitoring_ARG, ignoreactivationskip_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG, ignoreactivationskip_ARG,
ignoreskippedcluster_ARG, major_ARG, metadataprofile_ARG, minor_ARG, ignoreskippedcluster_ARG, major_ARG, metadataprofile_ARG, minor_ARG,
monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, noudevsync_ARG, monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, noudevsync_ARG,

View File

@ -1014,7 +1014,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
docmds++; docmds++;
} }
if (arg_count(cmd, cachepolicy_ARG)) { if (arg_count(cmd, cachepolicy_ARG) || arg_count(cmd, cachesettings_ARG)) {
if (!archive(lv->vg)) if (!archive(lv->vg))
return_ECMD_FAILED; return_ECMD_FAILED;
doit += lvchange_cachepolicy(cmd, lv); doit += lvchange_cachepolicy(cmd, lv);
@ -1081,6 +1081,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, resync_ARG) || arg_count(cmd, resync_ARG) ||
arg_count(cmd, syncaction_ARG) || arg_count(cmd, syncaction_ARG) ||
arg_count(cmd, cachepolicy_ARG) || arg_count(cmd, cachepolicy_ARG) ||
arg_count(cmd, cachesettings_ARG) ||
arg_count(cmd, writebehind_ARG) || arg_count(cmd, writebehind_ARG) ||
arg_count(cmd, writemostly_ARG) || arg_count(cmd, writemostly_ARG) ||
arg_count(cmd, zero_ARG); arg_count(cmd, zero_ARG);

View File

@ -1127,56 +1127,57 @@ struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
struct arg_value_group_list *group; struct arg_value_group_list *group;
struct dm_config_tree *result = NULL, *prev = NULL, *current = NULL; struct dm_config_tree *result = NULL, *prev = NULL, *current = NULL;
struct dm_config_node *cn, *last = NULL; struct dm_config_node *cn, *last = NULL;
int ok = 0;
dm_list_iterate_items(group, &cmd->arg_value_groups) { dm_list_iterate_items(group, &cmd->arg_value_groups) {
if (!grouped_arg_is_set(group->arg_values, cachepolicy_ARG)) if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
continue; continue;
current = dm_config_create(); current = dm_config_create();
if (!current) if (!current)
goto_bad; goto_out;
if (prev) if (prev)
current->cascade = prev; current->cascade = prev;
prev = current; prev = current;
if (!(str = grouped_arg_str_value(group->arg_values, if (!(str = grouped_arg_str_value(group->arg_values,
cachepolicy_ARG, cachesettings_ARG,
NULL))) NULL)))
goto_bad; goto_out;
if (!dm_config_parse(current, str, str + strlen(str))) if (!dm_config_parse(current, str, str + strlen(str)))
goto_bad; goto_out;
} }
result = dm_config_flatten(current); result = dm_config_flatten(current);
if (!(cn = dm_config_create_node(result, "policy_settings"))) {
dm_config_destroy(result); if (!(cn = dm_config_create_node(result, "policy_settings")))
result = NULL; goto_out;
}
cn->child = result->root; cn->child = result->root;
result->root = cn; result->root = cn;
cn = cn->child;
while (cn) { if (arg_count(cmd, cachepolicy_ARG)) {
if (!strcmp(cn->key, "policy")) { if (!(cn = dm_config_create_node(result, "policy")))
if (last) goto_out;
last->sib = cn->sib;
else result->root->sib = cn;
result->root->child = cn->sib; if (!(cn->v = dm_config_create_value(result)))
cn->parent = NULL; goto_out;
cn->sib = NULL;
result->root->sib = cn; cn->v->v.str = arg_str_value(cmd, cachepolicy_ARG, NULL);
}
last = cn;
cn = cn->sib;
} }
if (!_validate_cachepool_params(current)) { if (!_validate_cachepool_params(result))
goto_out;
ok = 1;
out:
if (!ok) {
dm_config_destroy(result); dm_config_destroy(result);
result = NULL; result = NULL;
} }
bad:
while (prev) { while (prev) {
current = prev->cascade; current = prev->cascade;
dm_config_destroy(prev); dm_config_destroy(prev);