mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Disallow the direct removal of a merging snapshot.
Allow lv_remove_with_dependencies() to know the top-level LV that was requested to be removed (otherwise it recurses and we lose context). A merging snapshot cannot be removed directly but the associated origin can be. Disallow removal of a merging snapshot unless the associated origin is also being removed.
This commit is contained in:
parent
d6d08486c8
commit
60267bdce8
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.64 -
|
Version 2.02.64 -
|
||||||
=================================
|
=================================
|
||||||
|
Disallow the direct removal of a merging snapshot.
|
||||||
Set appropriate udev flags for reserved LVs.
|
Set appropriate udev flags for reserved LVs.
|
||||||
Don't preload the origin when removing a snapshot whose merge is pending.
|
Don't preload the origin when removing a snapshot whose merge is pending.
|
||||||
Disallow the addition of mirror images while a conversion is happening.
|
Disallow the addition of mirror images while a conversion is happening.
|
||||||
|
@ -2306,16 +2306,25 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
* remove LVs with its dependencies - LV leaf nodes should be removed first
|
* remove LVs with its dependencies - LV leaf nodes should be removed first
|
||||||
*/
|
*/
|
||||||
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
|
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
const force_t force)
|
const force_t force, unsigned level)
|
||||||
{
|
{
|
||||||
struct dm_list *snh, *snht;
|
struct dm_list *snh, *snht;
|
||||||
|
|
||||||
|
if (lv_is_cow(lv)) {
|
||||||
|
/* A merging snapshot cannot be removed directly */
|
||||||
|
if (lv_is_merging_cow(lv) && !level) {
|
||||||
|
log_error("Can't remove merging snapshot logical volume \"%s\"",
|
||||||
|
lv->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lv_is_origin(lv)) {
|
if (lv_is_origin(lv)) {
|
||||||
/* remove snapshot LVs first */
|
/* remove snapshot LVs first */
|
||||||
dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) {
|
dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) {
|
||||||
if (!lv_remove_with_dependencies(cmd, dm_list_struct_base(snh, struct lv_segment,
|
if (!lv_remove_with_dependencies(cmd, dm_list_struct_base(snh, struct lv_segment,
|
||||||
origin_list)->cow,
|
origin_list)->cow,
|
||||||
force))
|
force, level + 1))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
force_t force);
|
force_t force);
|
||||||
|
|
||||||
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
|
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
force_t force);
|
force_t force, unsigned level);
|
||||||
|
|
||||||
int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
|
int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
const char *new_name);
|
const char *new_name);
|
||||||
|
@ -484,7 +484,7 @@ int remove_lvs_in_vg(struct cmd_context *cmd,
|
|||||||
|
|
||||||
while ((lst = dm_list_first(&vg->lvs))) {
|
while ((lst = dm_list_first(&vg->lvs))) {
|
||||||
lvl = dm_list_item(lst, struct lv_list);
|
lvl = dm_list_item(lst, struct lv_list);
|
||||||
if (!lv_remove_with_dependencies(cmd, lvl->lv, force))
|
if (!lv_remove_with_dependencies(cmd, lvl->lv, force, 0))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,17 +44,22 @@ setup_merge() {
|
|||||||
aux prepare_vg 1 100
|
aux prepare_vg 1 100
|
||||||
|
|
||||||
|
|
||||||
# full merge of a single LV
|
# test full merge of a single LV
|
||||||
setup_merge $vg $lv1
|
setup_merge $vg $lv1
|
||||||
|
|
||||||
# now that snapshot LV is created: test if snapshot-merge target is available
|
# now that snapshot LV is created: test if snapshot-merge target is available
|
||||||
$(dmsetup targets | grep -q snapshot-merge) || exit 200
|
$(dmsetup targets | grep -q snapshot-merge) || exit 200
|
||||||
|
|
||||||
lvs -a
|
lvs -a
|
||||||
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
|
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
|
||||||
lvremove -f $vg/$lv1
|
lvremove -f $vg/$lv1
|
||||||
|
|
||||||
|
|
||||||
|
# test that an actively merging snapshot may not be removed
|
||||||
|
setup_merge $vg $lv1
|
||||||
|
lvconvert -i+100 --merge --background $vg/$(snap_lv_name_ $lv1)
|
||||||
|
not lvremove -f $vg/$(snap_lv_name_ $lv1)
|
||||||
|
lvremove -f $vg/$lv1
|
||||||
|
|
||||||
|
|
||||||
# "onactivate merge" test
|
# "onactivate merge" test
|
||||||
setup_merge $vg $lv1
|
setup_merge $vg $lv1
|
||||||
lvs -a
|
lvs -a
|
||||||
@ -99,6 +104,7 @@ lvs -a
|
|||||||
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
|
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
|
||||||
lvremove -f $vg/$lv1
|
lvremove -f $vg/$lv1
|
||||||
|
|
||||||
|
|
||||||
# test merging multiple snapshots that share the same tag
|
# test merging multiple snapshots that share the same tag
|
||||||
setup_merge $vg $lv1
|
setup_merge $vg $lv1
|
||||||
setup_merge $vg $lv2
|
setup_merge $vg $lv2
|
||||||
|
@ -26,7 +26,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
|
if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
|
||||||
lv = origin;
|
lv = origin;
|
||||||
|
|
||||||
if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG))) {
|
if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG), 0)) {
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user