summaryrefslogtreecommitdiffstats
path: root/Incremental.c
diff options
context:
space:
mode:
authorJes Sorensen <jsorensen@fb.com>2017-05-05 18:06:57 +0200
committerJes Sorensen <jsorensen@fb.com>2017-05-05 18:06:57 +0200
commit74d293a2535ef8726a9d43577dad4a908f471a0e (patch)
tree467d03e5129ea81341d2d2a6c28aa0a5dd318fb1 /Incremental.c
parentsysfs/sysfs_read: Count active_disks and failed_disks (diff)
downloadmdadm-74d293a2535ef8726a9d43577dad4a908f471a0e.tar.xz
mdadm-74d293a2535ef8726a9d43577dad4a908f471a0e.zip
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>
Diffstat (limited to 'Incremental.c')
-rw-r--r--Incremental.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/Incremental.c b/Incremental.c
index c00a43d6..b73eabd7 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;
}