aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-03-25 01:20:56 -0400
committerNeilBrown <neilb@suse.de>2010-05-18 01:27:52 -0400
commit490773268cf64f68da2470e07b52c7944da6312d (patch)
treed394aafa7203c316db6b63f128b8894e18993fca /drivers/md/md.c
parent2b7f22284d71975e37a82db154386348eec0e52c (diff)
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>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c5a1b0725c9f..117663d2a4e5 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -214,8 +214,11 @@ static DEFINE_SPINLOCK(all_mddevs_lock);
214 */ 214 */
215static int md_make_request(struct request_queue *q, struct bio *bio) 215static int md_make_request(struct request_queue *q, struct bio *bio)
216{ 216{
217 const int rw = bio_data_dir(bio);
217 mddev_t *mddev = q->queuedata; 218 mddev_t *mddev = q->queuedata;
218 int rv; 219 int rv;
220 int cpu;
221
219 if (mddev == NULL || mddev->pers == NULL) { 222 if (mddev == NULL || mddev->pers == NULL) {
220 bio_io_error(bio); 223 bio_io_error(bio);
221 return 0; 224 return 0;
@@ -236,7 +239,15 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
236 } 239 }
237 atomic_inc(&mddev->active_io); 240 atomic_inc(&mddev->active_io);
238 rcu_read_unlock(); 241 rcu_read_unlock();
242
239 rv = mddev->pers->make_request(q, bio); 243 rv = mddev->pers->make_request(q, bio);
244
245 cpu = part_stat_lock();
246 part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
247 part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw],
248 bio_sectors(bio));
249 part_stat_unlock();
250
240 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) 251 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
241 wake_up(&mddev->sb_wait); 252 wake_up(&mddev->sb_wait);
242 253