summaryrefslogtreecommitdiff
path: root/Create.c
diff options
context:
space:
mode:
authorCzarnowska, Anna <anna.czarnowska@intel.com>2011-04-05 09:29:45 +1000
committerNeilBrown <neilb@suse.de>2011-04-05 09:29:45 +1000
commit64385908bbec982d4d6cddd313c7594499087126 (patch)
tree6de61f329e412db818783d2194a1920f4255abb2 /Create.c
parentdb975ab5c3d68daef5e739c9263bb6c4e5b178b8 (diff)
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>
Diffstat (limited to 'Create.c')
-rw-r--r--Create.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/Create.c b/Create.c
index 5709baf8..9ee09280 100644
--- 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) {