From f870229fba606cf89fd912737f8011926697ff14 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 4 Jun 2004 20:56:05 -0700 Subject: [PATCH] [PATCH] md: make sure the size of a raid5/6 array is a multiple of the chunk size. 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid5.c | 3 +++ drivers/md/raid6main.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index af11a0815e0ad..2e8782368b7e2 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -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)); diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index bc14ca1c161e8..5f9436e98d346 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -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); -- 2.53.0