]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: --size improvements.
authorNeilBrown <neilb@suse.de>
Tue, 14 Jul 2009 04:32:30 +0000 (14:32 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 14 Jul 2009 04:32:30 +0000 (14:32 +1000)
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>
Grow.c
mdadm.c

diff --git a/Grow.c b/Grow.c
index 65b708a71fc91f91119cf29f0963ee44b58762ee..29d3628a8a7f3e67c0887b152921e49b1c2c4b91 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -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;
diff --git a/mdadm.c b/mdadm.c
index 0432622b688d191b334941bfbacc07a3a19bc71b..a77c4ad846676973eb2735146c74b8faae900812 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -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;