Skip to content

Commit

Permalink
blkdev: allow async blkdev_issue_flush requests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Monakhov authored and Jens Axboe committed Apr 28, 2010
1 parent fbd9b09 commit f17e232
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions block/blk-barrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ static void bio_end_empty_barrier(struct bio *bio, int err)
set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
clear_bit(BIO_UPTODATE, &bio->bi_flags);
}

complete(bio->bi_private);
if (bio->bi_private)
complete(bio->bi_private);
bio_put(bio);
}

/**
Expand All @@ -300,7 +301,8 @@ static void bio_end_empty_barrier(struct bio *bio, int err)
* Description:
* Issue a flush for the block device in question. Caller can supply
* room for storing the error offset in case of a flush error, if they
* wish to.
* wish to. If WAIT flag is not passed then caller may check only what
* request was pushed in some internal queue for later handling.
*/
int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
sector_t *error_sector, unsigned long flags)
Expand All @@ -319,19 +321,22 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,

bio = bio_alloc(gfp_mask, 0);
bio->bi_end_io = bio_end_empty_barrier;
bio->bi_private = &wait;
bio->bi_bdev = bdev;
submit_bio(WRITE_BARRIER, bio);

wait_for_completion(&wait);
if (test_bit(BLKDEV_WAIT, &flags))
bio->bi_private = &wait;

/*
* The driver must store the error location in ->bi_sector, if
* it supports it. For non-stacked drivers, this should be copied
* from blk_rq_pos(rq).
*/
if (error_sector)
*error_sector = bio->bi_sector;
bio_get(bio);
submit_bio(WRITE_BARRIER, bio);
if (test_bit(BLKDEV_WAIT, &flags)) {
wait_for_completion(&wait);
/*
* The driver must store the error location in ->bi_sector, if
* it supports it. For non-stacked drivers, this should be
* copied from blk_rq_pos(rq).
*/
if (error_sector)
*error_sector = bio->bi_sector;
}

if (bio_flagged(bio, BIO_EOPNOTSUPP))
ret = -EOPNOTSUPP;
Expand Down

0 comments on commit f17e232

Please sign in to comment.