1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

lvcreate: improve --chunksize support for cached volume.

Support parsing --chunksize option also when converting.
Now user can use cache pool created with i.e. 32K chunksize,
while in caching user can select 512K blocks.
Tool is supposed to validate cache metadata size is big enough
to support such chunk size. Otherwise error is shown.
This commit is contained in:
Zdenek Kabelac 2016-05-05 21:34:21 +02:00
parent d3b15674df
commit d1ecbfa52d
3 changed files with 23 additions and 23 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.153 -
==================================
Support --chunksize option also when caching LV when possible.
Add function to check for target presence and version via 1 ioctl.
Version 2.02.152 - 30th April 2016

View File

@ -7166,9 +7166,17 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
if (seg_is_cache(lp)) {
/* validate metadata size */
if (!validate_lv_cache_chunk_size(pool_lv, lp->chunk_size))
return_0;
first_seg(pool_lv)->chunk_size = lp->chunk_size;
}
/* Validate volume size to to aling on chunk for small extents */
/* Cache chunk size is always set */
size = seg_is_cache(lp) ? lp->chunk_size : first_seg(pool_lv)->chunk_size;
size = first_seg(pool_lv)->chunk_size;
if (size > vg->extent_size) {
/* Align extents on chunk boundary size */
size = ((uint64_t)vg->extent_size * lp->extents + size - 1) /
@ -7427,27 +7435,15 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* Unlock memory if possible */
memlock_unlock(vg->cmd);
if (lv_is_cache_pool(lv) || lv_is_cache(lv)) {
if (!cache_set_mode(first_seg(lv), lp->cache_mode)) {
if (lv_is_cache_pool(lv)) {
if (!cache_set_params(first_seg(lv),
lp->cache_mode,
lp->policy_name,
lp->policy_settings,
lp->chunk_size)) {
stack;
goto revert_new_lv;
}
if (!cache_set_policy(first_seg(lv), lp->policy_name, lp->policy_settings)) {
stack;
goto revert_new_lv;
}
pool_lv = pool_lv ? : lv;
if (lp->chunk_size) {
first_seg(pool_lv)->chunk_size = lp->chunk_size;
/* TODO: some calc_policy solution for cache ? */
if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, lp->passed_args,
THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) {
stack;
goto revert_new_lv;
}
}
} else if (lv_is_raid(lv)) {
first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
@ -7649,10 +7645,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
lv = tmp_lv;
if (!cache_set_mode(first_seg(lv), lp->cache_mode))
return_NULL; /* revert? */
if (!cache_set_policy(first_seg(lv), lp->policy_name, lp->policy_settings))
if (!cache_set_params(first_seg(lv),
lp->cache_mode,
lp->policy_name,
lp->policy_settings,
(lp->passed_args & PASS_ARG_CHUNK_SIZE) ? lp->chunk_size : 0))
return_NULL; /* revert? */
cache_check_for_warns(first_seg(lv));

View File

@ -260,6 +260,8 @@ and the default value is 4KiB.
.br
For cache pools the value must a multiple of 32KiB
between 32KiB and 1GiB. The default is 64KiB.
When the size is specified with volume caching, it may not be smaller
then cache pool creation chunk size was.
.br
For thin pools the value must be a multiple of 64KiB
between 64KiB and 1GiB.