diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2013-02-14 09:19:59 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-02-15 10:45:07 -0500 |
commit | 5577022f4ed8973762450ebe7fe7ebfd953817db (patch) | |
tree | c6c965101e32bf2b36155da0fc0ad94c696d4606 | |
parent | 686855f5d833178e518d79e7912cdb3268a9fa69 (diff) |
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: Vladimir Davydov <vdavydov@parallels.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-exec.c | 4 | ||||
-rw-r--r-- | block/blk-flush.c | 2 | ||||
-rw-r--r-- | block/blk-lib.c | 6 |
3 files changed, 6 insertions, 6 deletions
diff --git a/block/blk-exec.c b/block/blk-exec.c index 74638ec234c8..f634de772b0c 100644 --- a/block/blk-exec.c +++ b/block/blk-exec.c | |||
@@ -120,9 +120,9 @@ int blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk, | |||
120 | /* Prevent hang_check timer from firing at us during very long I/O */ | 120 | /* Prevent hang_check timer from firing at us during very long I/O */ |
121 | hang_check = sysctl_hung_task_timeout_secs; | 121 | hang_check = sysctl_hung_task_timeout_secs; |
122 | if (hang_check) | 122 | if (hang_check) |
123 | while (!wait_for_completion_timeout(&wait, hang_check * (HZ/2))); | 123 | while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2))); |
124 | else | 124 | else |
125 | wait_for_completion(&wait); | 125 | wait_for_completion_io(&wait); |
126 | 126 | ||
127 | if (rq->errors) | 127 | if (rq->errors) |
128 | err = -EIO; | 128 | err = -EIO; |
diff --git a/block/blk-flush.c b/block/blk-flush.c index 720ad607ff91..db8f1b507857 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c | |||
@@ -436,7 +436,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, | |||
436 | 436 | ||
437 | bio_get(bio); | 437 | bio_get(bio); |
438 | submit_bio(WRITE_FLUSH, bio); | 438 | submit_bio(WRITE_FLUSH, bio); |
439 | wait_for_completion(&wait); | 439 | wait_for_completion_io(&wait); |
440 | 440 | ||
441 | /* | 441 | /* |
442 | * The driver must store the error location in ->bi_sector, if | 442 | * The driver must store the error location in ->bi_sector, if |
diff --git a/block/blk-lib.c b/block/blk-lib.c index b3a1f2b70b31..d6f50d572565 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c | |||
@@ -126,7 +126,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
126 | 126 | ||
127 | /* Wait for bios in-flight */ | 127 | /* Wait for bios in-flight */ |
128 | if (!atomic_dec_and_test(&bb.done)) | 128 | if (!atomic_dec_and_test(&bb.done)) |
129 | wait_for_completion(&wait); | 129 | wait_for_completion_io(&wait); |
130 | 130 | ||
131 | if (!test_bit(BIO_UPTODATE, &bb.flags)) | 131 | if (!test_bit(BIO_UPTODATE, &bb.flags)) |
132 | ret = -EIO; | 132 | ret = -EIO; |
@@ -200,7 +200,7 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, | |||
200 | 200 | ||
201 | /* Wait for bios in-flight */ | 201 | /* Wait for bios in-flight */ |
202 | if (!atomic_dec_and_test(&bb.done)) | 202 | if (!atomic_dec_and_test(&bb.done)) |
203 | wait_for_completion(&wait); | 203 | wait_for_completion_io(&wait); |
204 | 204 | ||
205 | if (!test_bit(BIO_UPTODATE, &bb.flags)) | 205 | if (!test_bit(BIO_UPTODATE, &bb.flags)) |
206 | ret = -ENOTSUPP; | 206 | ret = -ENOTSUPP; |
@@ -262,7 +262,7 @@ int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | |||
262 | 262 | ||
263 | /* Wait for bios in-flight */ | 263 | /* Wait for bios in-flight */ |
264 | if (!atomic_dec_and_test(&bb.done)) | 264 | if (!atomic_dec_and_test(&bb.done)) |
265 | wait_for_completion(&wait); | 265 | wait_for_completion_io(&wait); |
266 | 266 | ||
267 | if (!test_bit(BIO_UPTODATE, &bb.flags)) | 267 | if (!test_bit(BIO_UPTODATE, &bb.flags)) |
268 | /* One of bios in the batch was completed with error.*/ | 268 | /* One of bios in the batch was completed with error.*/ |