public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW test/t-vgsplit-operation.sh t ...
@ 2011-10-06 14:17 jbrassow
  0 siblings, 0 replies; 2+ messages in thread
From: jbrassow @ 2011-10-06 14:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-10-06 14:17:45

Modified files:
	.              : WHATS_NEW 
	test           : t-vgsplit-operation.sh 
	tools          : vgsplit.c 

Log message:
	Fix vgsplit when there are mirrors that have mirrored logs.
	
	The problem as reported by "ben <benscott@nwlink.com>" on lvm-devel:
	
	vgsplit fails with mirrored mirror log
	
	#lvs --all -o lv_name,lv_attr,devices
	LV                       Attr   Devices
	MyMirror                 mwi--
	[MyMirror_mimage_0]      Iwi--- /dev/sdq(0)
	[MyMirror_mimage_1]      Iwi--- /dev/sdo(0)
	[MyMirror_mimage_2]      Iwi--- /dev/sdi(0)
	[MyMirror_mlog]          mwi---
	[MyMirror_mlog_mimage_0] Iwi--- /dev/sds(0)
	[MyMirror_mlog_mimage_1] Iwi--- /dev/sde(0)
	
	#vgsplit -v "TestA" "TestB" "/dev/sdq" "/dev/sdo" "/dev/sdi" "/dev/sds"
	"/dev/sde"
	Checking for volume group "TestA"
	Checking for new volume group "TestB"
	Archiving volume group "TestA" metadata (seqno 213).
	Can't split mirror MyMirror between two Volume Groups
	
	AFTER FIX:
	
	[root@bp-01 ~]# lvs -a -o name,vg_name,devices vg new
	Volume group "new" not found
	Skipping volume group new
	LV                 VG   Devices
	lv                 vg   lv_mimage_0(0),lv_mimage_1(0)
	[lv_mimage_0]      vg   /dev/sdb1(0)
	[lv_mimage_1]      vg   /dev/sdc1(0)
	[lv_mlog]          vg   lv_mlog_mimage_0(0),lv_mlog_mimage_1(0)
	[lv_mlog_mimage_0] vg   /dev/sdh1(0)
	[lv_mlog_mimage_1] vg   /dev/sdi1(0)
	[root@bp-01 ~]# vgsplit vg new /dev/sd[bchi]1
	New volume group "new" successfully split from "vg"
	[root@bp-01 ~]# lvs -a -o name,vg_name,devices vg new
	LV                 VG   Devices
	lv                 new  lv_mimage_0(0),lv_mimage_1(0)
	[lv_mimage_0]      new  /dev/sdb1(0)
	[lv_mimage_1]      new  /dev/sdc1(0)
	[lv_mlog]          new  lv_mlog_mimage_0(0),lv_mlog_mimage_1(0)
	[lv_mlog_mimage_0] new  /dev/sdh1(0)
	[lv_mlog_mimage_1] new  /dev/sdi1(0)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2145&r2=1.2146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110

--- LVM2/WHATS_NEW	2011/10/04 20:49:24	1.2145
+++ LVM2/WHATS_NEW	2011/10/06 14:17:45	1.2146
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix vgsplit when there are mirrors that have mirrored logs.
   Clarify multi-name device filter pattern matching explanation in lvm.conf.5.
   Introduce lv_send_message and dev_manager_send_message.
   Introduce revert_lv for better pvmove cleanup.
--- LVM2/test/t-vgsplit-operation.sh	2011/01/05 00:16:20	1.27
+++ LVM2/test/t-vgsplit-operation.sh	2011/10/06 14:17:45	1.28
@@ -93,6 +93,31 @@
 		fi 
 		lvremove -f $vg2/$lv1 
 		vgremove -f $vg2
+# FIXME: ensure split /doesn't/ work when not all devs of mirror specified
+
+COMM "vgsplit correctly splits mirror LV with mirrored log into $i VG ($j args)"
+		vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
+		if [ $i = existing ]; then
+		  vgcreate -c n $vg2 $dev5
+		fi
+
+		lvcreate -l 64 --mirrorlog mirrored -m1 -n $lv1 $vg1 \
+		    $dev1 $dev2 $dev3 $dev4
+
+		vgchange -an $vg1
+		if [ $j = PV ]; then
+		  vgsplit $vg1 $vg2 $dev1 $dev2 $dev3 $dev4
+		else
+		  vgsplit -n $lv1 $vg1 $vg2
+		fi
+		if [ $i = existing ]; then
+		  check pvlv_counts $vg2 5 1 0
+		else
+		  check pvlv_counts $vg2 4 1 0
+		fi
+		lvremove -f $vg2/$lv1
+		vgremove -f $vg2
+# FIXME: ensure split /doesn't/ work when not all devs of mirror specified
 
 COMM "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)" 
 		vgcreate -c n $vg1 $dev1 $dev2 
