From 1e4e9548b167ca2a76a0bbb3a5a347c062b84361 Mon Sep 17 00:00:00 2001 From: Jonathan Earl Brassow Date: Tue, 1 May 2012 19:21:24 +0000 Subject: [PATCH] Disallow snapshots of mirror segment types. Snapshots of RAID logical volumes are allowed (including "raid1"). However, snapshots of "mirror" logical volumes has been disallowed due to unsolvable issues inherent to the design. The fact that mirroring (dm-raid1.c) must stop all I/O as the result of a failure and wait for userspace intervention can lead to a circular dependency if userspace is simultaneously waiting for snapshots (on mirrors) to make an I/O update before proceeding. Various snapshot on mirror tests have been removed as a result. --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 10 ++++------ test/shell/lvconvert-repair-snapshot.sh | 7 +++++++ test/shell/snapshots-of-mirrors.sh | 10 ++++++++-- test/shell/vgreduce-removemissing-snapshot.sh | 8 ++++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 636fae3f2..df4bbd6db 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.96 - ================================ + Disallow snapshots of mirror segment type. Fix bug in cmirror that caused incorrect status info to print on some nodes. Remove statement that snapshots cannot be tagged from lvm man page. Disallow changing cluster attribute of VG while RAID LVs are active. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 7a4b6e9d1..4f8158573 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -4208,12 +4208,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l return NULL; } - if ((org->status & MIRROR_IMAGE) || - (org->status & MIRROR_LOG)) { - log_error("Snapshots of mirror %ss " - "are not supported", - (org->status & MIRROR_LOG) ? - "log" : "image"); + if (lv_is_mirror_type(org) && + !seg_is_raid(first_seg(org))) { + log_error("Snapshots of \"mirror\" segment types" + " are not supported"); return NULL; } diff --git a/test/shell/lvconvert-repair-snapshot.sh b/test/shell/lvconvert-repair-snapshot.sh index 786b9501d..4c20890af 100644 --- a/test/shell/lvconvert-repair-snapshot.sh +++ b/test/shell/lvconvert-repair-snapshot.sh @@ -11,6 +11,13 @@ . lib/test +exit 0 +# +# Snapshots of 'mirrors' are not supported. They can no longer be created. +# This file could be used to test some aspect of lvconvert, snapshot, and +# RAID at some point though... +# + aux prepare_vg 5 aux lvmconf 'allocation/maximise_cling = 0' aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' diff --git a/test/shell/snapshots-of-mirrors.sh b/test/shell/snapshots-of-mirrors.sh index dbd6b6cea..f52cb7aa8 100644 --- a/test/shell/snapshots-of-mirrors.sh +++ b/test/shell/snapshots-of-mirrors.sh @@ -13,9 +13,15 @@ aux prepare_vg 4 -# Create snapshot of a mirror origin +# Attempt to create snapshot of a mirror origin - should fail lvcreate -m 1 -L 10M -n lv $vg -lvcreate -s $vg/lv -L 10M -n snap +not lvcreate -s $vg/lv -L 10M -n snap + +exit 0 + +# +# Snapshots of mirrors are no longer allowed. +# # Down-convert (mirror -> linear) under a snapshot lvconvert -m0 $vg/lv diff --git a/test/shell/vgreduce-removemissing-snapshot.sh b/test/shell/vgreduce-removemissing-snapshot.sh index f4b68f805..488d8fe74 100644 --- a/test/shell/vgreduce-removemissing-snapshot.sh +++ b/test/shell/vgreduce-removemissing-snapshot.sh @@ -11,6 +11,14 @@ . lib/test +exit 0 + +# +# Snapshots of 'mirrors' are not supported. They can no longer be created. +# This file could be used to test some aspect of vgreduce, snapshot, and +# RAID at some point though... +# + aux prepare_vg 5 lvcreate -m 3 --ig -L 2M -n 4way $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5":0 -- 2.43.5