Commit d72d904a authored by Jens Axboe's avatar Jens Axboe

[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: default avatarJens Axboe <axboe@suse.de>
parent d83c671f
...@@ -2387,16 +2387,12 @@ static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io) ...@@ -2387,16 +2387,12 @@ static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io)
if (!blk_fs_request(rq) || !rq->rq_disk) if (!blk_fs_request(rq) || !rq->rq_disk)
return; return;
if (rw == READ) { if (!new_io) {
__disk_stat_add(rq->rq_disk, read_sectors, nr_sectors); if (rw == READ)
if (!new_io)
__disk_stat_inc(rq->rq_disk, read_merges); __disk_stat_inc(rq->rq_disk, read_merges);
} else if (rw == WRITE) { else
__disk_stat_add(rq->rq_disk, write_sectors, nr_sectors);
if (!new_io)
__disk_stat_inc(rq->rq_disk, write_merges); __disk_stat_inc(rq->rq_disk, write_merges);
} } else {
if (new_io) {
disk_round_stats(rq->rq_disk); disk_round_stats(rq->rq_disk);
rq->rq_disk->in_flight++; rq->rq_disk->in_flight++;
} }
...@@ -3048,6 +3044,13 @@ static int __end_that_request_first(struct request *req, int uptodate, ...@@ -3048,6 +3044,13 @@ static int __end_that_request_first(struct request *req, int uptodate,
(unsigned long long)req->sector); (unsigned long long)req->sector);
} }
if (blk_fs_request(req) && req->rq_disk) {
if (rq_data_dir(req) == READ)
__disk_stat_add(req->rq_disk, read_sectors, nr_bytes >> 9);
else
__disk_stat_add(req->rq_disk, write_sectors, nr_bytes >> 9);
}
total_bytes = bio_nbytes = 0; total_bytes = bio_nbytes = 0;
while ((bio = req->bio) != NULL) { while ((bio = req->bio) != NULL) {
int nbytes; int nbytes;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment