]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix chunksize defaulting.
authorNeilBrown <neilb@suse.de>
Wed, 9 Mar 2011 07:27:19 +0000 (18:27 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 9 Mar 2011 07:27:19 +0000 (18:27 +1100)
the new code for defaulting chunksizes didn't work quite right
 - default was set to late in super1/super0/ddf
 - defaults would over-ride values of '0' imposed by some levels
 - default value wasn't applied to size properly.

Signed-off-by: NeilBrown <neilb@suse.de>
Create.c
super-ddf.c
super0.c
super1.c

index bbd25e554d04e5941899d713814f8d97d7c4467d..2e3d7235cf1094152a1ea1892cdc8ffd80865828 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -230,9 +230,11 @@ int Create(struct supertype *st, char *mddev,
        case 10:
        case 6:
        case 0:
-               if (chunk == 0 || chunk == UnSet)
+               if (chunk == 0 || chunk == UnSet) {
+                       chunk = UnSet;
                        do_default_chunk = 1;
                        /* chunk will be set later */
+               }
                break;
        case LEVEL_LINEAR:
                /* a chunksize of zero 0s perfectly valid (and preferred) since 2.6.16 */
@@ -257,12 +259,17 @@ int Create(struct supertype *st, char *mddev,
                return 1;
        }
        
-       if (size && chunk)
+       if (size && chunk && chunk != UnSet)
                size &= ~(unsigned long long)(chunk - 1);
        newsize = size * 2;
        if (st && ! st->ss->validate_geometry(st, level, layout, raiddisks,
                                              &chunk, size*2, NULL, &newsize, verbose>=0))
                return 1;
+
+       if (chunk) {
+               newsize &= ~(unsigned long long)(chunk*2 - 1);
+               size &= ~(unsigned long long)(chunk - 1);
+       }
        if (size == 0) {
                size = newsize / 2;
                if (size && verbose > 0)
index c62d9ca24d087ca770fa7e3f46afddfef25128fc..41ff00530698f742556b8dff1b95f8aa2c810d83 100644 (file)
@@ -2566,6 +2566,10 @@ static int validate_geometry_ddf(struct supertype *st,
         * If given BVDs, we make an SVD, changing all the GUIDs in the process.
         */
 
+       if (chunk && *chunk == UnSet)
+               *chunk = DEFAULT_CHUNK;
+
+
        if (level == LEVEL_CONTAINER) {
                /* Must be a fresh device to add to a container */
                return validate_geometry_ddf_container(st, level, layout,
@@ -2734,9 +2738,6 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
        if (!ddf)
                return 0;
 
-       if (chunk && (*chunk == 0 || *chunk == UnSet))
-               *chunk = DEFAULT_CHUNK;
-
        if (!dev) {
                /* General test:  make sure there is space for
                 * 'raiddisks' device extents of size 'size'.
index 832072d83cd04f78154fe72ccd96b549157e8cfa..4f7110d08a0de28324ae4ed0af864d718d2f9c29 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -1113,12 +1113,12 @@ static int validate_geometry0(struct supertype *st, int level,
                        fprintf(stderr, Name ": 0.90 metadata supports at most 2 terrabytes per device\n");
                return 0;
        }
+       if (chunk && *chunk == UnSet)
+               *chunk = DEFAULT_CHUNK;
+
        if (!subdev)
                return 1;
 
-       if (chunk && (*chunk == 0 || *chunk == UnSet))
-               *chunk = DEFAULT_CHUNK;
-
        fd = open(subdev, O_RDONLY|O_EXCL, 0);
        if (fd < 0) {
                if (verbose)
index be0591677c2f6f2fed705af679dd9a9738597665..9299322fff9c4844a440c5619059619b1ceb51df 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -1666,12 +1666,12 @@ static int validate_geometry1(struct supertype *st, int level,
                        fprintf(stderr, Name ": 1.x metadata does not support containers\n");
                return 0;
        }
+       if (chunk && *chunk == UnSet)
+               *chunk = DEFAULT_CHUNK;
+
        if (!subdev)
                return 1;
 
-       if (chunk && (*chunk == 0 || *chunk == UnSet))
-               *chunk = DEFAULT_CHUNK;
-
        fd = open(subdev, O_RDONLY|O_EXCL, 0);
        if (fd < 0) {
                if (verbose)