]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Detail: show which 'set' each device in a RAID10 belongs to
authorNeilBrown <neilb@suse.de>
Wed, 30 May 2012 03:08:39 +0000 (13:08 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 30 May 2012 03:08:39 +0000 (13:08 +1000)
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>
Detail.c

index ae15846d8d5bd6edb2d68fb00fc314387d3f86ae..abe8e2f1f89adc16029c04d7da3c04fb9f4695c4 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -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 &