summaryrefslogtreecommitdiff
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-08-25 19:56:14 +0900
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 08:56:08 +0200
commit074a7aca7afa6f230104e8e65eba3420263714a5 (patch)
treef418313e45bd55be8156c8a3e8f9a216cf63058d /block/blk-core.c
parenteddb2e26b5ee3c5da68ba4bf1921ba20e2097bff (diff)
block: move stats from disk to part0
Move stats related fields - stamp, in_flight, dkstats - from disk to part0 and unify stat handling such that... * part_stat_*() now updates part0 together if the specified partition is not part0. ie. part_stat_*() are now essentially all_stat_*(). * {disk|all}_stat_*() are gone. * part_round_stats() is updated similary. It handles part0 stats automatically and disk_round_stats() is killed. * part_{inc|dec}_in_fligh() is implemented which automatically updates part0 stats for parts other than part0. * disk_map_sector_rcu() is updated to return part0 if no part matches. Combined with the above changes, this makes NULL special case handling in callers unnecessary. * Separate stats show code paths for disk are collapsed into part stats show code paths. * Rename disk_stat_lock/unlock() to part_stat_lock/unlock() While at it, reposition stat handling macros a bit and add missing parentheses around macro parameters. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c84
1 files changed, 34 insertions, 50 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 505ec61067df..98138f002524 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -61,21 +61,17 @@ static void drive_stat_acct(struct request *rq, int new_io)
if (!blk_fs_request(rq) || !rq->rq_disk)
return;
- cpu = disk_stat_lock();
+ cpu = part_stat_lock();
part = disk_map_sector_rcu(rq->rq_disk, rq->sector);
if (!new_io)
- all_stat_inc(cpu, rq->rq_disk, part, merges[rw], rq->sector);
+ part_stat_inc(cpu, part, merges[rw]);
else {
- disk_round_stats(cpu, rq->rq_disk);
- rq->rq_disk->in_flight++;
- if (part) {
- part_round_stats(cpu, part);
- part->in_flight++;
- }
+ part_round_stats(cpu, part);
+ part_inc_in_flight(part);
}
- disk_stat_unlock();
+ part_stat_unlock();
}
void blk_queue_congestion_threshold(struct request_queue *q)
@@ -983,8 +979,22 @@ static inline void add_request(struct request_queue *q, struct request *req)
__elv_add_request(q, req, ELEVATOR_INSERT_SORT, 0);
}
-/*
- * disk_round_stats() - Round off the performance stats on a struct
+static void part_round_stats_single(int cpu, struct hd_struct *part,
+ unsigned long now)
+{
+ if (now == part->stamp)
+ return;
+
+ if (part->in_flight) {
+ __part_stat_add(cpu, part, time_in_queue,
+ part->in_flight * (now - part->stamp));
+ __part_stat_add(cpu, part, io_ticks, (now - part->stamp));
+ }
+ part->stamp = now;
+}
+
+/**
+ * part_round_stats() - Round off the performance stats on a struct
* disk_stats.
*
* The average IO queue length and utilisation statistics are maintained
@@ -998,36 +1008,15 @@ static inline void add_request(struct request_queue *q, struct request *req)
* /proc/diskstats. This accounts immediately for all queue usage up to
* the current jiffies and restarts the counters again.
*/
-void disk_round_stats(int cpu, struct gendisk *disk)
-{
- unsigned long now = jiffies;
-
- if (now == disk->stamp)
- return;
-
- if (disk->in_flight) {
- disk_stat_add(cpu, disk, time_in_queue,
- disk->in_flight * (now - disk->stamp));
- disk_stat_add(cpu, disk, io_ticks, (now - disk->stamp));
- }
- disk->stamp = now;
-}
-EXPORT_SYMBOL_GPL(disk_round_stats);
-
void part_round_stats(int cpu, struct hd_struct *part)
{
unsigned long now = jiffies;
- if (now == part->stamp)
- return;
-
- if (part->in_flight) {
- part_stat_add(cpu, part, time_in_queue,
- part->in_flight * (now - part->stamp));
- part_stat_add(cpu, part, io_ticks, (now - part->stamp));
- }
- part->stamp = now;
+ if (part->partno)
+ part_round_stats_single(cpu, &part_to_disk(part)->part0, now);
+ part_round_stats_single(cpu, part, now);
}
+EXPORT_SYMBOL_GPL(part_round_stats);
/*
* queue lock must be held
@@ -1567,11 +1556,10 @@ static int __end_that_request_first(struct request *req, int error,
struct hd_struct *part;
int cpu;
- cpu = disk_stat_lock();
+ cpu = part_stat_lock();
part = disk_map_sector_rcu(req->rq_disk, req->sector);
- all_stat_add(cpu, req->rq_disk, part, sectors[rw],
- nr_bytes >> 9, req->sector);
- disk_stat_unlock();
+ part_stat_add(cpu, part, sectors[rw], nr_bytes >> 9);
+ part_stat_unlock();
}
total_bytes = bio_nbytes = 0;
@@ -1758,19 +1746,15 @@ static void end_that_request_last(struct request *req, int error)
struct hd_struct *part;
int cpu;
- cpu = disk_stat_lock();
+ cpu = part_stat_lock();
part = disk_map_sector_rcu(disk, req->sector);
- all_stat_inc(cpu, disk, part, ios[rw], req->sector);
- all_stat_add(cpu, disk, part, ticks[rw], duration, req->sector);
- disk_round_stats(cpu, disk);
- disk->in_flight--;
- if (part) {
- part_round_stats(cpu, part);
- part->in_flight--;
- }
+ part_stat_inc(cpu, part, ios[rw]);
+ part_stat_add(cpu, part, ticks[rw], duration);
+ part_round_stats(cpu, part);
+ part_dec_in_flight(part);
- disk_stat_unlock();
+ part_stat_unlock();
}
if (req->end_io)