From: NeilBrown Date: Tue, 30 Nov 2010 05:23:02 +0000 (+1100) Subject: Allow K,M,G suffix on chunk sizes as well as device/array sizes. X-Git-Tag: mdadm-3.2~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36fad8ecb9b8d7835fa9563d065a608304327560;p=thirdparty%2Fmdadm.git 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 --- diff --git a/mdadm.8.in b/mdadm.8.in index d911cb34..1cfd9170 100644 --- a/mdadm.8.in +++ b/mdadm.8.in @@ -410,6 +410,9 @@ If this is not specified size, though if there is a variance among the drives of greater than 1%, a warning is issued. +A suffix of 'M' or 'G' can be given to indicate Megabytes or +Gigabytes respectively. + This value can be set with .B \-\-grow for RAID level 1/4/5/6. If the array was created with a size smaller @@ -428,7 +431,7 @@ metadata such as DDF and IMSM. .BR \-Z ", " \-\-array-size= This is only meaningful with .B \-\-grow -and its effect is not persistent: when the array is stopped an +and its effect is not persistent: when the array is stopped and restarted the default array size will be restored. Setting the array-size causes the array to appear smaller to programs @@ -439,6 +442,13 @@ but setting the size with is, it is required that the array size is reduced as appropriate before the number of devices in the array is reduced. +A suffix of 'M' or 'G' can be given to indicate Megabytes or +Gigabytes respectively. +A value of +.B max +restores the apparent size of the array to be whatever the real +amount of available space is. + .TP .BR \-c ", " \-\-chunk= Specify chunk size of kibibytes. The default when creating an @@ -446,6 +456,9 @@ array is 512KB. To ensure compatibility with earlier versions, the default when Building and array with no persistent metadata is 64KB. This is only meaningful for RAID0, RAID4, RAID5, RAID6, and RAID10. +A suffix of 'M' or 'G' can be given to indicate Megabytes or +Gigabytes respectively. + .TP .BR \-\-rounding= Specify rounding factor for a Linear array. The size of each @@ -618,6 +631,9 @@ When using an bitmap, the chunksize defaults to 64Meg, or larger if necessary to fit the bitmap into the available space. +A suffix of 'M' or 'G' can be given to indicate Megabytes or +Gigabytes respectively. + .TP .BR \-W ", " \-\-write\-mostly subsequent devices listed in a @@ -666,21 +682,6 @@ See the GROW MODE section below on RAID\-DEVICES CHANGES. The file should be stored on a separate device, not on the RAID array being reshaped. -.TP -.BR \-\-array-size= ", " \-Z -Set the size of the array which is seen by users of the device such as -filesystems. This can be less that the real size, but never greater. -The size set this way does not persist across restarts of the array. - -This is most useful when reducing the number of devices in a RAID5 or -RAID6. Such arrays require the array-size to be reduced before a -reshape can be performed that reduces the real size. - -A value of -.B max -restores the apparent size of the array to be whatever the real -amount of available space is. - .TP .BR \-N ", " \-\-name= Set a 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):