--- LVM2/tools/vgsplit.c	2011/08/30 14:55:19	1.109
+++ LVM2/tools/vgsplit.c	2011/10/06 14:17:45	1.110
@@ -163,7 +163,7 @@
 {
 	struct dm_list *lvh, *lvht;
 	struct logical_volume *lv;
-	struct lv_segment *seg;
+	struct lv_segment *seg, *log_seg;
 	unsigned s, seg_in, log_in;
 
 	dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
@@ -179,7 +179,20 @@
 			if (_lv_is_in_vg(vg_to, seg_lv(seg, s)))
 			    seg_in++;
 
-		log_in = (!seg->log_lv || _lv_is_in_vg(vg_to, seg->log_lv));
+		log_in = !seg->log_lv;
+		if (seg->log_lv) {
+			log_seg = first_seg(seg->log_lv);
+			if (seg_is_mirrored(log_seg)) {
+				log_in = 1;
+
+				/* Ensure each log dev is in vg_to */
+				for (s = 0; s < log_seg->area_count; s++)
+					log_in = log_in &&
+						_lv_is_in_vg(vg_to,
+							     seg_lv(log_seg, s));
+			} else
+				log_in = _lv_is_in_vg(vg_to, seg->log_lv);
+		}
 
 		if ((seg_in && seg_in < seg->area_count) ||
 		    (seg_in && seg->log_lv && !log_in) ||


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2 ./WHATS_NEW test/t-vgsplit-operation.sh t ...
@ 2008-04-09 20:56 wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2008-04-09 20:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-04-09 20:56:06

Modified files:
	.              : WHATS_NEW 
	test           : t-vgsplit-operation.sh 
	tools          : vgsplit.c 

Log message:
	Fix vgsplit to only move hidden 'snapshotN' LVs when necessary.
	
	This bug has been around for a long time as far as I can tell.
	Without this fix, a vgsplit would unconditionally move the
	'hidden/internal' snapshot LVs, and result in corrupted metadata
	in the following case:
	vg1: contains lv1, lv1snap, both on pvset1
	vg1: contains lv2, on pvset2
	
	"vgsplit vg1 vg2 pvset2"
	would result in "snapshot0" hidden LV being moved to vg2, and
	the origin and cow being left in vg1.  The tools detect the
	corruption in vg2, but not in vg1.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.840&r2=1.841
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58

--- LVM2/WHATS_NEW	2008/04/09 14:47:34	1.840
+++ LVM2/WHATS_NEW	2008/04/09 20:56:05	1.841
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Fix vgsplit to only move hidden 'snapshotN' LVs when necessary.
   Update vgsplit tests for lvnames on the cmdline.
   Update vgsplit man page to reflect lvnames on the cmdline.
   Update vgsplit to take "-n LogicalVolumeName" on the cmdline.
--- LVM2/test/t-vgsplit-operation.sh	2008/04/09 14:47:34	1.15
+++ LVM2/test/t-vgsplit-operation.sh	2008/04/09 20:56:06	1.16
@@ -149,6 +149,35 @@
    lvremove -f $vg2/$lv1 &&
    vgremove -f $vg2'
 
+test_expect_success \
+  "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)" \
+  'vgcreate $vg1 $d1 $d2 &&
+   if [ $i == existing ]; then
+     vgcreate $vg2 $d3
+   fi &&
+   lvcreate -l 64 -i 2 -n $lv1 $vg1 &&
+   lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 &&
+   vgextend $vg1 $d4 &&
+   lvcreate -l 64 -n $lv3 $vg1 $d4 &&
+   vgchange -an $vg1 &&
+   if [ $j == PV ]; then
+     vgsplit $vg1 $vg2 $d4
+   else
+     vgsplit -n $lv3 $vg1 $vg2
+   fi &&
+   if [ $i == existing ]; then
+     vg_validate_pvlv_counts_ $vg2 2 1 0
+     vg_validate_pvlv_counts_ $vg1 2 1 1
+   else
+     vg_validate_pvlv_counts_ $vg2 1 1 0
+     vg_validate_pvlv_counts_ $vg1 2 1 1
+   fi &&
+   lvremove -f $vg1/$lv2 &&
+   lvremove -f $vg1/$lv1 &&
+   lvremove -f $vg2/$lv3 &&
+   vgremove -f $vg1 &&
+   vgremove -f $vg2'
+
 done
 done
 
--- LVM2/tools/vgsplit.c	2008/04/09 13:47:13	1.57
+++ LVM2/tools/vgsplit.c	2008/04/09 20:56:06	1.58
@@ -164,6 +164,9 @@
 	return 1;
 }
 
+/*
+ * Move the hidden / internal "snapshotN" LVs.from 'vg_from' to 'vg_to'.
+ */
 static int _move_snapshots(struct volume_group *vg_from,
 			   struct volume_group *vg_to)
 {
@@ -191,14 +194,21 @@
 					  " two Volume Groups", seg->cow->name);
 				return 0;
 			}
-		}
 
-		/* Move this snapshot */
-		list_del(lvh);
-		list_add(&vg_to->lvs, lvh);
+			/*
+			 * At this point, the cow and origin should already be
+			 * in vg_to.
+			 */
+			if (_lv_is_in_vg(vg_to, seg->cow) &&
+			    _lv_is_in_vg(vg_to, seg->origin)) {
+				list_del(lvh);
+				list_add(&vg_to->lvs, lvh);
+				
+				vg_from->snapshot_count--;
+				vg_to->snapshot_count++;
+			}
+		}
 
-		vg_from->snapshot_count--;
-		vg_to->snapshot_count++;
 	}
 
 	return 1;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-06 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-06 14:17 LVM2 ./WHATS_NEW test/t-vgsplit-operation.sh t jbrassow
  -- strict thread matches above, loose matches on Subject: below --
2008-04-09 20:56 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).