]> sourceware.org Git - lvm2.git/commitdiff
cache: disallow to combine format 2 with mq
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 19 Mar 2018 09:23:48 +0000 (10:23 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 19 Mar 2018 11:02:08 +0000 (12:02 +0100)
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.

WHATS_NEW
lib/metadata/cache_manip.c

index 995b389cb1266d6bf39d77ffd4e8165e9e61de0a..37503419f34c2c2ac8d14caa8e257db6a28e0f76 100644 (file)
--- 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.
index 5167760ea2fb9eed01116f929bb4d638992a9fe1..2a54682e7f4d1e33b2413eace67c8a9d9b5ea99b 100644 (file)
@@ -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) {
This page took 0.046294 seconds and 5 git commands to generate.