]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
sysfs/sysfs_read: Count working_disks
authorJes Sorensen <jsorensen@fb.com>
Tue, 9 May 2017 21:09:40 +0000 (17:09 -0400)
committerJes Sorensen <jsorensen@fb.com>
Tue, 9 May 2017 21:09:40 +0000 (17:09 -0400)
This counts working_disks the same way as get_array_info counts it in
the kernel.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
sysfs.c

diff --git a/sysfs.c b/sysfs.c
index f7967e88489ae45a9306b5aa1fa7c3a94b8e476c..e47f5e483cdd9423a9e8dc899270985778958f81 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -272,6 +272,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
        sra->array.spare_disks = 0;
        sra->array.active_disks = 0;
        sra->array.failed_disks = 0;
+       sra->array.working_disks = 0;
 
        devp = &sra->devs;
        sra->devs = NULL;
@@ -358,16 +359,18 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
                        strcpy(dbase, "state");
                        if (load_sys(fname, buf, sizeof(buf)))
                                goto abort;
-                       if (strstr(buf, "in_sync")) {
-                               dev->disk.state |= (1<<MD_DISK_SYNC);
-                               sra->array.active_disks++;
-                       }
                        if (strstr(buf, "faulty")) {
                                dev->disk.state |= (1<<MD_DISK_FAULTY);
                                sra->array.failed_disks++;
+                       } else {
+                               sra->array.working_disks++;
+                               if (strstr(buf, "in_sync")) {
+                                       dev->disk.state |= (1<<MD_DISK_SYNC);
+                                       sra->array.active_disks++;
+                               }
+                               if (dev->disk.state == 0)
+                                       sra->array.spare_disks++;
                        }
-                       if (dev->disk.state == 0)
-                               sra->array.spare_disks++;
                }
                if (options & GET_ERROR) {
                        strcpy(buf, "errors");