]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Detail.c
Detail: adding sync status for cluster device
[thirdparty/mdadm.git] / Detail.c
index 4dcf81ddba73200aff32221b2b7c500d83eb2672..24eeba0f993e289ce8efb921414eb6c1ca0db27a 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -56,7 +56,7 @@ int Detail(char *dev, struct context *c)
         */
        int fd = open(dev, O_RDONLY);
        mdu_array_info_t array;
-       mdu_disk_info_t *disks;
+       mdu_disk_info_t *disks = NULL;
        int next;
        int d;
        time_t atime;
@@ -81,6 +81,7 @@ int Detail(char *dev, struct context *c)
        int external;
        int inactive;
        int is_container = 0;
+       char *arrayst;
 
        if (fd < 0) {
                pr_err("cannot open %s: %s\n",
@@ -263,6 +264,7 @@ int Detail(char *dev, struct context *c)
 
                        if (st->ss->export_detail_super)
                                st->ss->export_detail_super(st);
+                       map_free(map);
                } else {
                        struct map_ent *mp, *map = NULL;
                        char nbuf[64];
@@ -277,12 +279,13 @@ int Detail(char *dev, struct context *c)
                                print_escape(mp->path+8);
                                putchar('\n');
                        }
+                       map_free(map);
                }
-               if (sra) {
+               if (!c->no_devices && sra) {
                        struct mdinfo *mdi;
                        for (mdi  = sra->devs; mdi; mdi = mdi->next) {
                                char *path;
-                               char *sysdev = xstrdup(mdi->sys_name + 1);
+                               char *sysdev = xstrdup(mdi->sys_name);
                                char *cp;
 
                                path = map_dev(mdi->disk.major,
@@ -465,7 +468,9 @@ int Detail(char *dev, struct context *c)
                if (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))
+               } else if (array.state & (1<<MD_SB_CLUSTERED))
+                       printf("     Intent Bitmap : Internal(Clustered)\n\n");
+               else if (array.state & (1<<MD_SB_BITMAP_PRESENT))
                        printf("     Intent Bitmap : Internal\n\n");
                atime = array.utime;
                if (atime)
@@ -483,18 +488,30 @@ int Detail(char *dev, struct context *c)
                        else
                                st = ", degraded";
 
-                       printf("             State : %s%s%s%s%s%s \n",
-                              (array.state & (1 << MD_SB_CLEAN)) ?
-                              "clean" : "active", st,
+                       if (array.state & (1 << MD_SB_CLEAN)) {
+                               if ((array.level == 0) ||
+                                   (array.level == LEVEL_LINEAR))
+                                       arrayst = map_num(sysfs_array_states,
+                                                         sra->array_state);
+                               else
+                                       arrayst = "clean";
+                       } else
+                               arrayst = "active";
+
+                       printf("             State : %s%s%s%s%s%s%s \n",
+                              arrayst, st,
                               (!e || (e->percent < 0 &&
                                       e->percent != RESYNC_PENDING &&
-                                      e->percent != RESYNC_DELAYED)) ?
+                                      e->percent != RESYNC_DELAYED &&
+                                      e->percent != RESYNC_REMOTE)) ?
                               "" : sync_action[e->resync],
                               larray_size ? "": ", Not Started",
                               (e && e->percent == RESYNC_DELAYED) ?
                               " (DELAYED)": "",
                               (e && e->percent == RESYNC_PENDING) ?
-                              " (PENDING)": "");
+                              " (PENDING)": "",
+                              (e && e->percent == RESYNC_REMOTE) ?
+                              " (REMOTE)": "");
                } else if (inactive && !is_container) {
                        printf("             State : inactive\n");
                }
@@ -513,6 +530,11 @@ int Detail(char *dev, struct context *c)
                        printf("            Layout : %s\n",
                               str ? str : "-unknown-");
                }
+               if (array.level == 0 && array.layout) {
+                       str = map_num(r0layout, array.layout);
+                       printf("            Layout : %s\n",
+                              str ? str : "-unknown-");
+               }
                if (array.level == 6) {
                        str = map_num(r6layout, array.layout);
                        printf("            Layout : %s\n",
@@ -561,7 +583,6 @@ int Detail(char *dev, struct context *c)
                        printf("    %7s Status : %d%% complete\n",
                               sync_action[e->resync], e->percent);
                }
-               free_mdstat(ms);
 
                if ((st && st->sb) && (info && info->reshape_active)) {
 #if 0
@@ -609,8 +630,10 @@ This is pretty boring
                        printf("\n");
                } else if (e && e->percent >= 0)
                        printf("\n");
+               free_mdstat(ms);
+
                if (st && st->sb)
-                       st->ss->detail_super(st, c->homehost);
+                       st->ss->detail_super(st, c->homehost, subarray);
 
                if (array.raid_disks == 0 && sra &&
                    sra->array.major_version == -1 &&
@@ -652,12 +675,17 @@ This is pretty boring
                        printf("\n\n");
                }
 
-               if (array.raid_disks)
-                       printf("    Number   Major   Minor   RaidDevice State\n");
-               else
-                       printf("    Number   Major   Minor   RaidDevice\n");
+               if (!c->no_devices) {
+                       if (array.raid_disks)
+                               printf("    Number   Major   Minor   RaidDevice State\n");
+                       else
+                               printf("    Number   Major   Minor   RaidDevice\n");
+               }
        }
-       free(info);
+
+       /* if --no_devices specified, not print component devices info */
+       if (c->no_devices)
+               goto skip_devices_state;
 
        for (d = 0; d < max_disks * 2; d++) {
                char *dv;
@@ -744,10 +772,12 @@ This is pretty boring
                if (!c->brief)
                        printf("\n");
        }
+
+skip_devices_state:
        if (spares && c->brief && array.raid_disks)
                printf(" spares=%d", spares);
        if (c->brief && st && st->sb)
-               st->ss->brief_detail_super(st);
+               st->ss->brief_detail_super(st, subarray);
        if (st)
                st->ss->free_super(st);
 
@@ -763,8 +793,9 @@ This is pretty boring
            !enough(array.level, array.raid_disks, array.layout, 1, avail))
                rv = 2;
 
-       free(disks);
 out:
+       free(info);
+       free(disks);
        close(fd);
        free(subarray);
        free(avail);