1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

thin: apply VG profile if creating a new thin pool

When creating a new thin pool and there's no profile requested
via "lvcreate --profile ...", inherit any VG profile if it's attached.

Currently this applies to these settings:
  allocation/thin_pool_chunk_size
  allocation/thin_pool_discards
  allocation/thin_pool_zero
This commit is contained in:
Peter Rajnoha 2013-08-06 11:42:40 +02:00
parent 1cdd563b6c
commit e195b5227e
6 changed files with 54 additions and 20 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.100 -
================================
Inherit and apply any profile attached to a VG if creating new thin pool.
Add initial support thin pool lvconvert --repair.
Add --with-thin-repair and --with-thin-dump configure options.
Add lvm.conf thin_repair/dump_executable and thin_repair_options.

View File

@ -656,10 +656,13 @@ struct logical_volume *find_pool_lv(struct logical_volume *lv);
int pool_is_active(const struct logical_volume *pool_lv);
int pool_can_resize_metadata(const struct logical_volume *pool_lv);
int update_pool_lv(struct logical_volume *lv, int activate);
int update_pool_params(struct cmd_context *cmd, unsigned attr, int passed_args,
int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profile,
int passed_args, uint32_t *chunk_size,
thin_discards_t *discards, int *zero);
int update_pool_params(struct volume_group *vg, unsigned attr, int passed_args,
uint32_t data_extents, uint32_t extent_size,
uint32_t *chunk_size, thin_discards_t *discards,
uint64_t *pool_metadata_size);
uint64_t *pool_metadata_size, int *zero);
int get_pool_discards(const char *str, thin_discards_t *discards);
const char *get_pool_discards_name(thin_discards_t discards);
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,

View File

@ -569,12 +569,46 @@ int update_pool_lv(struct logical_volume *lv, int activate)
return 1;
}
int update_pool_params(struct cmd_context *cmd, unsigned attr, int passed_args,
int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profile,
int passed_args, uint32_t *chunk_size,
thin_discards_t *discards, int *zero)
{
const char *dstr;
if (!(passed_args & PASS_ARG_CHUNK_SIZE)) {
*chunk_size = find_config_tree_int(cmd, allocation_thin_pool_chunk_size_CFG, profile) * 2;
if ((*chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
(*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) {
log_error("Chunk size must be in the range %s to %s.",
display_size(cmd, DM_THIN_MIN_DATA_BLOCK_SIZE),
display_size(cmd, DM_THIN_MAX_DATA_BLOCK_SIZE));
return 0;
}
}
if (!(passed_args & PASS_ARG_DISCARDS)) {
dstr = find_config_tree_str(cmd, allocation_thin_pool_discards_CFG, profile);
if (!get_pool_discards(dstr, discards))
return_0;
}
if (!(passed_args & PASS_ARG_ZERO))
*zero = find_config_tree_bool(cmd, allocation_thin_pool_zero_CFG, profile);
return 1;
}
int update_pool_params(struct volume_group *vg, unsigned attr, int passed_args,
uint32_t data_extents, uint32_t extent_size,
uint32_t *chunk_size, thin_discards_t *discards,
uint64_t *pool_metadata_size)
uint64_t *pool_metadata_size, int *zero)
{
size_t estimate_chunk_size;
struct cmd_context *cmd = vg->cmd;
if (!update_profilable_pool_params(cmd, vg->profile, passed_args,
chunk_size, discards, zero))
return_0;
if (!(attr & THIN_FEATURE_BLOCK_SIZE) &&
(*chunk_size & (*chunk_size - 1))) {

View File

@ -2293,10 +2293,10 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
}
if (!lp->pool_metadata_lv_name) {
if (!update_pool_params(cmd, lp->target_attr, lp->passed_args,
if (!update_pool_params(pool_lv->vg, lp->target_attr, lp->passed_args,
pool_lv->le_count, pool_lv->vg->extent_size,
&lp->chunk_size, &lp->discards,
&lp->poolmetadata_size))
&lp->poolmetadata_size, &lp->zero))
return_0;
if (!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size))
@ -2399,10 +2399,10 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
display_size(cmd, 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE));
return 0;
}
if (!update_pool_params(cmd, lp->target_attr, lp->passed_args,
if (!update_pool_params(pool_lv->vg, lp->target_attr, lp->passed_args,
pool_lv->le_count, pool_lv->vg->extent_size,
&lp->chunk_size, &lp->discards,
&lp->poolmetadata_size))
&lp->poolmetadata_size, &lp->zero))
return_0;
}

View File

@ -334,10 +334,10 @@ static int _update_extents_params(struct volume_group *vg,
}
if (lp->create_thin_pool) {
if (!update_pool_params(vg->cmd, lp->target_attr, lp->passed_args,
if (!update_pool_params(vg, lp->target_attr, lp->passed_args,
lp->extents, vg->extent_size,
&lp->chunk_size, &lp->discards,
&lp->poolmetadatasize))
&lp->poolmetadatasize, &lp->zero))
return_0;
if (!(lp->poolmetadataextents =

View File

@ -1547,25 +1547,18 @@ int get_pool_params(struct cmd_context *cmd,
uint64_t *pool_metadata_size,
int *zero)
{
const char *dstr;
*passed_args = 0;
if (arg_count(cmd, zero_ARG)) {
*passed_args |= PASS_ARG_ZERO;
*zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
log_very_verbose("Setting pool zeroing: %u", *zero);
} else
*zero = find_config_tree_bool(cmd, allocation_thin_pool_zero_CFG, profile);
}
if (arg_count(cmd, discards_ARG)) {
*passed_args |= PASS_ARG_DISCARDS;
*discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, 0);
log_very_verbose("Setting pool discards: %s",
get_pool_discards_name(*discards));
} else {
dstr = find_config_tree_str(cmd, allocation_thin_pool_discards_CFG, profile);
if (!get_pool_discards(dstr, discards))
return_0;
}
if (arg_count(cmd, chunksize_ARG)) {
@ -1578,8 +1571,11 @@ int get_pool_params(struct cmd_context *cmd,
DM_THIN_MIN_DATA_BLOCK_SIZE);
log_very_verbose("Setting pool chunk size: %s",
display_size(cmd, *chunk_size));
} else
*chunk_size = find_config_tree_int(cmd, allocation_thin_pool_chunk_size_CFG, profile) * 2;
}
if (!update_profilable_pool_params(cmd, profile, *passed_args,
chunk_size, discards, zero))
return_0;
if ((*chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
(*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) {