]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
md: raid0/linear: ensure device sizes are rounded to chunk size.
authorNeilBrown <neilb@suse.de>
Wed, 17 Jun 2009 22:48:55 +0000 (08:48 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 17 Jun 2009 22:48:55 +0000 (08:48 +1000)
This is currently ensured by common code, but it is more reliable to
ensure it where it is needed in personality code.
All the other personalities that care already round the size to
the chunk_size.  raid0 and linear are the only hold-outs.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/linear.c
drivers/md/raid0.c

index 9f7cec42dd8e2d7ed41a60e505f9e849c510b4bd..dda2f1b64a6dce3885f16cda83b525f1ed32f9cf 100644 (file)
@@ -135,6 +135,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
        list_for_each_entry(rdev, &mddev->disks, same_set) {
                int j = rdev->raid_disk;
                dev_info_t *disk = conf->disks + j;
+               sector_t sectors;
 
                if (j < 0 || j >= raid_disks || disk->rdev) {
                        printk("linear: disk numbering problem. Aborting!\n");
@@ -142,6 +143,11 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
                }
 
                disk->rdev = rdev;
+               if (mddev->chunk_sectors) {
+                       sectors = rdev->sectors;
+                       sector_div(sectors, mddev->chunk_sectors);
+                       rdev->sectors = sectors * mddev->chunk_sectors;
+               }
 
                blk_queue_stack_limits(mddev->queue,
                                       rdev->bdev->bd_disk->queue);
index 11e384253718487b3fb99f3804825281094f72f1..717e64a4af9a2f225f216c28b7e27d00979f81a3 100644 (file)
@@ -100,6 +100,12 @@ static int create_strip_zones(mddev_t *mddev)
                printk(KERN_INFO "raid0: looking at %s\n",
                        bdevname(rdev1->bdev,b));
                c = 0;
+
+               /* round size to chunk_size */
+               sectors = rdev1->sectors;
+               sector_div(sectors, mddev->chunk_sectors);
+               rdev1->sectors = sectors * mddev->chunk_sectors;
+
                list_for_each_entry(rdev2, &mddev->disks, same_set) {
                        printk(KERN_INFO "raid0:   comparing %s(%llu)",
                               bdevname(rdev1->bdev,b),