]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add information about reshape to --detail
authorNeil Brown <neilb@suse.de>
Tue, 28 Mar 2006 22:44:05 +0000 (22:44 +0000)
committerNeil Brown <neilb@suse.de>
Tue, 28 Mar 2006 22:44:05 +0000 (22:44 +0000)
Also fix problems with dev names and symlinks

Signed-off-by: Neil Brown <neilb@suse.de>
Detail.c
super1.c
util.c

index 89ad02f3075254f1e9d9d4d19347299f3504c0d8..25b31c48aa0cd22da644abd96993b58ddf854fe0 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -54,6 +54,7 @@ int Detail(char *dev, int brief, int test)
        int failed = 0;
        struct supertype *st = NULL;
        int max_disks = MD_SB_DISKS;
        int failed = 0;
        struct supertype *st = NULL;
        int max_disks = MD_SB_DISKS;
+       struct mdinfo info;
 
        void *super = NULL;
        int rv = test ? 4 : 1;
 
        void *super = NULL;
        int rv = test ? 4 : 1;
@@ -113,7 +114,6 @@ int Detail(char *dev, int brief, int test)
                                int fd2 = dev_open(dv, O_RDONLY);
                                if (fd2 >=0 && st &&
                                    st->ss->load_super(st, fd2, &super, NULL) == 0) {
                                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) {
                                        st->ss->getinfo_super(&info, super);
                                        if (info.array.ctime != array.ctime ||
                                            info.array.level != array.level) {
@@ -223,11 +223,47 @@ int Detail(char *dev, int brief, int test)
                }
        
                if (e && e->percent >= 0) {
                }
        
                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);
 
                        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, far=%d\n",
+                                              info.new_layout&255,
+                                              (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);
 
                if (super && st)
                        st->ss->detail_super(super);
 
index 38b53e7d88121c93013ad0b5ed99a4fd63abbd95..45c3d9562ab57b0c9ca0706a6b1770fc5d892462 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -369,7 +369,7 @@ static void getinfo_super1(struct mdinfo *info, void *sbv)
        info->array.md_minor = -1;
        info->array.ctime = __le64_to_cpu(sb->ctime);
        info->array.utime = __le64_to_cpu(sb->utime);
        info->array.md_minor = -1;
        info->array.ctime = __le64_to_cpu(sb->ctime);
        info->array.utime = __le64_to_cpu(sb->utime);
-       info->array.chunk_size = __le32_to_cpu(sb->chunksize)/512;
+       info->array.chunk_size = __le32_to_cpu(sb->chunksize)*512;
 
        info->data_offset = __le64_to_cpu(sb->data_offset);
        info->component_size = __le64_to_cpu(sb->size);
 
        info->data_offset = __le64_to_cpu(sb->data_offset);
        info->component_size = __le64_to_cpu(sb->size);
@@ -408,7 +408,7 @@ static void getinfo_super1(struct mdinfo *info, void *sbv)
                info->new_level = __le32_to_cpu(sb->new_level);
                info->delta_disks = __le32_to_cpu(sb->delta_disks);
                info->new_layout = __le32_to_cpu(sb->new_layout);
                info->new_level = __le32_to_cpu(sb->new_level);
                info->delta_disks = __le32_to_cpu(sb->delta_disks);
                info->new_layout = __le32_to_cpu(sb->new_layout);
-               info->new_chunk = __le32_to_cpu(sb->new_chunk);
+               info->new_chunk = __le32_to_cpu(sb->new_chunk)<<9;
        } else
                info->reshape_active = 0;
 
        } else
                info->reshape_active = 0;
 
diff --git a/util.c b/util.c
index 873deba67eacdb434e7a5c272d1182ddebc5f3ef..dcedab46e4f06f1fce32380a105cc889e70956bc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -381,20 +381,26 @@ int nftw(const char *path, int (*han)(const char *name, const struct stat *stb,
 
 int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
 {
 
 int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
 {
-    if ((stb->st_mode&S_IFMT)== S_IFBLK) {
-       char *n = strdup(name);
-       struct devmap *dm = malloc(sizeof(*dm));
-       if (strncmp(n, "/dev/.", 6)==0)
-               strcpy(n+4, name+6);
-       if (dm) {
-           dm->major = major(stb->st_rdev);
-           dm->minor = minor(stb->st_rdev);
-           dm->name = n;
-           dm->next = devlist;
-           devlist = dm;
+       struct stat st;
+       if (S_ISLNK(stb->st_mode)) {
+               stat(name, &st);
+               stb = &st;
        }
        }
-    }
-    return 0;
+
+       if ((stb->st_mode&S_IFMT)== S_IFBLK) {
+               char *n = strdup(name);
+               struct devmap *dm = malloc(sizeof(*dm));
+               if (strncmp(n, "/dev/./", 7)==0)
+                       strcpy(n+4, name+6);
+               if (dm) {
+                       dm->major = major(stb->st_rdev);
+                       dm->minor = minor(stb->st_rdev);
+                       dm->name = n;
+                       dm->next = devlist;
+                       devlist = dm;
+               }
+       }
+       return 0;
 }
 
 /*
 }
 
 /*