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

cache: update validation rules

Validate cache origin in front of the prompt.
Also add some rules to command description file.

TODO:
more validation needed also for lvcreate,
more complex rules with "OR" seems to be needed.
This commit is contained in:
Zdenek Kabelac 2023-07-04 19:21:43 +02:00
parent 88f1e7a9a7
commit e36028b7d2
3 changed files with 6 additions and 10 deletions

View File

@ -356,17 +356,10 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
return 0; return 0;
} }
/*
* Only linear, striped or raid supported.
* FIXME Tidy up all these type restrictions.
*/
if (lv_is_cache_type(origin_lv) || if (lv_is_cache_type(origin_lv) ||
lv_is_mirror_type(origin_lv) || lv_is_mirror_type(origin_lv) ||
lv_is_thin_volume(origin_lv) || lv_is_thin_pool_metadata(origin_lv) ||
lv_is_merging_origin(origin_lv) || lv_is_merging_origin(origin_lv) ||
lv_is_cow(origin_lv) || lv_is_merging_cow(origin_lv) || lv_is_cow(origin_lv) || lv_is_merging_cow(origin_lv)) {
/* TODO: think about enabling caching of a single thin volume */
(lv_is_virtual(origin_lv) && !lv_is_vdo(origin_lv))) {
log_error("Cache is not supported with %s segment type of the original logical volume %s.", log_error("Cache is not supported with %s segment type of the original logical volume %s.",
lvseg_name(first_seg(origin_lv)), display_lvname(origin_lv)); lvseg_name(first_seg(origin_lv)), display_lvname(origin_lv));
return 0; return 0;

View File

@ -479,7 +479,7 @@ lvconvert --type cache --cachepool LV LV_linear_striped_raid_thinpool_vdo_vdopoo
OO: --cache, OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT OO: --cache, OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_cache_with_cachepool ID: lvconvert_to_cache_with_cachepool
DESC: Attach a cache pool to an LV, converts the LV to type cache. DESC: Attach a cache pool to an LV, converts the LV to type cache.
RULE: all and lv_is_visible RULE: all not lv_is_locked lv_is_merging_origin lv_is_merging_cow lv_is_cow
RULE: --poolmetadata not --readahead --stripesize --stripes_long RULE: --poolmetadata not --readahead --stripesize --stripes_long
# alternate form of lvconvert --type cache # alternate form of lvconvert --type cache
@ -487,7 +487,7 @@ lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool_vdo_vdopool_vdo
OO: OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT OO: OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_cache_with_cachepool ID: lvconvert_to_cache_with_cachepool
DESC: Attach a cache pool to an LV. DESC: Attach a cache pool to an LV.
RULE: all and lv_is_visible RULE: all not lv_is_locked lv_is_merging_origin lv_is_merging_cow lv_is_cow
RULE: --poolmetadata not --readahead --stripesize --stripes_long RULE: --poolmetadata not --readahead --stripesize --stripes_long
FLAGS: SECONDARY_SYNTAX FLAGS: SECONDARY_SYNTAX
AUTOTYPE: cache AUTOTYPE: cache

View File

@ -4516,6 +4516,9 @@ static int _lvconvert_cachepool_attach_single(struct cmd_context *cmd,
goto out; goto out;
} }
if (!validate_lv_cache_create_origin(lv))
goto_out;
/* Ensure the LV is not active elsewhere. */ /* Ensure the LV is not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0)) if (!lockd_lv(cmd, lv, "ex", 0))
goto_out; goto_out;