[lvm-devel] [PATCH 3 of 3] Allow lvconvert repair to work on RAID images with error segments

Jonathan Brassow jbrassow at redhat.com
Sun Feb 3 08:32:39 UTC 2013


RAID: Allow replacement of RAID images that contain error segments

This patch adds the ability to replace RAID images that contain error
segments.  The user will still be unable to run 'lvconvert --replace'
because there is no way to address the 'error' segment (i.e. no PV
that it is associated with).  However, 'lvconvert --repair' can be
used to replace the image's error segment with a new PV.  This is also
the most appropriate way to do it, since the LV will continue to be
reported as 'partial'.

Index: lvm2/lib/metadata/raid_manip.c
===================================================================
--- lvm2.orig/lib/metadata/raid_manip.c
+++ lvm2/lib/metadata/raid_manip.c
@@ -1631,8 +1631,8 @@ int lv_raid_reshape(struct logical_volum
 /*
  * lv_raid_replace
  * @lv
- * @replace_pvs
- * @allocatable_pvs
+ * @remove_pvs
+ * @allocate_pvs
  *
  * Replace the specified PVs.
  */
@@ -1675,7 +1675,10 @@ int lv_raid_replace(struct logical_volum
 			return 0;
 		}
 
-		if (_lv_is_on_pvs(seg_lv(raid_seg, s), remove_pvs) ||
+		// FIXME: safe to use 'virtual' as a substitute for 'error'?
+		if (lv_is_virtual(seg_lv(raid_seg, s)) ||
+		    lv_is_virtual(seg_metalv(raid_seg, s)) ||
+		    _lv_is_on_pvs(seg_lv(raid_seg, s), remove_pvs) ||
 		    _lv_is_on_pvs(seg_metalv(raid_seg, s), remove_pvs))
 			match_count++;
 	}
@@ -1705,7 +1708,9 @@ int lv_raid_replace(struct logical_volum
 			if (!(i % copies))
 				rebuilds_per_group = 0;
 			if (_lv_is_on_pvs(seg_lv(raid_seg, s), remove_pvs) ||
-			    _lv_is_on_pvs(seg_metalv(raid_seg, s), remove_pvs))
+			    _lv_is_on_pvs(seg_metalv(raid_seg, s), remove_pvs) ||
+			    lv_is_virtual(seg_lv(raid_seg, s)) ||
+			    lv_is_virtual(seg_metalv(raid_seg, s)))
 				rebuilds_per_group++;
 			if (rebuilds_per_group >= copies) {
 				log_error("Unable to replace all the devices "





More information about the lvm-devel mailing list