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;
}
}
- 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 */