Commit e91ece55 authored by Chris Mason's avatar Chris Mason Committed by NeilBrown

md_make_request: don't touch the bio after calling make_request

md_make_request was calling bio_sectors() for part_stat_add
after it was calling the make_request function.  This is
bad because the make_request function can free the bio and
because the bi_size field can change around.

The fix here was suggested by Jens Axboe.  It saves the
sector count before the make_request call.  I hit this
with CONFIG_DEBUG_PAGEALLOC turned on while trying to break
his pretty fusionio card.

Cc: <stable@kernel.org>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent c6751b2b
...@@ -287,6 +287,7 @@ static int md_make_request(struct request_queue *q, struct bio *bio) ...@@ -287,6 +287,7 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
mddev_t *mddev = q->queuedata; mddev_t *mddev = q->queuedata;
int rv; int rv;
int cpu; int cpu;
unsigned int sectors;
if (mddev == NULL || mddev->pers == NULL if (mddev == NULL || mddev->pers == NULL
|| !mddev->ready) { || !mddev->ready) {
...@@ -311,12 +312,16 @@ static int md_make_request(struct request_queue *q, struct bio *bio) ...@@ -311,12 +312,16 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
atomic_inc(&mddev->active_io); atomic_inc(&mddev->active_io);
rcu_read_unlock(); rcu_read_unlock();
/*
* save the sectors now since our bio can
* go away inside make_request
*/
sectors = bio_sectors(bio);
rv = mddev->pers->make_request(mddev, bio); rv = mddev->pers->make_request(mddev, bio);
cpu = part_stat_lock(); cpu = part_stat_lock();
part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors);
bio_sectors(bio));
part_stat_unlock(); part_stat_unlock();
if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
......
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