]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
container_members_max_degradation: Switch to using syfs for disk info
authorJes Sorensen <jsorensen@fb.com>
Fri, 5 May 2017 16:06:57 +0000 (12:06 -0400)
committerJes Sorensen <jsorensen@fb.com>
Fri, 5 May 2017 16:06:57 +0000 (12:06 -0400)
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

index c00a43d66bfc8418fbd14d7c9dd3de5a3004777f..b73eabd7f85babc7d71259ba774d3ef8a0a13f52 100644 (file)
@@ -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;
 }