From bed256c2419986e3a935680a7ead1def11ea08e7 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 28 Mar 2006 22:44:05 +0000 Subject: [PATCH] Add information about reshape to --detail Also fix problems with dev names and symlinks Signed-off-by: Neil Brown --- Detail.c | 40 ++++++++++++++++++++++++++++++++++++++-- super1.c | 4 ++-- util.c | 32 +++++++++++++++++++------------- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/Detail.c b/Detail.c index 89ad02f3..25b31c48 100644 --- 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; + struct mdinfo info; 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) { - struct mdinfo info; 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) { - 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, 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); diff --git a/super1.c b/super1.c index 38b53e7d..45c3d956 100644 --- 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.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); @@ -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_chunk = __le32_to_cpu(sb->new_chunk); + info->new_chunk = __le32_to_cpu(sb->new_chunk)<<9; } else info->reshape_active = 0; diff --git a/util.c b/util.c index 873deba6..dcedab46 100644 --- 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) { - 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; } /* -- 2.39.2