mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
cache: factor lvchange_cache
to prepare for future addition
This commit is contained in:
parent
e548e7c29d
commit
8c9d9a7446
@ -636,18 +636,26 @@ static int _lvchange_cache(struct cmd_context *cmd,
|
|||||||
cache_mode_t mode;
|
cache_mode_t mode;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct dm_config_tree *settings = NULL;
|
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;
|
int r = 0, is_clean;
|
||||||
uint32_t chunk_size = 0; /* FYI: lvchange does NOT support its change */
|
uint32_t chunk_size = 0; /* FYI: lvchange does NOT support its change */
|
||||||
|
|
||||||
if (lv_is_cache(lv))
|
seg = first_seg(lv);
|
||||||
pool_seg = first_seg(pool_seg->pool_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))
|
if (!get_cache_params(cmd, &chunk_size, &format, &mode, &name, &settings))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
if ((mode != CACHE_MODE_UNSELECTED) &&
|
if ((mode != CACHE_MODE_UNSELECTED) &&
|
||||||
(mode != pool_seg->cache_mode) &&
|
(mode != setting_seg->cache_mode) &&
|
||||||
lv_is_cache(lv)) {
|
lv_is_cache(lv)) {
|
||||||
if (!lv_cache_wait_for_clean(lv, &is_clean))
|
if (!lv_cache_wait_for_clean(lv, &is_clean))
|
||||||
return_0;
|
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;
|
goto_out;
|
||||||
|
|
||||||
if ((name || settings) &&
|
if ((name || settings) &&
|
||||||
!cache_set_policy(first_seg(lv), name, settings))
|
!cache_set_policy(seg, name, settings))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
/* Request caller to commit and reload metadata */
|
/* Request caller to commit and reload metadata */
|
||||||
|
Loading…
Reference in New Issue
Block a user