From e1e94543d1a2a930e11603609b9da61742f5c261 Mon Sep 17 00:00:00 2001 From: "Jun'ichi \"Nick\" Nomura" Date: Wed, 1 Feb 2006 03:04:53 -0800 Subject: [PATCH] --- yaml --- r: 19329 b: refs/heads/master c: 3eaf840e0b0046f56602c524c7ba58a82f5526c5 h: refs/heads/master i: 19327: c0045610c8f820f73f739975e3b0864827cb5897 v: v3 --- [refs] | 2 +- trunk/block/ll_rw_blk.c | 2 ++ trunk/drivers/md/dm.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index cb243a495c6c..748d28926ffb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 12f03a49cf0ab5e8511911142d28699499a572c4 +refs/heads/master: 3eaf840e0b0046f56602c524c7ba58a82f5526c5 diff --git a/trunk/block/ll_rw_blk.c b/trunk/block/ll_rw_blk.c index d38b4afa37ef..f9fc07efd2da 100644 --- a/trunk/block/ll_rw_blk.c +++ b/trunk/block/ll_rw_blk.c @@ -2579,6 +2579,8 @@ void disk_round_stats(struct gendisk *disk) disk->stamp = now; } +EXPORT_SYMBOL_GPL(disk_round_stats); + /* * queue lock must be held */ diff --git a/trunk/drivers/md/dm.c b/trunk/drivers/md/dm.c index c47518386c91..e9adeb9d172f 100644 --- a/trunk/drivers/md/dm.c +++ b/trunk/drivers/md/dm.c @@ -31,6 +31,7 @@ struct dm_io { int error; struct bio *bio; atomic_t io_count; + unsigned long start_time; }; /* @@ -244,6 +245,36 @@ static inline void free_tio(struct mapped_device *md, struct target_io *tio) mempool_free(tio, md->tio_pool); } +static void start_io_acct(struct dm_io *io) +{ + struct mapped_device *md = io->md; + + io->start_time = jiffies; + + preempt_disable(); + disk_round_stats(dm_disk(md)); + preempt_enable(); + dm_disk(md)->in_flight = atomic_inc_return(&md->pending); +} + +static int end_io_acct(struct dm_io *io) +{ + struct mapped_device *md = io->md; + struct bio *bio = io->bio; + unsigned long duration = jiffies - io->start_time; + int pending; + int rw = bio_data_dir(bio); + + preempt_disable(); + disk_round_stats(dm_disk(md)); + preempt_enable(); + dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending); + + disk_stat_add(dm_disk(md), ticks[rw], duration); + + return !pending; +} + /* * Add the bio to the list of deferred io. */ @@ -299,7 +330,7 @@ static void dec_pending(struct dm_io *io, int error) io->error = error; if (atomic_dec_and_test(&io->io_count)) { - if (atomic_dec_and_test(&io->md->pending)) + if (end_io_acct(io)) /* nudge anyone waiting on suspend queue */ wake_up(&io->md->wait); @@ -554,7 +585,7 @@ static void __split_bio(struct mapped_device *md, struct bio *bio) ci.sector_count = bio_sectors(bio); ci.idx = bio->bi_idx; - atomic_inc(&md->pending); + start_io_acct(ci.io); while (ci.sector_count) __clone_and_map(&ci);