mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-24 17:57:48 +03:00
lvremove: use to_remove for snapshot removal
Reuse similar 'acceleration' as used for dependent volumes also for snapshot - so when origin is being removed with all thick snapshots, don't bother with individual 'COW' detachments and write&commits, and when possible handle this all within a single commit.
This commit is contained in:
parent
0a2d7c57a1
commit
5edb353062
@ -6823,13 +6823,10 @@ static int _lv_remove_segs_using_this_lv(struct cmd_context *cmd, struct logical
|
||||
yes_no_prompt("Removing %s \"%s\" will remove %u dependent volume(s). "
|
||||
"Proceed? [y/n]: ", lv_type, lv->name,
|
||||
dm_list_size(&lv->segs_using_this_lv)) == 'n') {
|
||||
log_error("Logical volume \"%s\" not removed.", lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Make aware users of this LV, it's going to be removed, so they
|
||||
* can skip any updates of itself */
|
||||
lv->to_remove = 1;
|
||||
lv->to_remove = 0;
|
||||
log_error("Logical volume \"%s\" not removed.", lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not using _safe iterator here - since we may delete whole subtree
|
||||
@ -6859,6 +6856,10 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
|
||||
struct lv_list *lvl;
|
||||
struct logical_volume *origin;
|
||||
|
||||
/* Make aware users of this LV, it's going to be removed, so they
|
||||
* can skip any updates of itself */
|
||||
lv->to_remove = 1;
|
||||
|
||||
if (!level && lv_is_cow(lv)) {
|
||||
/*
|
||||
* A merging snapshot cannot be removed directly unless
|
||||
|
@ -325,6 +325,16 @@ int vg_remove_snapshot(struct logical_volume *cow)
|
||||
cow->snapshot = NULL;
|
||||
lv_set_visible(cow);
|
||||
|
||||
/* When origin with all its snapshots is going to be remove
|
||||
* don't bother with individual manipulation with COWs
|
||||
* Note: removal proceeds only when origin is inactive */
|
||||
if (is_origin_active && origin->to_remove) {
|
||||
origin->vg->needs_write_and_commit = 1;
|
||||
log_debug_metadata("Postponing write and commit for remove of snapshot %s.",
|
||||
display_lvname(cow));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!vg_write(origin->vg))
|
||||
return_0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user