diff options
author | Jes Sorensen <jsorensen@fb.com> | 2017-05-05 17:51:43 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-05-05 17:51:43 +0200 |
commit | 64ec81da7a70adcdc0dbccaacc69aaf90edb4011 (patch) | |
tree | b45506b287c3ef7c325f67d878f49bf3bb7b2984 /sysfs.c | |
parent | Incremental: return is not a function (diff) | |
download | mdadm-64ec81da7a70adcdc0dbccaacc69aaf90edb4011.tar.xz mdadm-64ec81da7a70adcdc0dbccaacc69aaf90edb4011.zip |
sysfs/sysfs_read: Count active_disks and failed_disks
Cound active_disks as drives mark 'in_sync' and failed_disks as
disks marked 'faulty', in the same way ioctl(GET_ARRAY_INFO) does.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -270,6 +270,8 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) if (!dir) goto abort; sra->array.spare_disks = 0; + sra->array.active_disks = 0; + sra->array.failed_disks = 0; devp = &sra->devs; sra->devs = NULL; @@ -356,10 +358,14 @@ 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")) + if (strstr(buf, "in_sync")) { dev->disk.state |= (1<<MD_DISK_SYNC); - if (strstr(buf, "faulty")) + sra->array.active_disks++; + } + if (strstr(buf, "faulty")) { dev->disk.state |= (1<<MD_DISK_FAULTY); + sra->array.failed_disks++; + } if (dev->disk.state == 0) sra->array.spare_disks++; } |