]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: When setting component size make sure components are ready.
authorNeilBrown <neilb@suse.de>
Tue, 10 May 2011 00:44:00 +0000 (10:44 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 10 May 2011 00:44:00 +0000 (10:44 +1000)
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>
Grow.c

diff --git a/Grow.c b/Grow.c
index 9c630369a11f72061853c6caa8d8e9370330a40f..f910277edf361323c151152aa969e21271ce1b1e 100644 (file)
--- 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