Grow: --size improvements.

1/ allow --size to be given with 'G' or 'T' suffix.
2/ allow size to exceed 32bits, and in that case write through sysfs.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2009-07-14 14:32:30 +10:00
parent 19678e536d
commit 5f4fc0e191
2 changed files with 18 additions and 3 deletions

15
Grow.c
View File

@ -512,8 +512,21 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
}
}
if (size >= 0) {
int rv;
array.size = size;
if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
if (array.size != size) {
/* got truncated to 32bit, write to
* component_size instead
*/
sra = sysfs_read(fd, 0, 0);
if (sra)
rv = sysfs_set_num(sra, NULL,
"component_size", size);
else
rv = -1;
} else
rv = ioctl(fd, SET_ARRAY_INFO, &array);
if (rv != 0) {
fprintf(stderr, Name ": Cannot set device size for %s: %s\n",
devname, strerror(errno));
return 1;

View File

@ -389,12 +389,14 @@ int main(int argc, char *argv[])
if (strcmp(optarg, "max")==0)
size = 0;
else {
size = strtoll(optarg, &c, 10);
if (!optarg[0] || *c || size < 4) {
size = parse_size(optarg);
if (size < 8) {
fprintf(stderr, Name ": invalid size: %s\n",
optarg);
exit(2);
}
/* convert sectors to K */
size /= 2;
}
continue;