Blame SOURCES/0022-imsm-fix-spare-activation-for-old-matrix-arrays.patch

5eacff
From 05501181f18cdccdb0b3cec1d8cf59f0995504d7 Mon Sep 17 00:00:00 2001
5eacff
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
5eacff
Date: Fri, 8 Mar 2019 12:19:11 +0100
5eacff
Subject: [RHEL7.7 PATCH 22/24] imsm: fix spare activation for old matrix
5eacff
 arrays
5eacff
5eacff
During spare activation get_extents() calculates metadata reserved space based
5eacff
on smallest active RAID member or it will take the defaults. Since patch
5eacff
611d9529("imsm: change reserved space to 4MB") default is extended.  If array
5eacff
was created prior that patch, reserved space is smaller. In case of matrix
5eacff
RAID - spare is activated in each array one-by-one, so it is spare for first
5eacff
activation, but treated as "active" during second one.
5eacff
5eacff
In case of adding spare drive to old matrix RAID with the size the same as
5eacff
already existing member drive the routine will take the defaults during second
5eacff
run and mdmon will refuse to rebuild second volume, claiming that the drive
5eacff
does not have enough free space.
5eacff
5eacff
Add parameter to get_extents(), so the during spare activation reserved space
5eacff
is always based on smallest active drive - even if given drive is already
5eacff
active in some other array of matrix RAID.
5eacff
5eacff
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
5eacff
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5eacff
---
5eacff
 super-intel.c | 19 ++++++++++---------
5eacff
 1 file changed, 10 insertions(+), 9 deletions(-)
5eacff
5eacff
diff --git a/super-intel.c b/super-intel.c
5eacff
index c399433..5a7c9f8 100644
5eacff
--- a/super-intel.c
5eacff
+++ b/super-intel.c
5eacff
@@ -1313,7 +1313,8 @@ static unsigned long long per_dev_array_size(struct imsm_map *map)
5eacff
 	return array_size;
5eacff
 }
5eacff
 
5eacff
-static struct extent *get_extents(struct intel_super *super, struct dl *dl)
5eacff
+static struct extent *get_extents(struct intel_super *super, struct dl *dl,
5eacff
+				  int get_minimal_reservation)
5eacff
 {
5eacff
 	/* find a list of used extents on the given physical device */
5eacff
 	struct extent *rv, *e;
5eacff
@@ -1325,7 +1326,7 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl)
5eacff
 	 * regardless of whether the OROM has assigned sectors from the
5eacff
 	 * IMSM_RESERVED_SECTORS region
5eacff
 	 */
5eacff
-	if (dl->index == -1)
5eacff
+	if (dl->index == -1 || get_minimal_reservation)
5eacff
 		reservation = imsm_min_reserved_sectors(super);
5eacff
 	else
5eacff
 		reservation = MPB_SECTOR_CNT + IMSM_RESERVED_SECTORS;
5eacff
@@ -1386,7 +1387,7 @@ static __u32 imsm_reserved_sectors(struct intel_super *super, struct dl *dl)
5eacff
 	if (dl->index == -1)
5eacff
 		return MPB_SECTOR_CNT;
5eacff
 
5eacff
-	e = get_extents(super, dl);
5eacff
+	e = get_extents(super, dl, 0);
5eacff
 	if (!e)
5eacff
 		return MPB_SECTOR_CNT + IMSM_RESERVED_SECTORS;
5eacff
 
5eacff
@@ -1478,7 +1479,7 @@ static __u32 imsm_min_reserved_sectors(struct intel_super *super)
5eacff
 		return rv;
5eacff
 
5eacff
 	/* find last lba used by subarrays on the smallest active disk */
5eacff
-	e = get_extents(super, dl_min);
5eacff
+	e = get_extents(super, dl_min, 0);
5eacff
 	if (!e)
5eacff
 		return rv;
5eacff
 	for (i = 0; e[i].size; i++)
5eacff
@@ -1519,7 +1520,7 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c)
5eacff
 	if (!dl)
5eacff
 		return -EINVAL;
5eacff
 	/* find last lba used by subarrays */
5eacff
-	e = get_extents(super, dl);
5eacff
+	e = get_extents(super, dl, 0);
5eacff
 	if (!e)
5eacff
 		return -EINVAL;
5eacff
 	for (i = 0; e[i].size; i++)
5eacff
@@ -7203,7 +7204,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level,
5eacff
 
5eacff
 			pos = 0;
5eacff
 			i = 0;
5eacff
-			e = get_extents(super, dl);
5eacff
+			e = get_extents(super, dl, 0);
5eacff
 			if (!e) continue;
5eacff
 			do {
5eacff
 				unsigned long long esize;
5eacff
@@ -7261,7 +7262,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level,
5eacff
 	}
5eacff
 
5eacff
 	/* retrieve the largest free space block */
5eacff
-	e = get_extents(super, dl);
5eacff
+	e = get_extents(super, dl, 0);
5eacff
 	maxsize = 0;
5eacff
 	i = 0;
5eacff
 	if (e) {
5eacff
@@ -7359,7 +7360,7 @@ static int imsm_get_free_size(struct supertype *st, int raiddisks,
5eacff
 		if (super->orom && dl->index < 0 && mpb->num_raid_devs)
5eacff
 			continue;
5eacff
 
5eacff
-		e = get_extents(super, dl);
5eacff
+		e = get_extents(super, dl, 0);
5eacff
 		if (!e)
5eacff
 			continue;
5eacff
 		for (i = 1; e[i-1].size; i++)
5eacff
@@ -8846,7 +8847,7 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot,
5eacff
 		/* Does this unused device have the requisite free space?
5eacff
 		 * It needs to be able to cover all member volumes
5eacff
 		 */
5eacff
-		ex = get_extents(super, dl);
5eacff
+		ex = get_extents(super, dl, 1);
5eacff
 		if (!ex) {
5eacff
 			dprintf("cannot get extents\n");
5eacff
 			continue;
5eacff
-- 
5eacff
2.7.5
5eacff