From: NeilBrown Date: Tue, 30 Jul 2013 03:45:22 +0000 (+1000) Subject: Manage: remove call to validate_geometry. X-Git-Tag: mdadm-3.3~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ccc4cc4fc6889680bbe4ec673cab3f6aa49aad3;p=thirdparty%2Fmdadm.git Manage: remove call to validate_geometry. This call to validate_geometry is really rather gratuitous. It is purely about the fact that super0 cannot use more than 4TB. So just make it an explicit test - less confusing that way. With this, validate_geometry is only called from Create, which makes it easier to reason about. Also validate_geometry is now never passed NULL for the 'chunk' parameter, so we can remove those annoying tests for NULL. Signed-off-by: NeilBrown --- diff --git a/Manage.c b/Manage.c index 8d1bbd97..0b0b7857 100644 --- a/Manage.c +++ b/Manage.c @@ -718,10 +718,8 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, return -1; } - if (tst->ss->validate_geometry( - tst, array->level, array->layout, - array->raid_disks, NULL, - ldsize >> 9, INVALID_SECTORS, NULL, NULL, 0) == 0) { + if (tst->ss == &super0 && ldsize > 4ULL*1024*1024*2) { + /* More than 4TB is wasted on v0.90 */ if (!force) { pr_err("%s is larger than %s can " "effectively use.\n" diff --git a/super-ddf.c b/super-ddf.c index 47074feb..683f9697 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -3185,14 +3185,14 @@ 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) + if (*chunk == UnSet) *chunk = DEFAULT_CHUNK; if (level == -1000000) level = LEVEL_CONTAINER; if (level == LEVEL_CONTAINER) { /* Must be a fresh device to add to a container */ return validate_geometry_ddf_container(st, level, layout, - raiddisks, chunk?*chunk:0, + raiddisks, *chunk, size, data_offset, dev, freesize, verbose); @@ -3220,7 +3220,7 @@ static int validate_geometry_ddf(struct supertype *st, * chosen so that add_to_super/getinfo_super * can return them. */ - return reserve_space(st, raiddisks, size, chunk?*chunk:0, freesize); + return reserve_space(st, raiddisks, size, *chunk, freesize); } return 1; } diff --git a/super-intel.c b/super-intel.c index baea13cc..4df33f42 100644 --- a/super-intel.c +++ b/super-intel.c @@ -5854,10 +5854,10 @@ validate_geometry_imsm_orom(struct intel_super *super, int level, int layout, return 0; } - if (chunk && (*chunk == 0 || *chunk == UnSet)) + if (*chunk == 0 || *chunk == UnSet) *chunk = imsm_default_chunk(super->orom); - if (super->orom && chunk && !imsm_orom_has_chunk(super->orom, *chunk)) { + if (super->orom && !imsm_orom_has_chunk(super->orom, *chunk)) { pr_vrb(": platform does not support a chunk size of: " "%d\n", *chunk); return 0; @@ -5874,7 +5874,7 @@ validate_geometry_imsm_orom(struct intel_super *super, int level, int layout, return 0; } - if (super->orom && (super->orom->attr & IMSM_OROM_ATTR_2TB) == 0 && chunk && + if (super->orom && (super->orom->attr & IMSM_OROM_ATTR_2TB) == 0 && (calc_array_size(level, raiddisks, layout, *chunk, size) >> 32) > 0) { pr_vrb(": platform does not support a volume size over 2TB\n"); return 0; @@ -6188,7 +6188,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, /* Must be a fresh device to add to a container */ return validate_geometry_imsm_container(st, level, layout, raiddisks, - chunk?*chunk:0, + *chunk, size, data_offset, dev, freesize, verbose); @@ -6224,7 +6224,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, } if (freesize) return reserve_space(st, raiddisks, size, - chunk?*chunk:0, freesize); + *chunk, freesize); } return 1; } diff --git a/super0.c b/super0.c index 85acf368..3218377f 100644 --- a/super0.c +++ b/super0.c @@ -1274,7 +1274,7 @@ static int validate_geometry0(struct supertype *st, int level, "%d terabytes per device\n", tbmax); return 0; } - if (chunk && *chunk == UnSet) + if (*chunk == UnSet) *chunk = DEFAULT_CHUNK; if (!subdev) diff --git a/super1.c b/super1.c index eb420580..f8404597 100644 --- a/super1.c +++ b/super1.c @@ -2302,7 +2302,7 @@ static int validate_geometry1(struct supertype *st, int level, pr_err("1.x metadata does not support containers\n"); return 0; } - if (chunk && *chunk == UnSet) + if (*chunk == UnSet) *chunk = DEFAULT_CHUNK; if (!subdev)