diff --git a/WHATS_NEW b/WHATS_NEW index 7fcf49a13..1e34e1c43 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.128 - =================================== + Check for valid cache mode in validation of cache segment. Enhance internal API cache_set_mode() and cache_set_policy(). Enhance toollib's get_cache_params(). Runtime detect presence of cache smq policy. diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c index 052617317..53c867e00 100644 --- a/lib/cache_segtype/cache.c +++ b/lib/cache_segtype/cache.c @@ -100,6 +100,9 @@ static int _cache_pool_text_import(struct lv_segment *seg, * If the policy is not present, default policy is used. */ if ((sn = dm_config_find_node(sn, "policy_settings"))) { + if (!seg->policy_name) + return SEG_LOG_ERROR("policy_settings must have a policy_name in"); + if (sn->v) return SEG_LOG_ERROR("policy_settings must be a section in"); diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index f13df1b2b..116f099ae 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -7074,7 +7074,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, display_lvname(origin_lv)); return NULL; } - } else if (pool_lv && seg_is_cache(lp)) { + } else if (seg_is_cache(lp)) { + if (!pool_lv) { + log_error(INTERNAL_ERROR "Pool LV for cache is missing."); + return NULL; + } if (!lv_is_cache_pool(pool_lv)) { log_error("Logical volume %s is not a cache pool.", display_lvname(pool_lv)); diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index e38cb5336..a3e6af109 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -208,7 +208,21 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg) } } - if (seg_is_cache_pool(seg)) { + if (seg_is_cache_pool(seg) && + !dm_list_empty(&seg->lv->segs_using_this_lv)) { + switch (seg->feature_flags & + (DM_CACHE_FEATURE_PASSTHROUGH | + DM_CACHE_FEATURE_WRITETHROUGH | + DM_CACHE_FEATURE_WRITEBACK)) { + case DM_CACHE_FEATURE_PASSTHROUGH: + case DM_CACHE_FEATURE_WRITETHROUGH: + case DM_CACHE_FEATURE_WRITEBACK: + break; + default: + log_error("LV %s has invalid cache's feature flag.", + lv->name); + inc_error_count; + } if (!seg->policy_name) { log_error("LV %s is missing cache policy name.", lv->name); inc_error_count;