Skip to contentSkip to conversation

master - RAID: Fix problems with creating, extending and converting large RAID LVs

PATCH Jonathan Brassow 1 participant 1 message Sep 27, 2012

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=886656e4ac5e5c932d9fbe60d18c063136288a38
Commit:        886656e4ac5e5c932d9fbe60d18c063136288a38
Parent:        662a2122f6224b5404d9f1276868bc3069766c49
Author:        Jonathan Brassow <[email protected]>
AuthorDate:    Thu Sep 27 16:51:22 2012 -0500
Committer:     Jonathan Brassow <[email protected]>
CommitterDate: Thu Sep 27 16:51:22 2012 -0500

RAID: Fix problems with creating, extending and converting large RAID LVs

MD's bitmaps can handle 2^21 regions at most. The RAID code has always used a region_size of 1024 sectors. That means the size of a RAID LV was limited to 1TiB. (The user can adjust the region_size when creating a RAID LV, which can affect the maximum size.) Thus, creating, extending or converting to a RAID LV greater than 1TiB would result in a failure to load the new device-mapper table.

Again, the size of the RAID LV is not limited by how much space is allocated for the metadata area, but by the limitations of the MD bitmap. Therefore, we must adjust the 'region_size' to ensure that the number of regions does not exceed the limit. I've added code to do this when extending a RAID LV (which covers 'create' and 'extend' operations) and when up-converting - specifically from linear to RAID1.

---
 WHATS_NEW                    |    1 +
 lib/metadata/lv_manip.c      |   12 +++++++-
 lib/metadata/raid_manip.c    |    6 ++++
 test/shell/lvcreate-large.sh |   65 ++++++++++++++++++++++++++++++++++++------
 4 files changed, 74 insertions(+), 10 deletions(-)
WHATS_NEW +1 -0
index 448f306..dc62d77 100644
@@ -1,5 +1,6 @@
 Version 2.02.98 -
 =================================
+  Fix inability to create, extend or convert to a large (> 1TiB) RAID LV.
   Add (p)artial attribute to lvs.
   Don't try to issue discards to a missing PV to avoid segfault.
   Prevent lvremove from removing LVs that have any part missing.
lib/metadata/lv_manip.c +11 -1
index 6c62bb3..f2d99b8 100644
@@ -2660,7 +2660,17 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah,
 	seg->area_len += extents;
 	seg->len += extents;
 	lv->le_count += extents;
-	lv->size += (uint64_t) extents *lv->vg->extent_size;
+	lv->size += (uint64_t) extents * lv->vg->extent_size;
+
+	/*
+	 * The MD bitmap is limited to being able to track 2^21 regions.
+	 * The region_size must be adjusted to meet that criteria.
+	 */
+	while (seg_is_raid(seg) && (seg->region_size < (lv->size / (1 << 21)))) {
+		seg->region_size *= 2;
+		log_very_verbose("Forced to adjust RAID region_size to %uS",
+				 seg->region_size);
+	}
 
 	return 1;
 }
lib/metadata/raid_manip.c +6 -0
index 0266013..98a7db3 100644
@@ -731,6 +731,12 @@ static int _raid_add_images(struct logical_volume *lv,
 		seg = first_seg(lv);
 		seg_lv(seg, 0)->status |= RAID_IMAGE | LVM_READ | LVM_WRITE;
 		seg->region_size = RAID_REGION_SIZE;
+		/* MD's bitmap is limited to tracking 2^21 regions */
+		while (seg->region_size < (lv->size / (1 << 21))) {
+			seg->region_size *= 2;
+			log_very_verbose("Setting RAID1 region_size to %uS",
+					 seg->region_size);
+		}
 		seg->segtype = get_segtype_from_string(lv->vg->cmd, "raid1");
 		if (!seg->segtype)
 			return_0;
test/shell/lvcreate-large.sh +56 -9

84 lines not on this page · raw message