aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-barrier.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk-barrier.c')
-rw-r--r--block/blk-barrier.c33
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 */
305int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, 307int 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;