summaryrefslogtreecommitdiffstats
path: root/Grow.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-11-26 16:28:35 +1100
committerNeilBrown <neilb@suse.de>2009-11-26 16:28:35 +1100
commitf98841b3852ceb7fce56a6f818236a4af9b5a00a (patch)
treef4f9e17fb2cf76a7c6ab93a3a5b7f16d941825be /Grow.c
parent2ed4f75388f99968be58097941a9704f6e42d701 (diff)
downloadmdadm-f98841b3852ceb7fce56a6f818236a4af9b5a00a.tar.gz
mdadm-f98841b3852ceb7fce56a6f818236a4af9b5a00a.tar.xz
mdadm-f98841b3852ceb7fce56a6f818236a4af9b5a00a.zip
Grow: be more careful when using array.size
As array.size is 32bit we need to prefer the 'component_size' read from sysfs when that is available. Grow wasn't always suitably careful. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r--Grow.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/Grow.c b/Grow.c
index a654d4e..d8d91cb 100644
--- a/Grow.c
+++ b/Grow.c
@@ -569,10 +569,17 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
goto release;
}
ioctl(fd, GET_ARRAY_INFO, &array);
+ size = get_component_size(fd);
+ if (size == 0)
+ size = array.size;
if (!quiet)
- fprintf(stderr, Name ": component size of %s has been set to %dK\n",
- devname, array.size);
+ fprintf(stderr, Name ": component size of %s has been set to %lluK\n",
+ devname, size);
changed = 1;
+ } else {
+ size = get_component_size(fd);
+ if (size == 0)
+ size = array.size;
}
/* ======= set level =========== */
@@ -844,10 +851,10 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
if (chunksize) {
nchunk = chunksize * 1024;
- if (array.size % chunksize) {
- fprintf(stderr, Name ": component size %dK is not"
+ if (size % chunksize) {
+ fprintf(stderr, Name ": component size %lluK is not"
" a multiple of chunksize %dK\n",
- array.size, chunksize);
+ size, chunksize);
break;
}
}
@@ -891,13 +898,12 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
}
/* Check that we can hold all the data */
- size = ndata * (long long)array.size;
get_dev_size(fd, NULL, &array_size);
- if (size < (array_size/1024)) {
+ if (ndata * size < (array_size/1024)) {
fprintf(stderr, Name ": this change will reduce the size of the array.\n"
" use --grow --array-size first to truncate array.\n"
" e.g. mdadm --grow %s --array-size %llu\n",
- devname, size);
+ devname, ndata * size);
rv = 1;
break;
}