aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorMichael Callahan <michaelcallahan@fb.com>2018-07-18 07:47:39 -0400
committerJens Axboe <axboe@kernel.dk>2018-07-18 10:44:20 -0400
commitddcf35d397976421a4ec1d0d00fbcc027a8cb034 (patch)
treeebffc9e2971b6c7bc3223a1c584a9c81372a34bc /block/blk-core.c
parentdbae2c551377b6533a00c11fc7ede370100ab404 (diff)
block: Add and use op_stat_group() for indexing disk_stat fields.
Add and use a new op_stat_group() function for indexing partition stat fields rather than indexing them by rq_data_dir() or bio_data_dir(). This function works similarly to op_is_sync() in that it takes the request::cmd_flags or bio::bi_opf flags and determines which stats should et updated. In addition, the second parameter to generic_start_io_acct() and generic_end_io_acct() is now a REQ_OP rather than simply a read or write bit and it uses op_stat_group() on the parameter to determine the stat group. Note that the partition in_flight counts are not part of the per-cpu statistics and as such are not indexed via this function. It's now indexed by op_is_write(). tj: Refreshed on top of v4.17. Updated to pass around REQ_OP. Signed-off-by: Michael Callahan <michaelcallahan@fb.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Joshua Morris <josh.h.morris@us.ibm.com> Cc: Philipp Reisner <philipp.reisner@linbit.com> Cc: Matias Bjorling <mb@lightnvm.io> Cc: Kent Overstreet <kent.overstreet@gmail.com> Cc: Alasdair Kergon <agk@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index c4b57d8806fe..03a4ea93a5f3 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2702,13 +2702,13 @@ EXPORT_SYMBOL_GPL(blk_rq_err_bytes);
2702void blk_account_io_completion(struct request *req, unsigned int bytes) 2702void blk_account_io_completion(struct request *req, unsigned int bytes)
2703{ 2703{
2704 if (blk_do_io_stat(req)) { 2704 if (blk_do_io_stat(req)) {
2705 const int rw = rq_data_dir(req); 2705 const int sgrp = op_stat_group(req_op(req));
2706 struct hd_struct *part; 2706 struct hd_struct *part;
2707 int cpu; 2707 int cpu;
2708 2708
2709 cpu = part_stat_lock(); 2709 cpu = part_stat_lock();
2710 part = req->part; 2710 part = req->part;
2711 part_stat_add(cpu, part, sectors[rw], bytes >> 9); 2711 part_stat_add(cpu, part, sectors[sgrp], bytes >> 9);
2712 part_stat_unlock(); 2712 part_stat_unlock();
2713 } 2713 }
2714} 2714}
@@ -2722,7 +2722,7 @@ void blk_account_io_done(struct request *req, u64 now)
2722 */ 2722 */
2723 if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) { 2723 if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) {
2724 unsigned long duration; 2724 unsigned long duration;
2725 const int rw = rq_data_dir(req); 2725 const int sgrp = op_stat_group(req_op(req));
2726 struct hd_struct *part; 2726 struct hd_struct *part;
2727 int cpu; 2727 int cpu;
2728 2728
@@ -2730,10 +2730,10 @@ void blk_account_io_done(struct request *req, u64 now)
2730 cpu = part_stat_lock(); 2730 cpu = part_stat_lock();
2731 part = req->part; 2731 part = req->part;
2732 2732
2733 part_stat_inc(cpu, part, ios[rw]); 2733 part_stat_inc(cpu, part, ios[sgrp]);
2734 part_stat_add(cpu, part, ticks[rw], duration); 2734 part_stat_add(cpu, part, ticks[sgrp], duration);
2735 part_round_stats(req->q, cpu, part); 2735 part_round_stats(req->q, cpu, part);
2736 part_dec_in_flight(req->q, part, rw); 2736 part_dec_in_flight(req->q, part, rq_data_dir(req));
2737 2737
2738 hd_struct_put(part); 2738 hd_struct_put(part);
2739 part_stat_unlock(); 2739 part_stat_unlock();