mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
lvconvert: separate splitcache and uncache functions
Reorg code so there are separate functions for splitcache and uncache for both cachepool and cachevol. Should be no functional change.
This commit is contained in:
parent
e35cf0f623
commit
4464004362
@ -1836,7 +1836,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
|
||||
static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
struct logical_volume *lv_fast)
|
||||
{
|
||||
@ -1847,7 +1847,6 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
|
||||
if (!archive(lv->vg))
|
||||
return_0;
|
||||
|
||||
if (lv_is_cache_vol(cache_seg->pool_lv)) {
|
||||
log_debug("Detaching cachevol %s from LV %s.", display_lvname(lv_fast), display_lvname(lv));
|
||||
|
||||
/*
|
||||
@ -1869,8 +1868,7 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
|
||||
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
yes_no_prompt("Detach writeback cache %s from %s without flushing data?",
|
||||
display_lvname(lv_fast),
|
||||
display_lvname(lv)) == 'n') {
|
||||
display_lvname(lv_fast), display_lvname(lv)) == 'n') {
|
||||
log_error("Conversion aborted.");
|
||||
return 0;
|
||||
}
|
||||
@ -1880,17 +1878,6 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
|
||||
|
||||
if (!lv_detach_cache_vol(lv, noflush))
|
||||
return_0;
|
||||
} else {
|
||||
log_debug("Detaching cachepool %s from LV %s.", display_lvname(lv_fast), display_lvname(lv));
|
||||
|
||||
if (vg_missing_pv_count(lv->vg)) {
|
||||
log_error("Cannot split cache pool while PVs are missing, see --uncache to delete cache pool.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lv_cache_remove(lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
|
||||
return_0;
|
||||
@ -1903,7 +1890,44 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lvconvert_split_and_remove_cache(struct cmd_context *cmd,
|
||||
static int _lvconvert_split_and_keep_cachepool(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
struct logical_volume *lv_fast)
|
||||
{
|
||||
if (!archive(lv->vg))
|
||||
return_0;
|
||||
|
||||
log_debug("Detaching cachepool %s from LV %s.", display_lvname(lv_fast), display_lvname(lv));
|
||||
|
||||
if (vg_missing_pv_count(lv->vg)) {
|
||||
log_error("Cannot split cache pool while PVs are missing, see --uncache to delete cache pool.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lv_cache_remove(lv))
|
||||
return_0;
|
||||
|
||||
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
|
||||
return_0;
|
||||
|
||||
backup(lv->vg);
|
||||
|
||||
log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
|
||||
display_lvname(lv), display_lvname(lv_fast));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lvconvert_split_and_remove_cachevol(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
struct logical_volume *lv_fast)
|
||||
{
|
||||
log_error("Detach cache from %s with --splitcache.", display_lvname(lv));
|
||||
log_error("The cache %s may then be removed with lvremove.", display_lvname(lv_fast));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _lvconvert_split_and_remove_cachepool(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
struct logical_volume *cachepool_lv)
|
||||
{
|
||||
@ -4701,19 +4725,24 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
|
||||
|
||||
ret = _lvconvert_detach_writecache(cmd, lv_main, lv_fast);
|
||||
|
||||
} else if (lv_is_cache(lv_main)) {
|
||||
if ((cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD) &&
|
||||
lv_is_cache_vol(lv_fast)) {
|
||||
log_error("Detach cache from %s with --splitcache.", display_lvname(lv));
|
||||
log_error("The cache %s may then be removed with lvremove.", display_lvname(lv_fast));
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else if (lv_is_cache(lv_main) && lv_is_cache_vol(lv_fast)) {
|
||||
if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD)
|
||||
ret = _lvconvert_split_and_remove_cache(cmd, lv_main, lv_fast);
|
||||
ret = _lvconvert_split_and_remove_cachevol(cmd, lv_main, lv_fast);
|
||||
|
||||
else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD)
|
||||
ret = _lvconvert_split_and_keep_cache(cmd, lv_main, lv_fast);
|
||||
ret = _lvconvert_split_and_keep_cachevol(cmd, lv_main, lv_fast);
|
||||
|
||||
else {
|
||||
log_error(INTERNAL_ERROR "Unknown cache split command.");
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
} else if (lv_is_cache(lv_main) && lv_is_cache_pool(lv_fast)) {
|
||||
if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD)
|
||||
ret = _lvconvert_split_and_remove_cachepool(cmd, lv_main, lv_fast);
|
||||
|
||||
else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD)
|
||||
ret = _lvconvert_split_and_keep_cachepool(cmd, lv_main, lv_fast);
|
||||
|
||||
else {
|
||||
log_error(INTERNAL_ERROR "Unknown cache split command.");
|
||||
|
Loading…
Reference in New Issue
Block a user