Commit d72d904a5367ad4ca3f2c9a2ce8c3a68f0b28bf0
1 parent
d83c671fb7
Exists in
master
and in
7 other branches
[BLOCK] Update read/write block io statistics at completion time
Right now we do it at queueing time, which works alright for reads (since they are usually sync), but not for async writes since we can queue io a lot faster than we can complete it. This makes the vmstat output look extremely bursty. Signed-off-by: Jens Axboe <axboe@suse.de>
Showing 1 changed file with 11 additions and 8 deletions Side-by-side Diff
drivers/block/ll_rw_blk.c
... | ... | @@ -2387,16 +2387,12 @@ |
2387 | 2387 | if (!blk_fs_request(rq) || !rq->rq_disk) |
2388 | 2388 | return; |
2389 | 2389 | |
2390 | - if (rw == READ) { | |
2391 | - __disk_stat_add(rq->rq_disk, read_sectors, nr_sectors); | |
2392 | - if (!new_io) | |
2390 | + if (!new_io) { | |
2391 | + if (rw == READ) | |
2393 | 2392 | __disk_stat_inc(rq->rq_disk, read_merges); |
2394 | - } else if (rw == WRITE) { | |
2395 | - __disk_stat_add(rq->rq_disk, write_sectors, nr_sectors); | |
2396 | - if (!new_io) | |
2393 | + else | |
2397 | 2394 | __disk_stat_inc(rq->rq_disk, write_merges); |
2398 | - } | |
2399 | - if (new_io) { | |
2395 | + } else { | |
2400 | 2396 | disk_round_stats(rq->rq_disk); |
2401 | 2397 | rq->rq_disk->in_flight++; |
2402 | 2398 | } |
... | ... | @@ -3046,6 +3042,13 @@ |
3046 | 3042 | printk("end_request: I/O error, dev %s, sector %llu\n", |
3047 | 3043 | req->rq_disk ? req->rq_disk->disk_name : "?", |
3048 | 3044 | (unsigned long long)req->sector); |
3045 | + } | |
3046 | + | |
3047 | + if (blk_fs_request(req) && req->rq_disk) { | |
3048 | + if (rq_data_dir(req) == READ) | |
3049 | + __disk_stat_add(req->rq_disk, read_sectors, nr_bytes >> 9); | |
3050 | + else | |
3051 | + __disk_stat_add(req->rq_disk, write_sectors, nr_bytes >> 9); | |
3049 | 3052 | } |
3050 | 3053 | |
3051 | 3054 | total_bytes = bio_nbytes = 0; |