From: Neil Brown Addresses http://bugme.osdl.org/show_bug.cgi?id=2355 It seems that a merge_bvec_fn needs to be aware of partitioning... who would have thought it :-( The following patch should fix the merge_bvec_fn for both linear and raid0. We teach linear and raid0 about partitions in the merge_bvec_fn. --- 25-akpm/drivers/md/linear.c | 8 ++++++-- 25-akpm/drivers/md/raid0.c | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff -puN drivers/md/linear.c~md-merging-fix drivers/md/linear.c --- 25/drivers/md/linear.c~md-merging-fix Tue Mar 23 15:18:56 2004 +++ 25-akpm/drivers/md/linear.c Tue Mar 23 15:18:56 2004 @@ -61,9 +61,13 @@ static int linear_mergeable_bvec(request mddev_t *mddev = q->queuedata; dev_info_t *dev0; unsigned long maxsectors, bio_sectors = bio->bi_size >> 9; + sector_t sector = bio->bi_sector; - dev0 = which_dev(mddev, bio->bi_sector); - maxsectors = (dev0->size << 1) - (bio->bi_sector - (dev0->offset<<1)); + if (bio->bi_bdev != bio->bi_bdev->bd_contains) + sector += bio->bi_bdev->bd_part->start_sect; + + dev0 = which_dev(mddev, sector); + maxsectors = (dev0->size << 1) - (sector - (dev0->offset<<1)); if (maxsectors < bio_sectors) maxsectors = 0; diff -puN drivers/md/raid0.c~md-merging-fix drivers/md/raid0.c --- 25/drivers/md/raid0.c~md-merging-fix Tue Mar 23 15:18:56 2004 +++ 25-akpm/drivers/md/raid0.c Tue Mar 23 15:18:56 2004 @@ -224,6 +224,9 @@ static int raid0_mergeable_bvec(request_ unsigned int chunk_sectors = mddev->chunk_size >> 9; unsigned int bio_sectors = bio->bi_size >> 9; + if (bio->bi_bdev != bio->bi_bdev->bd_contains) + sector += bio->bi_bdev->bd_part->start_sect; + max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; if (max < 0) max = 0; /* bio_add cannot handle a negative return */ if (max <= biovec->bv_len && bio_sectors == 0) _