From: NeilBrown Date: Tue, 10 May 2011 00:44:00 +0000 (+1000) Subject: Grow: When setting component size make sure components are ready. X-Git-Tag: mdadm-3.2.2~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1537ed19201222cf73bc55f844f100f1a70f6cb;p=thirdparty%2Fmdadm.git Grow: When setting component size make sure components are ready. If you change the size of a member of an array (e.g. it might be a dm device that can be resized, or on a smart storage device), md doesn't notice and so the space cannot be used without explicitly telling md that the device is bigger. This change causes "mdadm --grow --size=...." to make sure each component device is making at least that much space available if it can. Normally usage of "--size=max" will cause all devices to make max space available, the md will use as much as it can of that. Signed-off-by: NeilBrown --- diff --git a/Grow.c b/Grow.c index 9c630369..f910277e 100644 --- a/Grow.c +++ b/Grow.c @@ -1438,6 +1438,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, /* ========= set size =============== */ if (size >= 0 && (size == 0 || size != array.size)) { long long orig_size = array.size; + struct mdinfo *mdi; if (reshape_super(st, size, UnSet, UnSet, 0, 0, UnSet, NULL, devname, !quiet)) { @@ -1445,6 +1446,15 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, goto release; } sync_metadata(st); + + /* Update the size of each member device in case + * they have been resized. This will never reduce + * below the current used-size. The "size" attribute + * understand '0' to mean 'max'. + */ + for (mdi = sra->devs; mdi; mdi = mdi->next) + sysfs_set_num(sra, mdi, "size", size); + array.size = size; if (array.size != size) { /* got truncated to 32bit, write to