Skip to contentSkip to conversation

LVM2 lib/metadata/lv_manip.c lib/metadata/meta ...

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

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2008-01-17 13:13:55

Modified files:
lib/metadata : lv_manip.c metadata-exported.h mirror.c
tools : vgreduce.c

Log message:
lvconvert/vgreduce fixes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74

lib/metadata/lv_manip.c +18 -0
@@ -459,6 +459,24 @@
 }
 
 /*
+ * Empty an LV and add error segment.
+ */
+int lv_remap_error(struct logical_volume *lv)
+{
+	uint32_t len = lv->le_count;
+
+	if (!lv_empty(lv))
+		return_0;
+
+	if (!lv_add_virtual_segment(lv, 0, len,
+				    get_segtype_from_string(lv->vg->cmd,
+							    "error")))
+		return_0;
+
+	return 1;
+}
+
+/*
  * Remove given number of extents from LV.
  */
 int lv_reduce(struct logical_volume *lv, uint32_t extents)
lib/metadata/metadata-exported.h +3 -0
@@ -378,6 +378,9 @@
 /* Empty an LV prior to deleting it */
 int lv_empty(struct logical_volume *lv);
 
+/* Empty an LV and add error segment */
+int lv_remap_error(struct logical_volume *lv);
+
 /* Entry point for all LV extent allocations */
 int lv_extend(struct logical_volume *lv,
 	      const struct segment_type *segtype,
lib/metadata/mirror.c +87 -17

179 lines not on this page · raw message

tools/vgreduce.c +19 -0
@@ -255,8 +255,10 @@
 			}
 		}
 
+  lvs_changed_altered:
 		/* Remove lost mirror images from mirrors */
 		list_iterate_items(lvl, &vg->lvs) {
+  mirrored_seg_altered:
 			mirrored_seg = first_seg(lvl->lv);
 			if (!seg_is_mirrored(mirrored_seg))
 				continue;
@@ -315,6 +317,23 @@
 					vg_revert(vg);
 					return 0;
 				}
+
+				/* mirrored LV no longer has valid mimages.
+				 * So add it to lvs_changed for removal.
+				 * For this LV may be an area of other mirror,
+				 * restart the loop. */
+				if (!mimages) {
+					if (!_remove_lv(cmd, lvl->lv,
+						 &list_unsafe, &lvs_changed))
+						return_0;
+					goto lvs_changed_altered;
+				}
+
+				/* As a result of reconfigure_mirror_images(),
+				 * first_seg(lv) may now be different seg.
+				 * e.g. a temporary layer might be removed.
+				 * So check the mirrored_seg again. */
+				goto mirrored_seg_altered;
 			}
 		}