]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: get component_size before using it.
authorNeilBrown <neilb@suse.de>
Fri, 6 Nov 2009 03:18:49 +0000 (14:18 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 6 Nov 2009 03:18:49 +0000 (14:18 +1100)
We were using ->component_size while it hadn't been set.
This effectively meant that 'blocks' wasn't multiplied by
16 and reshape was even slower than it should have been.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index 31007ae67735e4c5acfea650376bc5eb03ad9f59..9204edf6145a7fa83ebbbe4aba235f8a2d1e622d 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -900,6 +900,11 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
                /* LCM == product / GCD */
                blocks = ochunk/512 * nchunk/512 * odata * ndata / a;
 
+               sysfs_free(sra);
+               sra = sysfs_read(fd, 0,
+                                GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|
+                                GET_CACHE);
+
                if (ndata == odata) {
                        /* Make 'blocks' bigger for better throughput, but
                         * not so big that we reject it below.
@@ -910,10 +915,6 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
                        fprintf(stderr, Name ": Need to backup %luK of critical "
                                "section..\n", blocks/2);
 
-               sysfs_free(sra);
-               sra = sysfs_read(fd, 0,
-                                GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|
-                                GET_CACHE);
                if (!sra) {
                        fprintf(stderr, Name ": %s: Cannot get array details from sysfs\n",
                                devname);