Skip to content

Commit

Permalink
md: raid0/linear: ensure device sizes are rounded to chunk size.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeilBrown committed Jun 17, 2009
1 parent 1b57f13 commit 13f2682
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/md/linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,19 @@ 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");
goto out;
}

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);
Expand Down
6 changes: 6 additions & 0 deletions drivers/md/raid0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 13f2682

Please sign in to comment.