]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Detail.c
Allow autoassembly to choose it's own name for the array.
[thirdparty/mdadm.git] / Detail.c
index 15c751f82f2b820381cdc459649d508ae0ab3d19..832e0d8719d1adcf861aacfa3406ba48fafd952d 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
+ * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
 #include       "md_p.h"
 #include       "md_u.h"
 
-int Detail(char *dev, int brief, int test)
+int Detail(char *dev, int brief, int test, char *homehost)
 {
        /*
         * Print out details for an md array by using
@@ -53,7 +53,8 @@ int Detail(char *dev, int brief, int test)
        int is_rebuilding = 0;
        int failed = 0;
        struct supertype *st = NULL;
-       int max_disks = MD_SB_DISKS;
+       int max_disks = MD_SB_DISKS; /* just a default */
+       struct mdinfo info;
 
        void *super = NULL;
        int rv = test ? 4 : 1;
@@ -105,15 +106,14 @@ int Detail(char *dev, int brief, int test)
                    disk.major == 0 &&
                    disk.minor == 0)
                        continue;
-               if ((dv=map_dev(disk.major, disk.minor))) {
+               if ((dv=map_dev(disk.major, disk.minor, 1))) {
                        if (!super && (disk.state & (1<<MD_DISK_ACTIVE))) {
                                /* try to read the superblock from this device
                                 * to get more info
                                 */
-                               int fd2 = open(dv, O_RDONLY);
+                               int fd2 = dev_open(dv, O_RDONLY);
                                if (fd2 >=0 && st &&
                                    st->ss->load_super(st, fd2, &super, NULL) == 0) {
-                                       struct mdinfo info;
                                        st->ss->getinfo_super(&info, super);
                                        if (info.array.ctime != array.ctime ||
                                            info.array.level != array.level) {
@@ -180,19 +180,22 @@ int Detail(char *dev, int brief, int test)
                printf("    Persistence : Superblock is %spersistent\n",
                       array.not_persistent?"not ":"");
                printf("\n");
-               if (ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 &&
-                       bmf.pathname[0]) {
+               /* Only try GET_BITMAP_FILE for 0.90.01 and later */
+               if (vers >= 9001 &&
+                   ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 &&
+                   bmf.pathname[0]) {
                        printf("  Intent Bitmap : %s\n", bmf.pathname);
                        printf("\n");
                } else if (array.state & (1<<MD_SB_BITMAP_PRESENT))
                        printf("  Intent Bitmap : Internal\n\n");
                atime = array.utime;
                printf("    Update Time : %.24s\n", ctime(&atime));
-               printf("          State : %s%s%s\n",
+               printf("          State : %s%s%s%s\n",
                       (array.state&(1<<MD_SB_CLEAN))?"clean":"active",
                       array.active_disks < array.raid_disks? ", degraded":"",
                       (!e || e->percent < 0) ? "" :
-                       (e->resync) ? ", resyncing": ", recovering");
+                       (e->resync) ? ", resyncing": ", recovering",
+                      larray_size ? "": ", Not Started");
                printf(" Active Devices : %d\n", array.active_disks);
                printf("Working Devices : %d\n", array.working_disks);
                printf(" Failed Devices : %d\n", array.failed_disks);
@@ -203,8 +206,9 @@ int Detail(char *dev, int brief, int test)
                        printf("         Layout : %s\n", c?c:"-unknown-");
                }
                if (array.level == 10) {
-                       printf("         Layout : near=%d, far=%d\n", 
-                              array.layout&255, (array.layout>>8)&255);
+                       printf("         Layout : near=%d, %s=%d\n",
+                              array.layout&255, (array.layout&0x10000)?"offset":"far",
+                              (array.layout>>8)&255);
                }
                switch (array.level) {
                case 0:
@@ -221,13 +225,50 @@ int Detail(char *dev, int brief, int test)
                }
        
                if (e && e->percent >= 0) {
-                       printf(" Rebuild Status : %d%% complete\n\n", e->percent);
+                       printf(" Re%s Status : %d%% complete\n",
+                              (super && info.reshape_active)? "shape":"build",
+                              e->percent);
                        is_rebuilding = 1;
                }
                free_mdstat(ms);
 
+               if (super && info.reshape_active) {
+#if 0
+This is pretty boring
+                       printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info.reshape_progress<<9,
+                              human_size(info.reshape_progress<<9));
+#endif
+                       if (info.delta_disks > 0)
+                               printf("  Delta Devices : %d, (%d->%d)\n",
+                                      info.delta_disks, array.raid_disks - info.delta_disks, array.raid_disks);
+                       if (info.delta_disks < 0)
+                               printf("  Delta Devices : %d, (%d->%d)\n",
+                                      info.delta_disks, array.raid_disks, array.raid_disks + info.delta_disks);
+                       if (info.new_level != array.level) {
+                               char *c = map_num(pers, info.new_level);
+                               printf("      New Level : %s\n", c?c:"-unknown-");
+                       }
+                       if (info.new_level != array.level ||
+                           info.new_layout != array.layout) {
+                               if (info.new_level == 5) {
+                                       char *c = map_num(r5layout, info.new_layout);
+                                       printf("     New Layout : %s\n",
+                                              c?c:"-unknown-");
+                               }
+                               if (info.new_level == 10) {
+                                       printf("     New Layout : near=%d, %s=%d\n",
+                                              info.new_layout&255,
+                                              (info.new_layout&0x10000)?"offset":"far",
+                                              (info.new_layout>>8)&255);
+                               }
+                       }
+                       if (info.new_chunk != array.chunk_size)
+                               printf("  New Chunksize : %dK\n", info.new_chunk/1024);
+                       printf("\n");
+               } else if (e && e->percent >= 0)
+                       printf("\n");
                if (super && st)
-                       st->ss->detail_super(super);
+                       st->ss->detail_super(super, homehost);
 
                printf("    Number   Major   Minor   RaidDevice State\n");
        }
@@ -235,6 +276,7 @@ int Detail(char *dev, int brief, int test)
        for (d=0; d<max_disks; d++) {
                disks[d].state = (1<<MD_DISK_REMOVED);
                disks[d].major = disks[d].minor = 0;
+               disks[d].number = disks[d].raid_disk = d;
        }
 
        next = array.raid_disks;
@@ -306,7 +348,7 @@ int Detail(char *dev, int brief, int test)
                                rv |= 2;
                        rv |= 1;
                }
-               if ((dv=map_dev(disk.major, disk.minor))) {
+               if ((dv=map_dev(disk.major, disk.minor, 0))) {
                        if (brief) {
                                if (devices) {
                                        devices = realloc(devices,