Skip to contentSkip to conversation

master - lvconvert: disallow usage of origin for snapshot

PATCH Zdenek Kabelac 1 participant 1 message Mar 17, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3b9ee37e9b9672929737dedcd52b46f57d93d23
Commit:        f3b9ee37e9b9672929737dedcd52b46f57d93d23
Parent:        455f23586f0125fb2763c0f2f48e79bc08d9e2c0
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Mon Mar 17 09:41:36 2014 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Mar 17 14:31:42 2014 +0100

lvconvert: disallow usage of origin for snapshot

Usage of origin as a snapshot 'COW' volume is unsupported.

Without this test lvm2 is able to generate this ugly internal error message.

To test this:

lvcreate -L1 -n lv1 vg
lvcreate -L1 -n lv2 -s vg/lv1
lvcreate -L1 -n lv3 vg
lvconvert -s vg/lv3 vg/lv1

Internal error: LVs (5) != visible LVs (1) + snapshots (1) + internal LVs (0) in VG vg
---
 WHATS_NEW         |    1 +
 tools/lvconvert.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
index 2d91981..c3c8aff 100644
@@ -1,5 +1,6 @@
 Version 2.02.106 - 
 ====================================
+  Disallow lvconvert of origin to snapshot COW volume.
   Make report settings profilable.
   Add existing report settings to lvm.conf.
   Use VG read lock during 'pvscan --cache -aay' autoactivation.
tools/lvconvert.c +6 -0
index c8cc506..1b9d9f7 100644
@@ -2038,6 +2038,12 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
 {
 	struct logical_volume *org;
 
+	if (lv_is_origin(lv)) {
+		/* Unsupported stack */
+		log_error("Unable to convert origin \"%s\" into a snapshot.", lv->name);
+		return 0;
+	}
+
 	if (!(org = find_lv(lv->vg, lp->origin))) {
 		log_error("Couldn't find origin volume '%s'.", lp->origin);
 		return 0;