dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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