summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2017-10-24 16:34:25 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2017-10-25 21:58:01 +0200
commit0e7edd1d2438bab5d08a8d3db47c082d9c4e0b12 (patch)
tree12053417e890d9f670c255bb2feaad25211bdef1
parent38f7fbac64ee8291776c168b32fbd39ce2706bfe (diff)
downloadlvm2-0e7edd1d2438bab5d08a8d3db47c082d9c4e0b12.tar.gz
snapshot: improve validation
Do not allow to take snapshot of mirror/raid leg or log or metadata LV. This was actually never supported, but user was able to create it, and this put device stack in hardly fixable state (needs manual work). This prevents such creation to pass. Also improve validation when recreating snapshot volume type from origin and COW volume.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/metadata/lv_manip.c9
-rw-r--r--tools/lvconvert.c5
3 files changed, 13 insertions, 2 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 3ba8e304d..78a8052d1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Disallow creation of snapshot of mirror/raid subLV (was never supported).
Fix regression in more advanced vgname extraction in lvconvert (2.02.169).
Allow lvcreate to be used for caching of _tdata LV.
Avoid internal error when resizing cache type _tdata LV (not yet supported).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b03f9cf97..4cca5a108 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7622,11 +7622,20 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (lv_is_mirror_type(origin_lv)) {
+ if (!lv_is_mirror(origin_lv)) {
+ log_error("Snapshots of mirror subvolumes are not supported.");
+ return NULL;
+ }
log_warn("WARNING: Snapshots of mirrors can deadlock under rare device failures.");
log_warn("WARNING: Consider using the raid1 mirror type to avoid this.");
log_warn("WARNING: See global/mirror_segtype_default in lvm.conf.");
}
+ if (lv_is_raid_type(origin_lv) && !lv_is_raid(origin_lv)) {
+ log_error("Snapshots of raid subvolumes are not supported.");
+ return NULL;
+ }
+
if (vg_is_clustered(vg) && lv_is_active(origin_lv) &&
!lv_is_active_exclusive_locally(origin_lv)) {
log_error("%s must be active exclusively to"
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 02c649c4f..390a784c5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1945,8 +1945,9 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
* LV_foo specification because this LV is not processed by process_each_lv.
*/
if ((lv_is_cache_type(org) && !lv_is_cache(org)) ||
- lv_is_thin_type(org) ||
- lv_is_mirrored(org) ||
+ (lv_is_thin_type(org) && !lv_is_thin_volume(org)) ||
+ (lv_is_mirror_type(org) && !lv_is_mirror(org)) ||
+ (lv_is_raid_type(org) && !lv_is_raid(org)) ||
lv_is_cow(org)) {
log_error("Unable to use LV %s as snapshot origin: invald LV type.",
display_lvname(lv));