From: Zdenek Kabelac Date: Mon, 19 Mar 2018 09:23:48 +0000 (+0100) Subject: cache: disallow to combine format 2 with mq X-Git-Tag: v2_02_178-rc1~117 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=8d7ece126b96337326d026ab4edebe2db4333459;p=lvm2.git cache: disallow to combine format 2 with mq Only policy 'smq' is meant to be used with format version 2. Code used to let pass 'mq' policy also with format 2. But 'mq' is obsoloted wth smq and kernel currently matches it. But this is incompatible with older original mq logic - so disallow creation of this rather useless combination. --- diff --git a/WHATS_NEW b/WHATS_NEW index 995b389cb..37503419f 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.178 - ===================================== + Disallow usage of cache format 2 with mq cache policy. Again accept striped LV as COW LV with lvconvert -s (2.02.169). Fix raid target version testing for supported features. Allow activation of pools when thin/cache_check tool is missing. diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c index 5167760ea..2a54682e7 100644 --- a/lib/metadata/cache_manip.c +++ b/lib/metadata/cache_manip.c @@ -841,6 +841,18 @@ int cache_set_metadata_format(struct lv_segment *seg, cache_metadata_format_t fo return 0; } + /* + * If policy is unselected, but format 2 is selected, policy smq is enforced. + * ATM no other then smq policy is allowed to select format 2. + */ + if (!seg->policy_name) { + if (format == CACHE_METADATA_FORMAT_2) + seg->policy_name = "smq"; + } else if (strcmp(seg->policy_name, "smq")) { + seg->cache_metadata_format = CACHE_METADATA_FORMAT_1; + return 1; + } + /* Check if we need to search for configured cache metadata format */ if (format == CACHE_METADATA_FORMAT_UNSELECTED) { if (seg->cache_metadata_format != CACHE_METADATA_FORMAT_UNSELECTED) @@ -894,15 +906,15 @@ int cache_set_params(struct lv_segment *seg, struct lv_segment *pool_seg; struct cmd_context *cmd = seg->lv->vg->cmd; - if (!cache_set_metadata_format(seg, format)) - return_0; - if (!cache_set_cache_mode(seg, mode)) return_0; if (!cache_set_policy(seg, policy_name, policy_settings)) return_0; + if (!cache_set_metadata_format(seg, format)) + return_0; + pool_seg = seg_is_cache(seg) ? first_seg(seg->pool_lv) : seg; if (chunk_size) {