diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2010-04-28 09:55:07 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2010-04-28 13:47:36 -0400 |
commit | f17e232e9237c231daf9f0f4b177c61218bcb2e4 (patch) | |
tree | 6fae1e48cd6edde825229bfdf9a31ffbce9626e9 /block | |
parent | fbd9b09a177a481eda256447c881f014f29034fe (diff) |
blkdev: allow async blkdev_issue_flush requests
In some places caller don't want to wait a request to complete.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-barrier.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/block/blk-barrier.c b/block/blk-barrier.c index cf14311b98fc..f11eec9669e4 100644 --- a/block/blk-barrier.c +++ b/block/blk-barrier.c | |||
@@ -286,8 +286,9 @@ static void bio_end_empty_barrier(struct bio *bio, int err) | |||
286 | set_bit(BIO_EOPNOTSUPP, &bio->bi_flags); | 286 | set_bit(BIO_EOPNOTSUPP, &bio->bi_flags); |
287 | clear_bit(BIO_UPTODATE, &bio->bi_flags); | 287 | clear_bit(BIO_UPTODATE, &bio->bi_flags); |
288 | } | 288 | } |
289 | 289 | if (bio->bi_private) | |
290 | complete(bio->bi_private); | 290 | complete(bio->bi_private); |
291 | bio_put(bio); | ||
291 | } | 292 | } |
292 | 293 | ||
293 | /** | 294 | /** |
@@ -300,7 +301,8 @@ static void bio_end_empty_barrier(struct bio *bio, int err) | |||
300 | * Description: | 301 | * Description: |
301 | * Issue a flush for the block device in question. Caller can supply | 302 | * Issue a flush for the block device in question. Caller can supply |
302 | * room for storing the error offset in case of a flush error, if they | 303 | * room for storing the error offset in case of a flush error, if they |
303 | * wish to. | 304 | * wish to. If WAIT flag is not passed then caller may check only what |
305 | * request was pushed in some internal queue for later handling. | ||
304 | */ | 306 | */ |
305 | int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, | 307 | int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, |
306 | sector_t *error_sector, unsigned long flags) | 308 | sector_t *error_sector, unsigned long flags) |
@@ -319,19 +321,22 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, | |||
319 | 321 | ||
320 | bio = bio_alloc(gfp_mask, 0); | 322 | bio = bio_alloc(gfp_mask, 0); |
321 | bio->bi_end_io = bio_end_empty_barrier; | 323 | bio->bi_end_io = bio_end_empty_barrier; |
322 | bio->bi_private = &wait; | ||
323 | bio->bi_bdev = bdev; | 324 | bio->bi_bdev = bdev; |
324 | submit_bio(WRITE_BARRIER, bio); | 325 | if (test_bit(BLKDEV_WAIT, &flags)) |
325 | 326 | bio->bi_private = &wait; | |
326 | wait_for_completion(&wait); | ||
327 | 327 | ||
328 | /* | 328 | bio_get(bio); |
329 | * The driver must store the error location in ->bi_sector, if | 329 | submit_bio(WRITE_BARRIER, bio); |
330 | * it supports it. For non-stacked drivers, this should be copied | 330 | if (test_bit(BLKDEV_WAIT, &flags)) { |
331 | * from blk_rq_pos(rq). | 331 | wait_for_completion(&wait); |
332 | */ | 332 | /* |
333 | if (error_sector) | 333 | * The driver must store the error location in ->bi_sector, if |
334 | *error_sector = bio->bi_sector; | 334 | * it supports it. For non-stacked drivers, this should be |
335 | * copied from blk_rq_pos(rq). | ||
336 | */ | ||
337 | if (error_sector) | ||
338 | *error_sector = bio->bi_sector; | ||
339 | } | ||
335 | 340 | ||
336 | if (bio_flagged(bio, BIO_EOPNOTSUPP)) | 341 | if (bio_flagged(bio, BIO_EOPNOTSUPP)) |
337 | ret = -EOPNOTSUPP; | 342 | ret = -EOPNOTSUPP; |