Detail: fix handling of 'disks' array.
Since the introduction of replacement devices, we reserve to places in the "disks" array for each raid disk. That means we should allocate to twice "max_disk" as the array could have that many raid_disks (though that would limit the number of replacements). A couple of other places need to use "max_disks*2" instead of "max_disks" to co-ordinate with this. Reported-by: Or Sagi <ors@reduxio.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
21dc47172d
commit
8057db46a1
8
Detail.c
8
Detail.c
|
@ -295,8 +295,8 @@ int Detail(char *dev, struct context *c)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
disks = xmalloc(max_disks * sizeof(mdu_disk_info_t));
|
disks = xmalloc(max_disks * 2 * sizeof(mdu_disk_info_t));
|
||||||
for (d = 0; d < max_disks; d++) {
|
for (d = 0; d < max_disks * 2; d++) {
|
||||||
disks[d].state = (1<<MD_DISK_REMOVED);
|
disks[d].state = (1<<MD_DISK_REMOVED);
|
||||||
disks[d].major = disks[d].minor = 0;
|
disks[d].major = disks[d].minor = 0;
|
||||||
disks[d].number = disks[d].raid_disk = d;
|
disks[d].number = disks[d].raid_disk = d;
|
||||||
|
@ -327,7 +327,7 @@ int Detail(char *dev, struct context *c)
|
||||||
else if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks
|
else if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks
|
||||||
&& disks[disk.raid_disk*2+1].state == (1<<MD_DISK_REMOVED))
|
&& disks[disk.raid_disk*2+1].state == (1<<MD_DISK_REMOVED))
|
||||||
disks[disk.raid_disk*2+1] = disk;
|
disks[disk.raid_disk*2+1] = disk;
|
||||||
else if (next < max_disks)
|
else if (next < max_disks*2)
|
||||||
disks[next++] = disk;
|
disks[next++] = disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ This is pretty boring
|
||||||
}
|
}
|
||||||
free(info);
|
free(info);
|
||||||
|
|
||||||
for (d= 0; d < max_disks; d++) {
|
for (d= 0; d < max_disks * 2; d++) {
|
||||||
char *dv;
|
char *dv;
|
||||||
mdu_disk_info_t disk = disks[d];
|
mdu_disk_info_t disk = disks[d];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue