]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Create: fix size after setting default chunk
authorCzarnowska, Anna <anna.czarnowska@intel.com>
Mon, 4 Apr 2011 23:29:45 +0000 (09:29 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 4 Apr 2011 23:29:45 +0000 (09:29 +1000)
When -e option is given then the first validate_geometry
sets default chunk. Size must be rounded there and do_default_chunk
needs to be set to 0 so that we don't repeat the message below.

If we start without st then what we find on the the first disk determines
the st and sets chunk. So after running
validate_geometry on the first disk we need to fix the size too.
At this point chunk should always be set but it is safer to keep the check.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Create.c

index 5709baf8556fe977feabb0e1bc050ce3278bf0cc..9ee09280e4c29aa74427680b43b89c786a55dadc 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -268,8 +268,16 @@ int Create(struct supertype *st, char *mddev,
 
        if (chunk && chunk != UnSet) {
                newsize &= ~(unsigned long long)(chunk*2 - 1);
-               size &= ~(unsigned long long)(chunk - 1);
+               if (do_default_chunk) {
+                       /* default chunk was just set */
+                       if (verbose > 0)
+                               fprintf(stderr, Name ": chunk size "
+                                       "defaults to %dK\n", chunk);
+                       size &= ~(unsigned long long)(chunk - 1);
+                       do_default_chunk = 0;
+               }
        }
+
        if (size == 0) {
                size = newsize / 2;
                if (size && verbose > 0)
@@ -316,7 +324,7 @@ int Create(struct supertype *st, char *mddev,
                                                 verbose > 0)) {
                                        free(st);
                                        st = NULL;
-                                       chunk = do_default_chunk ? 0 : chunk;
+                                       chunk = do_default_chunk ? UnSet : chunk;
                                }
                        }
 
@@ -346,16 +354,19 @@ int Create(struct supertype *st, char *mddev,
                                continue;
                        }
                }
-               if (verbose > 0 && do_default_chunk) {
-                       do_default_chunk = 0;
-                       fprintf(stderr, Name ": chunk size "
-                               "defaults to %dK\n", chunk);
-               }
 
                freesize /= 2; /* convert to K */
                if (chunk && chunk != UnSet) {
                        /* round to chunk size */
                        freesize = freesize & ~(chunk-1);
+                       if (do_default_chunk) {
+                               /* default chunk was just set */
+                               if (verbose > 0)
+                                       fprintf(stderr, Name ": chunk size "
+                                               "defaults to %dK\n", chunk);
+                               size &= ~(unsigned long long)(chunk - 1);
+                               do_default_chunk = 0;
+                       }
                }
 
                if (size && freesize < size) {