From: NeilBrown Date: Mon, 24 Jun 2013 03:02:35 +0000 (+1000) Subject: Grow: Try hard to set new_offset. X-Git-Tag: mdadm-3.3-rc1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6a78630acd3772b493c042c71fc8c22799fab4d;p=thirdparty%2Fmdadm.git Grow: Try hard to set new_offset. Setting new_offset can fail if the v1.x "data_size" is too small. So if that happens, try increasing it first by writing "0". That can fail on spare devices due to a kernel bug, so if it doesn't try writing the correct number of sectors. Signed-off-by: NeilBrown --- diff --git a/Grow.c b/Grow.c index 122ca0ec..556bdafe 100644 --- a/Grow.c +++ b/Grow.c @@ -2353,10 +2353,21 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st, sd->data_offset - min); } } - if (sysfs_set_num(sra, sd, "new_offset", - new_data_offset) < 0) { - err = errno; - err = -1; + err = sysfs_set_num(sra, sd, "new_offset", new_data_offset); + if (err < 0 && errno == E2BIG) { + /* try again after increasing data size to max */ + err = sysfs_set_num(sra, sd, "size", 0); + if (err < 0 && errno == EINVAL && + !(sd->disk.state & (1<component_size + after)/2); + } + err = sysfs_set_num(sra, sd, "new_offset", + new_data_offset); + } + if (err < 0) { if (errno == E2BIG && data_offset != INVALID_SECTORS) { pr_err("data-offset is too big for %s\n", dn);