]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Create: allow chunksize to be non-power-of-2.
authorNeilBrown <neilb@suse.de>
Tue, 10 May 2011 07:35:41 +0000 (17:35 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 10 May 2011 07:35:41 +0000 (17:35 +1000)
RAID0 has accepted chunksizes that are not a power of 2 since 2.6.30.
So it time mdadm allowed that to be used.

Signed-off-by: NeilBrown <neilb@suse.de>
Build.c
Create.c
mdadm.8.in
mdadm.c

diff --git a/Build.c b/Build.c
index cb9f01e33264376e63be43c2efd8da1672c96461..4338e190d9270ee0e990ad6b20aa53ca9255f817 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -254,6 +254,10 @@ int Build(char *mddev, int chunk, int level, int layout,
                if (ioctl(mdfd, RUN_ARRAY, &param)) {
                        fprintf(stderr, Name ": RUN_ARRAY failed: %s\n",
                                strerror(errno));
+                       if (chunk & (chunk-1)) {
+                               fprintf(stderr, "     : Problem may be that chunk size"
+                                       " is not a power of 2\n");
+                       }
                        goto abort;
                }
        } else {
index 9ee09280e4c29aa74427680b43b89c786a55dadc..ef60244a352216dd950f8a9301cae242be3c7b29 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -930,6 +930,10 @@ int Create(struct supertype *st, char *mddev,
                        if (ioctl(mdfd, RUN_ARRAY, &param)) {
                                fprintf(stderr, Name ": RUN_ARRAY failed: %s\n",
                                        strerror(errno));
+                               if (info.array.chunk_size & (info.array.chunk_size-1)) {
+                                       fprintf(stderr, "     : Problem may be that "
+                                               "chunk size is not a power of 2\n");
+                               }
                                ioctl(mdfd, STOP_ARRAY, NULL);
                                goto abort;
                        }
index d9b51473797b8cb6c72431370cccc5799943c417..3fbfcce81fcdcc9b310cc45e1ed4c63a3b461a23 100644 (file)
@@ -484,6 +484,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.
 
+RAID4, RAID5, RAID6, and RAID10 require the chunk size to be a power
+of 2.  In any case it must be a multiple of 4KB.
+
 A suffix of 'M' or 'G' can be given to indicate Megabytes or
 Gigabytes respectively.
 
diff --git a/mdadm.c b/mdadm.c
index 662822d1c50dc43df806765fa905ce9d076ad7de..d55e9cfa3081b0a91d7f0d93f9e5de3679e58232 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -361,12 +361,12 @@ int main(int argc, char *argv[])
                                exit(2);
                        }
                        chunk = parse_size(optarg);
-                       if (chunk < 8 || ((chunk-1)&chunk)) {
+                       if (chunk < 8 || (chunk&1)) {
                                fprintf(stderr, Name ": invalid chunk/rounding value: %s\n",
                                        optarg);
                                exit(2);
                        }
-                       /* Covert sectors to K */
+                       /* Convert sectors to K */
                        chunk /= 2;
                        continue;