Skip to contentSkip to conversation

LVM2/tools vgmerge.c vgsplit.c

PATCH [email protected] 1 participant 1 message Mar 30, 2011

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2011-03-30 14:35:01

Modified files:
tools : vgmerge.c vgsplit.c

Log message:
Fix free_vg order

As now the FID management is more complex, the code inside free_vg needs to access some parts of memory pools which were not needed before.

For this - makes the order of unlock_and_free_vg() unconditional. Keek using unlock_and_free_vg() API function.

For properly working VG locking mechanism only the alphabeting locking orderer needs to be preserved.

TODO: there could be few more code parts simplified when we 'officially' support of referencies between different memory pools.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106

tools/vgmerge.c +7 -7
@@ -151,13 +151,13 @@
 		  vg_from->name, vg_to->name);
 	r = ECMD_PROCESSED;
 bad:
-	if (lock_vg_from_first) {
-		unlock_and_free_vg(cmd, vg_to, vg_name_to);
-		unlock_and_free_vg(cmd, vg_from, vg_name_from);
-	} else {
-		unlock_and_free_vg(cmd, vg_from, vg_name_from);
-		unlock_and_free_vg(cmd, vg_to, vg_name_to);
-	}
+	/*
+	 * Note: as vg_to is referencing moved elements from vg_from
+	 * the order of free_vg calls is mandatory.
+	 */
+	unlock_and_free_vg(cmd, vg_to, vg_name_to);
+	unlock_and_free_vg(cmd, vg_from, vg_name_from);
+
 	return r;
 }
 
tools/vgsplit.c +7 -7
@@ -487,12 +487,12 @@
 	r = ECMD_PROCESSED;
 
 bad:
-	if (lock_vg_from_first) {
-		unlock_and_free_vg(cmd, vg_to, vg_name_to);
-		unlock_and_free_vg(cmd, vg_from, vg_name_from);
-	} else {
-		unlock_and_free_vg(cmd, vg_from, vg_name_from);
-		unlock_and_free_vg(cmd, vg_to, vg_name_to);
-	}
+	/*
+	 * Note: as vg_to is referencing moved elements from vg_from
+	 * the order of free_vg calls is mandatory.
+	 */
+	unlock_and_free_vg(cmd, vg_to, vg_name_to);
+	unlock_and_free_vg(cmd, vg_from, vg_name_from);
+
 	return r;
 }