1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-28 11:22:15 +03:00

cache: lvcreate --cachepool checks for cache pool

Code path missed validation of lvcreate --cachepool argument.
If the non cache-pool LV was passed in, code has still continued
further work and failed later on internal error.  Validate this
condition at right place now.
This commit is contained in:
Zdenek Kabelac 2017-06-09 10:59:37 +02:00
parent f91ea96b4f
commit b3ef051e06
3 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.172 -
===============================
Improve lvcreate --cachepool arg validation.
Limit maximal size of thin-pool for specific chunk size.
Print a warning about in-use PVs with no VG using them.
Disable automatic clearing of PVs that look like in-use orphans.

View File

@ -26,6 +26,7 @@ aux prepare_vg 5 80000
aux lvmconf 'global/cache_disabled_features = [ "policy_smq" ]'
#######################
# Cache_Pool creation #
#######################
@ -62,6 +63,11 @@ grep "No command with matching syntax recognised" err
# Check nothing has been created yet
check vg_field $vg lv_count 0
# Checks that argument passed with --cachepool is really a cache-pool
lvcreate -an -l 1 -n $lv1 $vg
# Hint: nice way to 'tee' only stderr.log so we can check it's log_error()
fail lvcreate -L10 --cachepool $vg/$lv1 2> >(tee -a stderr.log >&2)
grep "not a cache pool" stderr.log
# With --type cache-pool we are clear which segtype has to be created
lvcreate -l 1 --type cache-pool $vg/pool1

View File

@ -1193,6 +1193,13 @@ static int _determine_cache_argument(struct volume_group *vg,
lp->create_pool = 0;
lp->origin_name = NULL;
} else if (lv) {
if (arg_is_set(cmd, cachepool_ARG)) {
/* Argument of --cachepool has to be a cache-pool */
log_error("Logical volume %s is not a cache pool.",
display_lvname(lv));
return 0;
}
/* Origin exists, create cache pool volume */
if (!validate_lv_cache_create_origin(lv))
return_0;