diff options
author | Jes Sorensen <jsorensen@fb.com> | 2017-05-09 17:09:40 -0400 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-05-09 17:09:40 -0400 |
commit | 8b0ebd645202b627982eb3ed9fc72583c4f245d3 (patch) | |
tree | 193207b491f8f482631baf746e66645bf016462a /sysfs.c | |
parent | b98943a4f889b466a3d07264068042b18c620d33 (diff) | |
download | mdadm-8b0ebd645202b627982eb3ed9fc72583c4f245d3.tar.gz |
sysfs/sysfs_read: Count working_disks
This counts working_disks the same way as get_array_info counts it in
the kernel.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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"); |