[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [LVM2 PATCH] (1/3) Check cow != origin in commands



Hi,

Currently we can do this strange thing:
  # lvconvert -s testvg/lvol0 testvg/lvol0
  Logical volume lvol0 converted to snapshot.

It means testvg/lvol0 is both origin and cow of the snapshot.

Once we create such a LV, we cannot remove it.

lvconvert should check its parameter and
the attached patch does it.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Prevent creating a snapshot whose origin is its cow:
  i.e. lvconvert -s vg/lv0 vg/lv0
such snapshot is of course broken and cannot be removed once created.

Index: LVM2.work/tools/lvconvert.c
===================================================================
--- LVM2.work.orig/tools/lvconvert.c
+++ LVM2.work/tools/lvconvert.c
@@ -509,6 +509,12 @@ static int lvconvert_snapshot(struct cmd
 		return 0;
 	}
 
+	if (org == lv) {
+		log_error("Unable to use \"%s\" for both snapshot and origin.",
+			  lv->name);
+		return 0;
+	}
+
 	if (org->status & (LOCKED|PVMOVE) || lv_is_cow(org)) {
 		log_error("Unable to create a snapshot of a %s LV.",
 			  org->status & LOCKED ? "locked" :

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]