]> sourceware.org Git - lvm2.git/commitdiff
cache: factor lvchange_cache
authorDavid Teigland <teigland@redhat.com>
Mon, 5 Nov 2018 22:38:08 +0000 (16:38 -0600)
committerDavid Teigland <teigland@redhat.com>
Tue, 6 Nov 2018 17:36:34 +0000 (11:36 -0600)
to prepare for future addition

tools/lvchange.c

index 07a578b865b675a4cc2b284233f30060dfc5b376..52b3bda6070725a69e7685fcedfb6162ac813ffb 100644 (file)
@@ -636,18 +636,26 @@ static int _lvchange_cache(struct cmd_context *cmd,
        cache_mode_t mode;
        const char *name;
        struct dm_config_tree *settings = NULL;
-       struct lv_segment *pool_seg = first_seg(lv);
+       struct lv_segment *seg;
+       struct lv_segment *setting_seg = NULL;
        int r = 0, is_clean;
        uint32_t chunk_size = 0; /* FYI: lvchange does NOT support its change */
 
-       if (lv_is_cache(lv))
-               pool_seg = first_seg(pool_seg->pool_lv);
+       seg = first_seg(lv);
+
+       if (seg_is_cache_pool(seg))
+               setting_seg = seg;
+
+       else if (seg_is_cache(seg))
+               setting_seg = first_seg(seg->pool_lv);
+       else
+               goto_out;
 
        if (!get_cache_params(cmd, &chunk_size, &format, &mode, &name, &settings))
                goto_out;
 
        if ((mode != CACHE_MODE_UNSELECTED) &&
-           (mode != pool_seg->cache_mode) &&
+           (mode != setting_seg->cache_mode) &&
            lv_is_cache(lv)) {
                if (!lv_cache_wait_for_clean(lv, &is_clean))
                        return_0;
@@ -658,11 +666,11 @@ static int _lvchange_cache(struct cmd_context *cmd,
                }
        }
 
-       if (mode && !cache_set_cache_mode(first_seg(lv), mode))
+       if (mode && !cache_set_cache_mode(seg, mode))
                goto_out;
 
        if ((name || settings) &&
-           !cache_set_policy(first_seg(lv), name, settings))
+           !cache_set_policy(seg, name, settings))
                goto_out;
 
        /* Request caller to commit and reload metadata */
This page took 0.037021 seconds and 5 git commands to generate.