Skip to contentSkip to conversation

LVM2 ./WHATS_NEW lib/metadata/lv_manip.c lib/m ...

PATCH [email protected] 1 participant 1 message Jan 26, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2008-01-26 00:25:04

Modified files:

	.              : WHATS_NEW 
	lib/metadata   : lv_manip.c metadata-exported.h mirror.c 
	tools          : lvchange.c 

Log message:
Refactor mirror log attachment code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.777&r2=1.778
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.32 -
 ===================================
+  Refactor mirror log attachment code.
   Fix internal metadata corruption in lvchange --resync. (2.02.30)
   Fix new parameter validation in vgsplit and test mode. (2.02.30)
   Remove redundant cnxman-socket.h file from clvmd directory.
lib/metadata/lv_manip.c +2 -5
@@ -208,11 +208,8 @@
 	seg->log_lv = log_lv;
 	list_init(&seg->tags);
 
-	if (log_lv) {
-		log_lv->status |= MIRROR_LOG;
-		if (!add_seg_to_segs_using_this_lv(log_lv, seg))
-			return_NULL;
-	}
+	if (log_lv && !attach_mirror_log(seg, log_lv))
+		return_NULL;
 
 	return seg;
 }
lib/metadata/metadata-exported.h +2 -0
@@ -495,6 +495,8 @@
 		      uint32_t mirrors, uint32_t stripes, uint32_t region_size,
 		      struct list *allocatable_pvs, alloc_policy_t alloc,
 		      uint32_t log_count);
+struct logical_volume *detach_mirror_log(struct lv_segment *seg);
+int attach_mirror_log(struct lv_segment *seg, struct logical_volume *lv);
 int remove_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
 		      struct list *removable_pvs);
 int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
lib/metadata/mirror.c +25 -29

134 lines not on this page · raw message

tools/lvchange.c +11 -24
@@ -271,21 +271,14 @@
 
 	if (log_lv) {
 		/* Separate mirror log so we can clear it */
-		first_seg(lv)->log_lv = NULL;
-		log_lv->status &= ~MIRROR_LOG;
-		log_lv->status |= VISIBLE_LV;
-		remove_seg_from_segs_using_this_lv(log_lv, first_seg(lv));
+		detach_mirror_log(first_seg(lv));
 
 		if (!vg_write(lv->vg)) {
 			log_error("Failed to write intermediate VG metadata.");
-			if (active) {
-				first_seg(lv)->log_lv = log_lv;
-				log_lv->status |= MIRROR_LOG;
-				log_lv->status &= ~VISIBLE_LV;
-				add_seg_to_segs_using_this_lv(log_lv, first_seg(lv));
-				if (!activate_lv(cmd, lv))
-					stack;
-			}
+			if (!attach_mirror_log(first_seg(lv), log_lv))
+				stack;
+			if (active && !activate_lv(cmd, lv))
+				stack;
 			return 0;
 		}
 
@@ -293,14 +286,10 @@
 
 		if (!vg_commit(lv->vg)) {
 			log_error("Failed to commit intermediate VG metadata.");
-			if (active) {
-				first_seg(lv)->log_lv = log_lv;
-				log_lv->status |= MIRROR_LOG;
-				log_lv->status &= ~VISIBLE_LV;
-				add_seg_to_segs_using_this_lv(log_lv, first_seg(lv));
-				if (!activate_lv(cmd, lv))
-					stack;
-			}
+			if (!attach_mirror_log(first_seg(lv), log_lv))
+				stack;
+			if (active && !activate_lv(cmd, lv))
+				stack;
 			return 0;
 		}
 
@@ -326,10 +315,8 @@
 		}
 
 		/* Put mirror log back in place */
-		first_seg(lv)->log_lv = log_lv;
-		log_lv->status |= MIRROR_LOG;
-		log_lv->status &= ~VISIBLE_LV;
-		add_seg_to_segs_using_this_lv(log_lv, first_seg(lv));
+		if (!attach_mirror_log(first_seg(lv), log_lv))
+			stack;
 	}
 
 	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);