From d998adc316299efc44cb6e70ecc2e04bffb76d17 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 29 Jan 2010 15:45:36 +1100 Subject: [PATCH] Detail: Report state of FAILED when an array has too few devices to work. We already have a call to 'enough' in Detail which is the check for "do we have enough devices". We just need to calculate the required data a bit earlier, then use the same 'enough' call to possibly print FAILED. This is motivated by Debian bug 495755. The other request in that bug is not practical. It would be very nice if output of `mdadm' is more clear in case of a broken array. Currently the only hint you get from `mdadm' that your array is broken is this: # mdadm -A /dev/md0 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 mdadm: /dev/md0 assembled from 1 drive and 3 spares - not enough to start the array. It could say something like `Your array is broken, you can't use it anymore' It is not valid to report that array as 'broken' if the user hasn't listed all the devices, which could be the case here. Resolves-Debian-Bug: 495755 Signed-off-by: NeilBrown --- Detail.c | 80 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/Detail.c b/Detail.c index ba07c83..3d6b10f 100644 --- a/Detail.c +++ b/Detail.c @@ -207,6 +207,42 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) goto out; } + disks = malloc(max_disks * sizeof(mdu_disk_info_t)); + for (d=0; d= 0 && disk.raid_disk < array.raid_disks) + disks[disk.raid_disk] = disk; + else if (next < max_disks) + disks[next++] = disk; + } + + avail = calloc(array.raid_disks, 1); + + for (d= 0; d < array.raid_disks; d++) { + mdu_disk_info_t disk = disks[d]; + + if ((disk.state & (1<percent < 0) ? "" : (e->resync) ? ", resyncing": ", recovering", larray_size ? "": ", Not Started"); + } if (array.raid_disks) printf(" Active Devices : %d\n", array.active_disks); printf("Working Devices : %d\n", array.working_disks); @@ -442,32 +488,7 @@ This is pretty boring else printf(" Number Major Minor RaidDevice\n"); } - disks = malloc(max_disks * sizeof(mdu_disk_info_t)); - for (d=0; d= 0 && disk.raid_disk < array.raid_disks) - disks[disk.raid_disk] = disk; - else if (next < max_disks) - disks[next++] = disk; - } - - avail = calloc(array.raid_disks, 1); for (d= 0; d < max_disks; d++) { char *dv; mdu_disk_info_t disk = disks[d]; @@ -520,11 +541,6 @@ This is pretty boring if (test && d < array.raid_disks && !(disk.state & (1<