]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
DDF: examine_pds to also list devices that aren't in the metadata.
authorNeilBrown <neilb@suse.de>
Wed, 9 Apr 2014 06:56:45 +0000 (16:56 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 21 May 2014 01:54:47 +0000 (11:54 +1000)
The phys disks table should list all disks, but if the metadata
is corrupt, it might not even list the disk it was read from.
So check for and report any known disks that aren't listed.

Signed-off-by: NeilBrown <neilb@suse.de>
super-ddf.c

index f8ff00c20cc11501f65c7b737b6af6b39f653784..f982460b5431f9c080fd0ede604eecfb96fee766 100644 (file)
@@ -488,6 +488,7 @@ struct ddf_super {
                                /* These fields used by auto-layout */
                                int raiddisk; /* slot to fill in autolayout */
                                __u64 esize;
+                               int displayed;
                        };
                };
                struct disk_data disk;
@@ -1488,9 +1489,13 @@ static void examine_pds(struct ddf_super *sb)
        int cnt = be16_to_cpu(sb->phys->max_pdes);
        int i;
        struct dl *dl;
+       int unlisted = 0;
        printf(" Physical Disks : %d\n", cnt);
        printf("      Number    RefNo      Size       Device      Type/State\n");
 
+       for (dl = sb->dlist; dl; dl = dl->next)
+               dl->displayed = 0;
+
        for (i=0 ; i<cnt ; i++) {
                struct phys_disk_entry *pd = &sb->phys->entries[i];
                int type = be16_to_cpu(pd->type);
@@ -1516,6 +1521,8 @@ static void examine_pds(struct ddf_super *sb)
                }
                if (!dl)
                        printf("%15s","");
+               else
+                       dl->displayed = 1;
                printf(" %s%s%s%s%s",
                       (type&2) ? "active":"",
                       (type&4) ? "Global-Spare":"",
@@ -1535,6 +1542,19 @@ static void examine_pds(struct ddf_super *sb)
                       (state&64)? ", Missing" : "");
                printf("\n");
        }
+       for (dl = sb->dlist; dl; dl = dl->next) {
+               char *dv;
+               if (dl->displayed)
+                       continue;
+               if (!unlisted)
+                       printf(" Physical disks not in metadata!:\n");
+               unlisted = 1;
+               dv = map_dev(dl->major, dl->minor, 0);
+               printf("   %08x %s\n", be32_to_cpu(dl->disk.refnum),
+                      dv ? dv : "-unknown-");
+       }
+       if (unlisted)
+               printf("\n");
 }
 
 static void examine_super_ddf(struct supertype *st, char *homehost)