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 <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-05-10 10:44:00 +10:00
parent 4bba043921
commit d1537ed192
1 changed files with 10 additions and 0 deletions

10
Grow.c
View File

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