diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-02-07 19:21:48 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-02-07 17:53:28 -0500 |
commit | e91ece5590b3c728624ab57043fc7a05069c604a (patch) | |
tree | 4c5fd4ad374caf5bd9c5f575b0a228b5cdf2f191 /drivers/md | |
parent | c6751b2bde477f56ceef67aa1d298ce44e8e2e23 (diff) |
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: Chris Mason <chris.mason@oracle.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 1138d1053e9a..0cc30ecda4c1 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -287,6 +287,7 @@ static int md_make_request(struct request_queue *q, struct bio *bio) | |||
287 | mddev_t *mddev = q->queuedata; | 287 | mddev_t *mddev = q->queuedata; |
288 | int rv; | 288 | int rv; |
289 | int cpu; | 289 | int cpu; |
290 | unsigned int sectors; | ||
290 | 291 | ||
291 | if (mddev == NULL || mddev->pers == NULL | 292 | if (mddev == NULL || mddev->pers == NULL |
292 | || !mddev->ready) { | 293 | || !mddev->ready) { |
@@ -311,12 +312,16 @@ static int md_make_request(struct request_queue *q, struct bio *bio) | |||
311 | atomic_inc(&mddev->active_io); | 312 | atomic_inc(&mddev->active_io); |
312 | rcu_read_unlock(); | 313 | rcu_read_unlock(); |
313 | 314 | ||
315 | /* | ||
316 | * save the sectors now since our bio can | ||
317 | * go away inside make_request | ||
318 | */ | ||
319 | sectors = bio_sectors(bio); | ||
314 | rv = mddev->pers->make_request(mddev, bio); | 320 | rv = mddev->pers->make_request(mddev, bio); |
315 | 321 | ||
316 | cpu = part_stat_lock(); | 322 | cpu = part_stat_lock(); |
317 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); | 323 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
318 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | 324 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors); |
319 | bio_sectors(bio)); | ||
320 | part_stat_unlock(); | 325 | part_stat_unlock(); |
321 | 326 | ||
322 | if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) | 327 | if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) |