diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> | 2017-08-10 11:43:48 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-08-16 10:19:38 +0200 |
commit | a822017f30e0dadc60a687900c2aa4da32e09a93 (patch) | |
tree | a61e6e4cc88c21ac185b89c6b16d793b81701f60 /Detail.c | |
parent | udev rules: introduce rules for cluster-md to confirm device (diff) | |
download | mdadm-a822017f30e0dadc60a687900c2aa4da32e09a93.tar.xz mdadm-a822017f30e0dadc60a687900c2aa4da32e09a93.zip |
Detail: correct output for active arrays
The check for inactive array is incorrect as it compares it against
active array. Introduce a new function md_is_array_active so the check
is consistent across the code.
As the output contains list of disks in the array include this
information in sysfs read.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Detail.c')
-rw-r--r-- | Detail.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -86,7 +86,8 @@ int Detail(char *dev, struct context *c) dev, strerror(errno)); return rv; } - sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS | GET_ARRAY_STATE); + sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS | + GET_ARRAY_STATE | GET_STATE); if (!sra) { if (md_get_array_info(fd, &array)) { pr_err("%s does not appear to be an md device\n", dev); @@ -96,8 +97,7 @@ int Detail(char *dev, struct context *c) } external = (sra != NULL && sra->array.major_version == -1 && sra->array.minor_version == -2); - inactive = (sra->array_state == ARRAY_ACTIVE || - sra->array_state == ARRAY_CLEAR); + inactive = (sra != NULL && !md_array_is_active(sra)); st = super_by_fd(fd, &subarray); if (md_get_array_info(fd, &array)) { if (errno == ENODEV) { @@ -314,11 +314,10 @@ int Detail(char *dev, struct context *c) next = array.raid_disks * 2; if (inactive) { struct mdinfo *mdi; - if (sra != NULL) - for (mdi = sra->devs; mdi; mdi = mdi->next) { - disks[next++] = mdi->disk; - disks[next - 1].number = -1; - } + for (mdi = sra->devs; mdi; mdi = mdi->next) { + disks[next++] = mdi->disk; + disks[next - 1].number = -1; + } } else for (d = 0; d < max_disks; d++) { mdu_disk_info_t disk; disk.number = d; |