Commit 5577022f authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Jens Axboe

block: account iowait time when waiting for completion of IO request

Using wait_for_completion() for waiting for a IO request to be executed
results in wrong iowait time accounting. For example, a system having
the only task doing write() and fdatasync() on a block device can be
reported being idle instead of iowaiting as it should because
blkdev_issue_flush() calls wait_for_completion() which in turn calls
schedule() that does not increment the iowait proc counter and thus does
not turn on iowait time accounting.

The patch makes block layer use wait_for_completion_io() instead of
wait_for_completion() where appropriate to account iowait time
correctly.
Signed-off-by: default avatarVladimir Davydov <vdavydov@parallels.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 686855f5
...@@ -120,9 +120,9 @@ int blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk, ...@@ -120,9 +120,9 @@ int blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk,
/* Prevent hang_check timer from firing at us during very long I/O */ /* Prevent hang_check timer from firing at us during very long I/O */
hang_check = sysctl_hung_task_timeout_secs; hang_check = sysctl_hung_task_timeout_secs;
if (hang_check) if (hang_check)
while (!wait_for_completion_timeout(&wait, hang_check * (HZ/2))); while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2)));
else else
wait_for_completion(&wait); wait_for_completion_io(&wait);
if (rq->errors) if (rq->errors)
err = -EIO; err = -EIO;
......
...@@ -436,7 +436,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, ...@@ -436,7 +436,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
bio_get(bio); bio_get(bio);
submit_bio(WRITE_FLUSH, bio); submit_bio(WRITE_FLUSH, bio);
wait_for_completion(&wait); wait_for_completion_io(&wait);
/* /*
* The driver must store the error location in ->bi_sector, if * The driver must store the error location in ->bi_sector, if
......
...@@ -126,7 +126,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, ...@@ -126,7 +126,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
/* Wait for bios in-flight */ /* Wait for bios in-flight */
if (!atomic_dec_and_test(&bb.done)) if (!atomic_dec_and_test(&bb.done))
wait_for_completion(&wait); wait_for_completion_io(&wait);
if (!test_bit(BIO_UPTODATE, &bb.flags)) if (!test_bit(BIO_UPTODATE, &bb.flags))
ret = -EIO; ret = -EIO;
...@@ -200,7 +200,7 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, ...@@ -200,7 +200,7 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
/* Wait for bios in-flight */ /* Wait for bios in-flight */
if (!atomic_dec_and_test(&bb.done)) if (!atomic_dec_and_test(&bb.done))
wait_for_completion(&wait); wait_for_completion_io(&wait);
if (!test_bit(BIO_UPTODATE, &bb.flags)) if (!test_bit(BIO_UPTODATE, &bb.flags))
ret = -ENOTSUPP; ret = -ENOTSUPP;
...@@ -262,7 +262,7 @@ int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, ...@@ -262,7 +262,7 @@ int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
/* Wait for bios in-flight */ /* Wait for bios in-flight */
if (!atomic_dec_and_test(&bb.done)) if (!atomic_dec_and_test(&bb.done))
wait_for_completion(&wait); wait_for_completion_io(&wait);
if (!test_bit(BIO_UPTODATE, &bb.flags)) if (!test_bit(BIO_UPTODATE, &bb.flags))
/* One of bios in the batch was completed with error.*/ /* One of bios in the batch was completed with error.*/
......
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