dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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