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