summaryrefslogtreecommitdiff
path: root/mdadm.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-07-14 12:13:29 +1000
committerNeilBrown <neilb@suse.de>2009-07-14 12:13:29 +1000
commit19678e536d5b7aba8b721a3065f2550b79ddd208 (patch)
tree7537fe1a28214e5fe490b8f8524fb1430c4d26c3 /mdadm.c
parentd823a6c87225d0c7f96443013798ed4dacf51ff6 (diff)
downloadmdadm-19678e536d5b7aba8b721a3065f2550b79ddd208.tar.gz
Grow: pass layout as a string rather than a number.
This allows the layout to be parsed after the current level of the array is know, so that the level doesn't need to be given (otherwise pointlessly) on the command line. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/mdadm.c b/mdadm.c
index bac0f35..0432622 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
long long array_size = -1;
int level = UnSet;
int layout = UnSet;
+ char *layout_str = NULL;
int raiddisks = 0;
int max_disks = MD_SB_DISKS; /* just a default */
int sparedisks = 0;
@@ -442,9 +443,18 @@ int main(int argc, char *argv[])
ident.level = level;
continue;
+ case O(GROW, 'p'): /* new layout */
+ if (layout_str) {
+ fprintf(stderr,Name ": layout may only be sent once. "
+ "Second value was %s\n", optarg);
+ exit(2);
+ }
+ layout_str = optarg;
+ /* 'Grow' will parse the value */
+ continue;
+
case O(CREATE,'p'): /* raid5 layout */
case O(BUILD,'p'): /* faulty layout */
- case O(GROW, 'p'): /* faulty reconfig */
if (layout != UnSet) {
fprintf(stderr,Name ": layout may only be sent once. "
"Second value was %s\n", optarg);
@@ -483,9 +493,10 @@ int main(int argc, char *argv[])
exit(2);
}
break;
- case -5: /* Faulty
- * modeNNN
- */
+ case LEVEL_FAULTY:
+ /* Faulty
+ * modeNNN
+ */
layout = parse_layout_faulty(optarg);
if (layout == -1) {
fprintf(stderr, Name ": layout %s not understood for faulty.\n",
@@ -1409,13 +1420,13 @@ int main(int argc, char *argv[])
if (rv)
break;
}
- } else if ((size >= 0) + (raiddisks != 0) + (layout != UnSet) + (bitmap_file != NULL)> 1) {
+ } else if ((size >= 0) + (raiddisks != 0) + (layout_str != NULL) + (bitmap_file != NULL)> 1) {
fprintf(stderr, Name ": can change at most one of size, raiddisks, bitmap, and layout\n");
rv = 1;
break;
- } else if (size >= 0 || raiddisks || layout != UnSet)
+ } else if (size >= 0 || raiddisks || layout_str != NULL)
rv = Grow_reshape(devlist->devname, mdfd, quiet, backup_file,
- size, level, layout, chunk, raiddisks);
+ size, level, layout_str, chunk, raiddisks);
else if (bitmap_file) {
if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
rv = Grow_addbitmap(devlist->devname, mdfd, bitmap_file,