diff options
author | NeilBrown <neilb@suse.de> | 2009-07-13 15:00:02 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-07-13 15:00:02 +1000 |
commit | 84e11361aa37c92c3c016095e5db7f4fc434ac18 (patch) | |
tree | 784d588a80d609f857beef00107adda2cc7b10d8 /mdadm.c | |
parent | e0d95aac9626badd1b849ce4f99f9c406d55beae (diff) | |
download | mdadm-84e11361aa37c92c3c016095e5db7f4fc434ac18.tar.gz mdadm-84e11361aa37c92c3c016095e5db7f4fc434ac18.tar.xz mdadm-84e11361aa37c92c3c016095e5db7f4fc434ac18.zip |
Grow: support --array-size changes
With 2.6.30 it is possible to tell the md driver to clip an array to a
size smaller than the real size of the array. This option gives
access to that feature. The size change does not persist
across restarts.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 43 |
1 files changed, 42 insertions, 1 deletions
@@ -46,6 +46,7 @@ int main(int argc, char *argv[]) int chunk = 0; long long size = -1; + long long array_size = -1; int level = UnSet; int layout = UnSet; int raiddisks = 0; @@ -397,6 +398,24 @@ int main(int argc, char *argv[]) } continue; + case O(GROW,'Z'): /* array size */ + if (array_size >= 0) { + fprintf(stderr, Name ": array-size may only be specified once. " + "Second value is %s.\n", optarg); + exit(2); + } + if (strcmp(optarg, "max") == 0) + array_size = 0; + else { + array_size = parse_size(optarg); + if (array_size <= 0) { + fprintf(stderr, Name ": invalid array size: %s\n", + optarg); + exit(2); + } + } + continue; + case O(GROW,'l'): /* hack - needed to understand layout */ case O(CREATE,'l'): case O(BUILD,'l'): /* set raid level*/ @@ -1372,6 +1391,28 @@ int main(int argc, char *argv[]) break; case GROW: + if (array_size >= 0) { + /* alway impose array size first, independent of + * anything else + */ + struct mdinfo sra; + int err; + sysfs_init(&sra, mdfd, 0); + if (array_size == 0) + err = sysfs_set_str(&sra, NULL, "array_size", "default"); + else + err = sysfs_set_num(&sra, NULL, "array_size", array_size / 2); + if (err < 0) { + if (errno == E2BIG) + fprintf(stderr, Name ": --array-size setting" + " is too large.\n"); + else + fprintf(stderr, Name ": current kernel does" + " not support setting --array-size\n"); + rv = 1; + break; + } + } if (devs_found > 1) { /* must be '-a'. */ @@ -1398,7 +1439,7 @@ int main(int argc, char *argv[]) if (delay == 0) delay = DEFAULT_BITMAP_DELAY; rv = Grow_addbitmap(devlist->devname, mdfd, bitmap_file, bitmap_chunk, delay, write_behind, force); - } else + } else if (array_size < 0) fprintf(stderr, Name ": no changes to --grow\n"); break; case INCREMENTAL: |