mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
cache: single code for removal of cached volume
Use same routine for dropping cached LV for cachevol and cachepool.
This commit is contained in:
parent
9969361b51
commit
5938cde11b
@ -6275,19 +6275,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (!lockd_lv(cmd, lock_lv, "ex", LDLV_PERSISTENT))
|
||||
return_0;
|
||||
|
||||
if (lv_is_cache(lv) && lv_is_cache_vol(first_seg(lv)->pool_lv)) {
|
||||
struct logical_volume *cachevol_lv = first_seg(lv)->pool_lv;
|
||||
|
||||
if (!lv_cache_remove(lv)) {
|
||||
log_error("Failed to detach cache from %s", display_lvname(lv));
|
||||
return 0;
|
||||
}
|
||||
if (!lv_remove_single(cmd, cachevol_lv, force, suppress_remove_message)) {
|
||||
log_error("Failed to remove cachevol %s.", display_lvname(cachevol_lv));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME Ensure not referred to by another existing LVs */
|
||||
ask_discard = find_config_tree_bool(cmd, devices_issue_discards_CFG, NULL);
|
||||
|
||||
@ -6339,7 +6326,22 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
if (lv_is_cache(lv) && !lv_is_pending_delete(lv)) {
|
||||
if (!lv_remove_single(cmd, first_seg(lv)->pool_lv, force,
|
||||
/* Handles both cachepool & cachevol based cached LVs.
|
||||
* It's placed before deactivation, so it can try to uncache
|
||||
* 'active' LV if possible
|
||||
*/
|
||||
struct logical_volume *cachevol_lv = first_seg(lv)->pool_lv;
|
||||
|
||||
if (lv_is_cache_pool(cachevol_lv))
|
||||
is_last_pool = 1;
|
||||
|
||||
if (!archive(vg))
|
||||
return_0;
|
||||
|
||||
if (!lv_cache_remove(lv))
|
||||
return_0;
|
||||
|
||||
if (!lv_remove_single(cmd, cachevol_lv, force,
|
||||
suppress_remove_message)) {
|
||||
if (force < DONT_PROMPT_OVERRIDE) {
|
||||
log_error("Failed to uncache %s.", display_lvname(lv));
|
||||
@ -6349,7 +6351,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
log_print_unless_silent("Ignoring uncache failure of %s.",
|
||||
display_lvname(lv));
|
||||
}
|
||||
is_last_pool = 1;
|
||||
}
|
||||
|
||||
/* Used cache pool, COW or historical LV cannot be activated */
|
||||
|
Loading…
x
Reference in New Issue
Block a user