summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--Detail.c18
-rw-r--r--mdadm.83
3 files changed, 17 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d81c3d..d92f5ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@ Changes Prior to this release
- Various manpage updates.
- Make "--grow --add" for linear arrays really work.
- --auto-detect to trigger in-kernel autodetect.
+ - Make return code for "--detail --test" more reliable. Missing
+ devices as well as failed devices cause an error.
Changes Prior to 2.6.1 release
- --monitor was producing some meaningless warnings due to a bug.
diff --git a/Detail.c b/Detail.c
index 58de67e..0ed81d1 100644
--- a/Detail.c
+++ b/Detail.c
@@ -58,6 +58,8 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
void *super = NULL;
int rv = test ? 4 : 1;
+ int avail_disks = 0;
+ char *avail;
if (fd < 0) {
fprintf(stderr, Name ": cannot open %s: %s\n",
@@ -301,6 +303,7 @@ This is pretty boring
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];
@@ -347,10 +350,13 @@ This is pretty boring
}
}
if (disk.state == 0) spares++;
- if (test && d < array.raid_disks && disk.state & (1<<MD_DISK_FAULTY)) {
- if ((rv & 1) && (array.level ==4 || array.level == 5))
- rv |= 2;
+ if (test && d < array.raid_disks
+ && !(disk.state & (1<<MD_DISK_SYNC)))
rv |= 1;
+ if (d < array.raid_disks
+ && (disk.state & (1<<MD_DISK_SYNC))) {
+ avail_disks ++;
+ avail[d] = 1;
}
if ((dv=map_dev(disk.major, disk.minor, 0))) {
if (brief) {
@@ -372,7 +378,11 @@ This is pretty boring
if (brief > 1 && devices) printf("\n devices=%s", devices);
if (brief) printf("\n");
out:
- if (test && (rv&2)) rv &= ~1;
+ if (test &&
+ !enough(array.level, array.raid_disks, array.layout,
+ 1, avail, avail_disks))
+ rv = 2;
+
close(fd);
return rv;
}
diff --git a/mdadm.8 b/mdadm.8
index e70a1a9..0d3adfc 100644
--- a/mdadm.8
+++ b/mdadm.8
@@ -1457,8 +1457,7 @@ The array is functioning normally.
The array has at least one failed device.
.TP
2
-The array has multiple failed devices and hence is unusable (raid4 or
-raid5).
+The array has multiple failed devices such that it is unusable.
.TP
4
There was an error while trying to get information about the device.