mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
toollib: get_cache_params
Enhance get_cache_params() to read common cache args.
This commit is contained in:
parent
6cde12a013
commit
969ee25a74
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.128 -
|
Version 2.02.128 -
|
||||||
===================================
|
===================================
|
||||||
|
Enhance toollib's get_cache_params().
|
||||||
Runtime detect presence of cache smq policy.
|
Runtime detect presence of cache smq policy.
|
||||||
Add demo cache-mq and cache-smq profiles.
|
Add demo cache-mq and cache-smq profiles.
|
||||||
Add cmd profilable allocation/cache_policy,cache_settings,cache_mode.
|
Add cmd profilable allocation/cache_policy,cache_settings,cache_mode.
|
||||||
|
@ -901,7 +901,7 @@ struct lvcreate_params {
|
|||||||
uint32_t min_recovery_rate; /* RAID */
|
uint32_t min_recovery_rate; /* RAID */
|
||||||
uint32_t max_recovery_rate; /* RAID */
|
uint32_t max_recovery_rate; /* RAID */
|
||||||
|
|
||||||
uint64_t feature_flags; /* cache */
|
const char *cache_mode; /* cache */
|
||||||
const char *policy_name; /* cache */
|
const char *policy_name; /* cache */
|
||||||
struct dm_config_tree *policy_settings; /* cache */
|
struct dm_config_tree *policy_settings; /* cache */
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ static int _lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_cache_policy_params(cmd, &name, &settings))
|
if (!get_cache_params(cmd, NULL, &name, &settings))
|
||||||
goto_out;
|
goto_out;
|
||||||
if (!lv_cache_set_policy(lv, name, settings))
|
if (!lv_cache_set_policy(lv, name, settings))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
@ -50,7 +50,7 @@ struct lvconvert_params {
|
|||||||
uint32_t stripes;
|
uint32_t stripes;
|
||||||
uint32_t stripe_size;
|
uint32_t stripe_size;
|
||||||
uint32_t read_ahead;
|
uint32_t read_ahead;
|
||||||
uint64_t feature_flags; /* cache_pool */
|
const char *cache_mode; /* cache */
|
||||||
const char *policy_name; /* cache */
|
const char *policy_name; /* cache */
|
||||||
struct dm_config_tree *policy_settings; /* cache */
|
struct dm_config_tree *policy_settings; /* cache */
|
||||||
|
|
||||||
@ -299,26 +299,14 @@ static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv,
|
|||||||
} else if (!strcmp(type_str, "thin-pool"))
|
} else if (!strcmp(type_str, "thin-pool"))
|
||||||
thinpool = 1;
|
thinpool = 1;
|
||||||
|
|
||||||
if (cachepool) {
|
if (lp->cache && !cachepool) {
|
||||||
const char *cachemode = arg_str_value(cmd, cachemode_ARG, NULL);
|
|
||||||
if (!cachemode)
|
|
||||||
cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
|
|
||||||
|
|
||||||
if (!set_cache_pool_feature(&lp->feature_flags, cachemode))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
if (!get_cache_policy_params(cmd, &lp->policy_name, &lp->policy_settings)) {
|
|
||||||
log_error("Failed to parse cache policy and/or settings.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (arg_from_list_is_set(cmd, "is valid only with cache pools",
|
|
||||||
cachepool_ARG, cachemode_ARG, -1))
|
|
||||||
return_0;
|
|
||||||
if (lp->cache) {
|
|
||||||
log_error("--cache requires --cachepool.");
|
log_error("--cache requires --cachepool.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ((lp->cache || cachepool) &&
|
||||||
|
!get_cache_params(cmd, &lp->cache_mode, &lp->policy_name, &lp->policy_settings)) {
|
||||||
|
log_error("Failed to parse cache policy and/or settings.");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thinpool) {
|
if (thinpool) {
|
||||||
@ -3080,7 +3068,6 @@ mda_write:
|
|||||||
seg->chunk_size = lp->chunk_size;
|
seg->chunk_size = lp->chunk_size;
|
||||||
seg->discards = lp->discards;
|
seg->discards = lp->discards;
|
||||||
seg->zero_new_blocks = lp->zero ? 1 : 0;
|
seg->zero_new_blocks = lp->zero ? 1 : 0;
|
||||||
seg->feature_flags = lp->feature_flags; /* cache-pool */
|
|
||||||
|
|
||||||
if ((lp->policy_name || lp->policy_settings) &&
|
if ((lp->policy_name || lp->policy_settings) &&
|
||||||
!lv_cache_set_policy(seg->lv, lp->policy_name, lp->policy_settings))
|
!lv_cache_set_policy(seg->lv, lp->policy_name, lp->policy_settings))
|
||||||
|
@ -567,21 +567,14 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
|
|||||||
static int _read_cache_params(struct cmd_context *cmd,
|
static int _read_cache_params(struct cmd_context *cmd,
|
||||||
struct lvcreate_params *lp)
|
struct lvcreate_params *lp)
|
||||||
{
|
{
|
||||||
const char *cachemode;
|
|
||||||
|
|
||||||
if (!seg_is_cache(lp) && !seg_is_cache_pool(lp))
|
if (!seg_is_cache(lp) && !seg_is_cache_pool(lp))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!(cachemode = arg_str_value(cmd, cachemode_ARG, NULL)))
|
if (!get_cache_params(cmd,
|
||||||
cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
|
&lp->cache_mode,
|
||||||
|
&lp->policy_name,
|
||||||
if (!set_cache_pool_feature(&lp->feature_flags, cachemode))
|
&lp->policy_settings))
|
||||||
return_0;
|
return_NULL;
|
||||||
|
|
||||||
if (!get_cache_policy_params(cmd, &lp->policy_name, &lp->policy_settings)) {
|
|
||||||
log_error("Failed to parse cache policy and/or settings.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1089,8 +1082,6 @@ static int _determine_cache_argument(struct volume_group *vg,
|
|||||||
/* If cache args not given, use those from cache pool */
|
/* If cache args not given, use those from cache pool */
|
||||||
if (!arg_is_set(cmd, chunksize_ARG))
|
if (!arg_is_set(cmd, chunksize_ARG))
|
||||||
lp->chunk_size = first_seg(lv)->chunk_size;
|
lp->chunk_size = first_seg(lv)->chunk_size;
|
||||||
if (!arg_is_set(cmd, cachemode_ARG))
|
|
||||||
lp->feature_flags = first_seg(lv)->feature_flags;
|
|
||||||
} else if (lv) {
|
} else if (lv) {
|
||||||
/* Origin exists, create cache pool volume */
|
/* Origin exists, create cache pool volume */
|
||||||
if (!validate_lv_cache_create_origin(lv))
|
if (!validate_lv_cache_create_origin(lv))
|
||||||
|
@ -1399,7 +1399,9 @@ static int _validate_cachepool_params(const char *name,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_cache_policy_params(struct cmd_context *cmd, const char **name,
|
int get_cache_params(struct cmd_context *cmd,
|
||||||
|
const char **mode,
|
||||||
|
const char **name,
|
||||||
struct dm_config_tree **settings)
|
struct dm_config_tree **settings)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
@ -1408,7 +1410,14 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
|
|||||||
struct dm_config_node *cn;
|
struct dm_config_node *cn;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
*name = arg_str_value(cmd, cachepolicy_ARG, DEFAULT_CACHE_POLICY);
|
if (mode)
|
||||||
|
*mode = arg_str_value(cmd, cachemode_ARG, NULL);
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
*name = arg_str_value(cmd, cachepolicy_ARG, NULL);
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return 1;
|
||||||
|
|
||||||
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, cachesettings_ARG))
|
if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
|
||||||
@ -1429,6 +1438,9 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
|
|||||||
goto_out;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!current)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (!(result = dm_config_flatten(current)))
|
if (!(result = dm_config_flatten(current)))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
|
@ -190,7 +190,8 @@ int get_pool_params(struct cmd_context *cmd,
|
|||||||
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
|
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
|
||||||
uint32_t *stripe_size);
|
uint32_t *stripe_size);
|
||||||
|
|
||||||
int get_cache_policy_params(struct cmd_context *cmd,
|
int get_cache_params(struct cmd_context *cmd,
|
||||||
|
const char **mode,
|
||||||
const char **name,
|
const char **name,
|
||||||
struct dm_config_tree **settings);
|
struct dm_config_tree **settings);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user