Detail: show which 'set' each device in a RAID10 belongs to

A RAID10 can be though of as having 2 sets of devices
(if there are 2 copies and an even number of devices in total).

With this patch "mdadm --detail" shows which 'set' each device
belongs to - set-A or set-B.

If there are more than 3 copies, there can be more than 3 sets.

If the number of copies does not evenly divide the number of devices,
there are not distinct 'sets' so none are reported.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2012-05-30 13:08:39 +10:00
parent 5e311406c4
commit 2c096ebe4b
1 changed files with 13 additions and 1 deletions

View File

@ -533,7 +533,19 @@ This is pretty boring
failed++;
}
if (disk.state & (1<<MD_DISK_ACTIVE)) printf(" active");
if (disk.state & (1<<MD_DISK_SYNC)) printf(" sync");
if (disk.state & (1<<MD_DISK_SYNC)) {
printf(" sync");
if (array.level == 10 && (array.layout & ~0x1FFFF) == 0) {
int nc = array.layout & 0xff;
int fc = (array.layout >> 8) & 0xff;
int copies = nc*fc;
if (array.raid_disks % copies == 0 && copies <= 26) {
/* We can divide the devices into 'sets' */
int set = disk.raid_disk % copies;
printf(" set-%c", set + 'A');
}
}
}
if (disk.state & (1<<MD_DISK_REMOVED)) printf(" removed");
if (disk.state & (1<<MD_DISK_WRITEMOSTLY)) printf(" writemostly");
if ((disk.state &