md: move io accounting out of personalities into md_make_request
While I generally prefer letting personalities do as much as possible, given that we have a central md_make_request anyway we may as well use it to simplify code. Also this centralises knowledge of ->gendisk which will help later. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
@@ -214,8 +214,11 @@ static DEFINE_SPINLOCK(all_mddevs_lock);
|
||||
*/
|
||||
static int md_make_request(struct request_queue *q, struct bio *bio)
|
||||
{
|
||||
const int rw = bio_data_dir(bio);
|
||||
mddev_t *mddev = q->queuedata;
|
||||
int rv;
|
||||
int cpu;
|
||||
|
||||
if (mddev == NULL || mddev->pers == NULL) {
|
||||
bio_io_error(bio);
|
||||
return 0;
|
||||
@@ -236,7 +239,15 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
|
||||
}
|
||||
atomic_inc(&mddev->active_io);
|
||||
rcu_read_unlock();
|
||||
|
||||
rv = mddev->pers->make_request(q, bio);
|
||||
|
||||
cpu = part_stat_lock();
|
||||
part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
|
||||
part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw],
|
||||
bio_sectors(bio));
|
||||
part_stat_unlock();
|
||||
|
||||
if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
|
||||
wake_up(&mddev->sb_wait);
|
||||
|
||||
|
Reference in New Issue
Block a user