summaryrefslogtreecommitdiff
path: root/mdadm.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-11-30 16:23:02 +1100
committerNeilBrown <neilb@suse.de>2010-11-30 16:23:02 +1100
commit36fad8ecb9b8d7835fa9563d065a608304327560 (patch)
tree5ba3e89a68cedd60a32a3f5ae3fd8fefdb171b85 /mdadm.c
parent1c009fc21861a30fd7c30fbb1cb50f9d03030d21 (diff)
Allow K,M,G suffix on chunk sizes as well as device/array sizes.
We already allow K,M,G suffixes for --size and --array-size. Allow it for --chunk and --bitmap-chunk as well. Also add this info to man page, and remove the duplication of info about --array-size. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/mdadm.c b/mdadm.c
index 24a2790c..aa41129b 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -353,12 +353,14 @@ int main(int argc, char *argv[])
"Second value is %s.\n", optarg);
exit(2);
}
- chunk = strtol(optarg, &c, 10);
- if (!optarg[0] || *c || chunk<4 || ((chunk-1)&chunk)) {
+ chunk = parse_size(optarg);
+ if (chunk < 8 || ((chunk-1)&chunk)) {
fprintf(stderr, Name ": invalid chunk/rounding value: %s\n",
optarg);
exit(2);
}
+ /* Covert sectors to K */
+ chunk /= 2;
continue;
#if 0
@@ -966,15 +968,16 @@ int main(int argc, char *argv[])
case O(GROW,BitmapChunk):
case O(BUILD,BitmapChunk):
case O(CREATE,BitmapChunk): /* bitmap chunksize */
- bitmap_chunk = strtol(optarg, &c, 10);
- if (!optarg[0] || *c || bitmap_chunk < 0 ||
- bitmap_chunk & (bitmap_chunk - 1)) {
- fprintf(stderr, Name ": invalid bitmap chunksize: %s\n",
- optarg);
+ bitmap_chunk = parse_size(optarg);
+ if (bitmap_chunk < 0 ||
+ bitmap_chunk & (bitmap_chunk - 1)) {
+ fprintf(stderr,
+ Name ": invalid bitmap chunksize: %s\n",
+ optarg);
exit(2);
}
- /* convert K to B, chunk of 0K means 512B */
- bitmap_chunk = bitmap_chunk ? bitmap_chunk * 1024 : 512;
+ /* convert sectors to B, chunk of 0 means 512B */
+ bitmap_chunk = bitmap_chunk ? bitmap_chunk * 512 : 512;
continue;
case O(GROW, WriteBehind):