From e380d3be42706ed455baf7b03c05d07f13368951 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Nov 2009 14:18:49 +1100 Subject: [PATCH] Grow: get component_size before using it. 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 --- Grow.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Grow.c b/Grow.c index 31007ae..9204edf 100644 --- 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);