Commit 24526e81 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md - Use sector rather than block numbers when splitting raid0 requests.

When raid0 needs to split a request, it uses 'block' (1K) addresses
rather than sector (512b) addresses, which causes problems if the sector
address is odd.  This patch fixes the problem.

Thanks to Andy Polyakov <appro@fy.chalmers.se>
parent 34e5ad41
......@@ -332,7 +332,7 @@ static int raid0_stop (mddev_t *mddev)
static int raid0_make_request (request_queue_t *q, struct bio *bio)
{
mddev_t *mddev = q->queuedata;
unsigned int sect_in_chunk, chunksize_bits, chunk_size;
unsigned int sect_in_chunk, chunksize_bits, chunk_size, chunk_sects;
raid0_conf_t *conf = mddev_to_conf(mddev);
struct strip_zone *zone;
mdk_rdev_t *tmp_dev;
......@@ -340,11 +340,12 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
sector_t block, rsect;
chunk_size = mddev->chunk_size >> 10;
chunk_sects = mddev->chunk_size >> 9;
chunksize_bits = ffz(~chunk_size);
block = bio->bi_sector >> 1;
if (unlikely(chunk_size < (block & (chunk_size - 1)) + (bio->bi_size >> 10))) {
if (unlikely(chunk_sects < (bio->bi_sector & (chunk_sects - 1)) + (bio->bi_size >> 9))) {
struct bio_pair *bp;
/* Sanity check -- queue functions should prevent this happening */
if (bio->bi_vcnt != 1 ||
......@@ -353,7 +354,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
/* This is a one page bio that upper layers
* refuse to split for us, so we need to split it.
*/
bp = bio_split(bio, bio_split_pool, (chunk_size - (block & (chunk_size - 1)))<<1 );
bp = bio_split(bio, bio_split_pool, chunk_sects - (bio->bi_sector & (chunk_sects - 1)) );
if (raid0_make_request(q, &bp->bio1))
generic_make_request(&bp->bio1);
if (raid0_make_request(q, &bp->bio2))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment