summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2012-08-30 13:55:58 -0700
committerJens Axboe <axboe@kernel.dk>2012-10-04 11:04:38 +0200
commit99350471ae4c627404e77f67587ff4a44a9a5ca1 (patch)
treeffca34865cb0dba153cc86abfa9a9e48aed160a8
parentc2061f3876d853f6dfe5a30d8d37a1c5299db79c (diff)
blk-mq: add drive accounting
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-core.c4
-rw-r--r--block/blk-mq.c7
-rw-r--r--block/blk.h2
3 files changed, 10 insertions, 3 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 5d8cbd3d4d7a..dfc4b646c16f 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -59,7 +59,7 @@ struct kmem_cache *blk_requestq_cachep;
*/
static struct workqueue_struct *kblockd_workqueue;
-static void drive_stat_acct(struct request *rq, int new_io)
+void drive_stat_acct(struct request *rq, int new_io)
{
struct hd_struct *part;
int rw = rq_data_dir(rq);
@@ -1982,7 +1982,7 @@ unsigned int blk_rq_err_bytes(const struct request *rq)
}
EXPORT_SYMBOL_GPL(blk_rq_err_bytes);
-static void blk_account_io_completion(struct request *req, unsigned int bytes)
+void blk_account_io_completion(struct request *req, unsigned int bytes)
{
if (blk_do_io_stat(req)) {
const int rw = rq_data_dir(req);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1a260611ab54..cc656e6434f9 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -143,6 +143,7 @@ static void blk_mq_free_request(struct request *rq)
static void __blk_mq_end_io(struct request *rq, int error)
{
struct bio *bio = rq->bio;
+ unsigned int bytes = 0;
if (blk_mark_rq_complete(rq))
return;
@@ -153,10 +154,12 @@ static void __blk_mq_end_io(struct request *rq, int error)
struct bio *next = bio->bi_next;
bio->bi_next = NULL;
+ bytes += bio->bi_size;
bio_endio(bio, error);
bio = next;
}
+ blk_account_io_completion(rq, bytes);
blk_mq_free_request(rq);
}
@@ -514,8 +517,10 @@ static struct request *blk_mq_bio_to_request(struct request_queue *q,
rq = __blk_mq_alloc_request(q, ctx, rw_flags, GFP_ATOMIC | __GFP_WAIT,
has_lock);
- if (rq)
+ if (rq) {
init_request_from_bio(rq, bio);
+ drive_stat_acct(rq, 1);
+ }
return rq;
}
diff --git a/block/blk.h b/block/blk.h
index 1b5404355e82..054f034c8e95 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -48,6 +48,8 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
struct bio *bio);
bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
unsigned int *request_count);
+void drive_stat_acct(struct request *rq, int new_io);
+void blk_account_io_completion(struct request *req, unsigned int bytes);
/*
* Internal atomic flags for request handling