diff options
author | NeilBrown <neilb@suse.de> | 2009-11-26 16:28:35 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-11-26 16:28:35 +1100 |
commit | f98841b3852ceb7fce56a6f818236a4af9b5a00a (patch) | |
tree | f4f9e17fb2cf76a7c6ab93a3a5b7f16d941825be /Grow.c | |
parent | 2ed4f75388f99968be58097941a9704f6e42d701 (diff) | |
download | mdadm-f98841b3852ceb7fce56a6f818236a4af9b5a00a.tar.gz |
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.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -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; } |