]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Improve reporting of layout for raid10.
authorNeilBrown <neilb@suse.de>
Mon, 13 Oct 2008 05:15:18 +0000 (16:15 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 13 Oct 2008 05:15:18 +0000 (16:15 +1100)
Showing e.g.

   near=1, far=2

for the 'far2' layout of raid10 is confusing even though there is a
sense in which is it correct.

Make it less confusing by only printing whichever number is not 1.
If both are 1, make that clear too (i.e. no redundancy).

Detail.c
mdadm.h
super0.c
super1.c
util.c

index 2b2111cd2f448cf691753d9382cda86c2eea4910..25b91b1e256b5cdf94fe9ff3d69a052de024f6cb 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -239,9 +239,9 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        printf("         Layout : %s\n", c?c:"-unknown-");
                }
                if (array.level == 10) {
-                       printf("         Layout : near=%d, %s=%d\n",
-                              array.layout&255, (array.layout&0x10000)?"offset":"far",
-                              (array.layout>>8)&255);
+                       printf("         Layout :");
+                       print_r10_layout(array.layout);
+                       printf("\n");
                }
                switch (array.level) {
                case 0:
diff --git a/mdadm.h b/mdadm.h
index ce140e586a37b774c2352181e6c13db4c94cfe39..174ea395ad3002b3b7f8f26d628d69a66f9b12c0 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -513,7 +513,8 @@ extern void remove_partitions(int fd);
 
 
 extern char *human_size(long long bytes);
-char *human_size_brief(long long bytes);
+extern char *human_size_brief(long long bytes);
+extern void print_r10_layout(int layout);
 
 #define NoMdDev (1<<23)
 extern int find_free_devnum(int use_partitions);
index 8e4c568e1e360ac2e8ab1146b1bc5b06578ad8fc..71dc39ce4a0dec2ccbb18c0d67ad19e09d636fca 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -188,10 +188,9 @@ static void examine_super0(struct supertype *st, char *homehost)
                printf("         Layout : %s\n", c?c:"-unknown-");
        }
        if (sb->level == 10) {
-               printf("         Layout : near=%d, %s=%d\n",
-                      sb->layout&255,
-                      (sb->layout&0x10000)?"offset":"far",
-                      (sb->layout>>8)&255);
+               printf("         Layout :");
+               print_r10_layout(sb->layout);
+               printf("\n");
        }
        switch(sb->level) {
        case 0:
index e1d021904ec003c0320a056bb1dabd06bf06dc7d..bec0c5e4b9304cd6a36dfd88b81eea1dc9543123 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -248,10 +248,9 @@ static void examine_super1(struct supertype *st, char *homehost)
                                printf("     New Layout : %s\n", c?c:"-unknown-");
                        }
                        if (__le32_to_cpu(sb->level) == 10) {
-                               printf("     New Layout : near=%d, %s=%d\n",
-                                      __le32_to_cpu(sb->new_layout)&255,
-                                      (__le32_to_cpu(sb->new_layout)&0x10000)?"offset":"far",
-                                      (__le32_to_cpu(sb->new_layout)>>8)&255);
+                               printf("     New Layout :");
+                               print_r10_layout(__le32_to_cpu(sb->new_layout));
+                               printf("\n");
                        }
                }
                if (__le32_to_cpu(sb->new_chunk) != __le32_to_cpu(sb->chunksize))
@@ -281,10 +280,9 @@ static void examine_super1(struct supertype *st, char *homehost)
        }
        if (__le32_to_cpu(sb->level) == 10) {
                int lo = __le32_to_cpu(sb->layout);
-               printf("         Layout : near=%d, %s=%d\n",
-                      lo&255,
-                      (lo&0x10000)?"offset":"far",
-                      (lo>>8)&255);
+               printf("         Layout :");
+               print_r10_layout(lo);
+               printf("\n");
        }
        switch(__le32_to_cpu(sb->level)) {
        case 0:
diff --git a/util.c b/util.c
index 75f370644124351c6279d3a0b194d7416745604f..2d51de02ba4386ea3fae93a4cd41d7b7e998773b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -606,6 +606,23 @@ char *human_size_brief(long long bytes)
                        );
        return buf;
 }
+
+void print_r10_layout(int layout)
+{
+       int near = layout & 255;
+       int far = (layout >> 8) & 255;
+       int offset = (layout&0x10000);
+       char *sep = "";
+
+       if (near != 1) {
+               printf("%s near=%d", sep, near);
+               sep = ",";
+       }
+       if (far != 1)
+               printf("%s %s=%d", sep, offset?"offset":"far", far);
+       if (near*far == 1)
+               printf("NO REDUNDANCY");
+}
 #endif
 
 #if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)