Blame SOURCES/container_members_max-degradation-Switch-to-using-sy.patch

2c1b57
From 74d293a2535ef8726a9d43577dad4a908f471a0e Mon Sep 17 00:00:00 2001
2c1b57
From: Jes Sorensen <jsorensen@fb.com>
2c1b57
Date: Fri, 5 May 2017 12:06:57 -0400
2c1b57
Subject: [RHEL7.5 PATCH 114/169] container_members_max_degradation: Switch
2c1b57
 to using syfs for disk info
2c1b57
2c1b57
With sysfs now providing the necessary active_disks info, switch to
2c1b57
sysfs and eliminate one more use of md_get_array_info(). We can do
2c1b57
this unconditionally since we wouldn't get here witout sysfs being
2c1b57
available.
2c1b57
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 Incremental.c | 28 ++++++++++++++--------------
2c1b57
 1 file changed, 14 insertions(+), 14 deletions(-)
2c1b57
2c1b57
diff --git a/Incremental.c b/Incremental.c
2c1b57
index c00a43d..b73eabd 100644
2c1b57
--- a/Incremental.c
2c1b57
+++ b/Incremental.c
2c1b57
@@ -802,27 +802,27 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
2c1b57
 }
2c1b57
 
2c1b57
 /* test if container has degraded member(s) */
2c1b57
-static int container_members_max_degradation(struct map_ent *map, struct map_ent *me)
2c1b57
+static int
2c1b57
+container_members_max_degradation(struct map_ent *map, struct map_ent *me)
2c1b57
 {
2c1b57
-	mdu_array_info_t array;
2c1b57
-	int afd;
2c1b57
-	int max_degraded = 0;
2c1b57
+	struct mdinfo *sra;
2c1b57
+	int degraded, max_degraded = 0;
2c1b57
 
2c1b57
 	for(; map; map = map->next) {
2c1b57
 		if (!metadata_container_matches(map->metadata, me->devnm))
2c1b57
 			continue;
2c1b57
-		afd = open_dev(map->devnm);
2c1b57
-		if (afd < 0)
2c1b57
-			continue;
2c1b57
 		/* most accurate information regarding array degradation */
2c1b57
-		if (md_get_array_info(afd, &array) >= 0) {
2c1b57
-			int degraded = array.raid_disks - array.active_disks -
2c1b57
-				       array.spare_disks;
2c1b57
-			if (degraded > max_degraded)
2c1b57
-				max_degraded = degraded;
2c1b57
-		}
2c1b57
-		close(afd);
2c1b57
+		sra = sysfs_read(-1, map->devnm,
2c1b57
+				 GET_DISKS | GET_DEVS | GET_STATE);
2c1b57
+		if (!sra)
2c1b57
+			continue;
2c1b57
+		degraded = sra->array.raid_disks - sra->array.active_disks -
2c1b57
+			sra->array.spare_disks;
2c1b57
+		if (degraded > max_degraded)
2c1b57
+			max_degraded = degraded;
2c1b57
+		sysfs_free(sra);
2c1b57
 	}
2c1b57
+
2c1b57
 	return max_degraded;
2c1b57
 }
2c1b57
 
2c1b57
-- 
2c1b57
2.7.4
2c1b57