Create: fix size after setting default chunk

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>
This commit is contained in:
Czarnowska, Anna 2011-04-05 09:29:45 +10:00 committed by NeilBrown
parent db975ab5c3
commit 64385908bb
1 changed files with 18 additions and 7 deletions

View File

@ -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) {