]> git.hungrycats.org Git - linux/commitdiff
[PATCH] md: make sure the size of a raid5/6 array is a multiple of the chunk size.
authorNeil Brown <neilb@cse.unsw.edu.au>
Sat, 5 Jun 2004 03:56:05 +0000 (20:56 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 5 Jun 2004 03:56:05 +0000 (20:56 -0700)
Normally the size is chosen as a multiple of the chunk size, but if the size
is explicitly chosen, it might not be.  So we force it.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/md/raid5.c
drivers/md/raid6main.c

index af11a0815e0adcfa6c375896e5a539bf082a26f6..2e8782368b7e270050e254fb3336edbf26ae749e 100644 (file)
@@ -1577,6 +1577,9 @@ static int run (mddev_t *mddev)
        conf->algorithm = mddev->layout;
        conf->max_nr_stripes = NR_STRIPES;
 
+       /* device size must be a multiple of chunk size */
+       mddev->size &= ~(mddev->chunk_size/1024 -1);
+
        if (!conf->chunk_size || conf->chunk_size % 4) {
                printk(KERN_ERR "raid5: invalid chunk size %d for %s\n",
                        conf->chunk_size, mdname(mddev));
index bc14ca1c161e84973aaf1d0f8ae979757bd722f7..5f9436e98d3464fdb13d58ab61af49f7d7638ac5 100644 (file)
@@ -1741,6 +1741,9 @@ static int run (mddev_t *mddev)
        conf->algorithm = mddev->layout;
        conf->max_nr_stripes = NR_STRIPES;
 
+       /* device size must be a multiple of chunk size */
+       mddev->size &= ~(mddev->chunk_size/1024 -1);
+
        if (conf->raid_disks < 4) {
                printk(KERN_ERR "raid6: not enough configured devices for %s (%d, minimum 4)\n",
                       mdname(mddev), conf->raid_disks);