diff options
author | Jerome Marchand <jmarchan@redhat.com> | 2008-02-08 05:04:35 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-02-08 06:41:56 -0500 |
commit | 6f2576af5ba5913538fda7dfb7c6a17771025477 (patch) | |
tree | ff55bc30686ccec8b0ce22eb3844e78a52aea875 /block/blk-core.c | |
parent | ea5c48ab2a76559d4af39e1f7de137c0851ac0a5 (diff) |
Enhanced partition statistics: update partition statitics
Updates the enhanced partition statistics in generic block layer
besides the disk statistics.
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r-- | block/blk-core.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index fba4ca7c608..2358fc5de5a 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -60,10 +60,15 @@ static void drive_stat_acct(struct request *rq, int new_io) | |||
60 | return; | 60 | return; |
61 | 61 | ||
62 | if (!new_io) { | 62 | if (!new_io) { |
63 | __disk_stat_inc(rq->rq_disk, merges[rw]); | 63 | __all_stat_inc(rq->rq_disk, merges[rw], rq->sector); |
64 | } else { | 64 | } else { |
65 | struct hd_struct *part = get_part(rq->rq_disk, rq->sector); | ||
65 | disk_round_stats(rq->rq_disk); | 66 | disk_round_stats(rq->rq_disk); |
66 | rq->rq_disk->in_flight++; | 67 | rq->rq_disk->in_flight++; |
68 | if (part) { | ||
69 | part_round_stats(part); | ||
70 | part->in_flight++; | ||
71 | } | ||
67 | } | 72 | } |
68 | } | 73 | } |
69 | 74 | ||
@@ -997,6 +1002,21 @@ void disk_round_stats(struct gendisk *disk) | |||
997 | } | 1002 | } |
998 | EXPORT_SYMBOL_GPL(disk_round_stats); | 1003 | EXPORT_SYMBOL_GPL(disk_round_stats); |
999 | 1004 | ||
1005 | void part_round_stats(struct hd_struct *part) | ||
1006 | { | ||
1007 | unsigned long now = jiffies; | ||
1008 | |||
1009 | if (now == part->stamp) | ||
1010 | return; | ||
1011 | |||
1012 | if (part->in_flight) { | ||
1013 | __part_stat_add(part, time_in_queue, | ||
1014 | part->in_flight * (now - part->stamp)); | ||
1015 | __part_stat_add(part, io_ticks, (now - part->stamp)); | ||
1016 | } | ||
1017 | part->stamp = now; | ||
1018 | } | ||
1019 | |||
1000 | /* | 1020 | /* |
1001 | * queue lock must be held | 1021 | * queue lock must be held |
1002 | */ | 1022 | */ |
@@ -1530,7 +1550,8 @@ static int __end_that_request_first(struct request *req, int error, | |||
1530 | if (blk_fs_request(req) && req->rq_disk) { | 1550 | if (blk_fs_request(req) && req->rq_disk) { |
1531 | const int rw = rq_data_dir(req); | 1551 | const int rw = rq_data_dir(req); |
1532 | 1552 | ||
1533 | disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9); | 1553 | all_stat_add(req->rq_disk, sectors[rw], |
1554 | nr_bytes >> 9, req->sector); | ||
1534 | } | 1555 | } |
1535 | 1556 | ||
1536 | total_bytes = bio_nbytes = 0; | 1557 | total_bytes = bio_nbytes = 0; |
@@ -1715,11 +1736,16 @@ static void end_that_request_last(struct request *req, int error) | |||
1715 | if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { | 1736 | if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { |
1716 | unsigned long duration = jiffies - req->start_time; | 1737 | unsigned long duration = jiffies - req->start_time; |
1717 | const int rw = rq_data_dir(req); | 1738 | const int rw = rq_data_dir(req); |
1739 | struct hd_struct *part = get_part(disk, req->sector); | ||
1718 | 1740 | ||
1719 | __disk_stat_inc(disk, ios[rw]); | 1741 | __all_stat_inc(disk, ios[rw], req->sector); |
1720 | __disk_stat_add(disk, ticks[rw], duration); | 1742 | __all_stat_add(disk, ticks[rw], duration, req->sector); |
1721 | disk_round_stats(disk); | 1743 | disk_round_stats(disk); |
1722 | disk->in_flight--; | 1744 | disk->in_flight--; |
1745 | if (part) { | ||
1746 | part_round_stats(part); | ||
1747 | part->in_flight--; | ||
1748 | } | ||
1723 | } | 1749 | } |
1724 | 1750 | ||
1725 | if (req->end_io) | 1751 | if (req->end_io) |