[PATCH 2/4] blkdev: allow async blkdev_issue_flush requests

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dmitry Monakhov
Date: Wednesday, April 28, 2010 - 6:55 am

In some places caller don't want to wait a request to complete.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 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 cf14311..f11eec9 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)
 			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);
 }
 
 /**
@@ -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)
@@ -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;
-- 
1.6.6.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/4] blkdev: blkdev_issue_fn cleanups v2, Dmitry Monakhov, (Mon Apr 12, 6:03 am)
[PATCH 3/4] blkdev: add blkdev_issue helper functions, Dmitry Monakhov, (Mon Apr 12, 6:03 am)
[PATCH 4/4] patch blk-add-zeroout-helper.patch, Dmitry Monakhov, (Mon Apr 12, 6:03 am)
Re: [PATCH 2/4] blkdev: generalize flags for blkdev_issue_ ..., Christoph Hellwig, (Tue Apr 13, 11:05 am)
Re: [PATCH 3/4] blkdev: add blkdev_issue helper functions, Christoph Hellwig, (Tue Apr 13, 11:06 am)
Re: [PATCH 4/4] patch blk-add-zeroout-helper.patch, Christoph Hellwig, (Tue Apr 13, 11:07 am)
Re: [PATCH 1/4] blkdev: pass gfp_mask and flags to blkdev_ ..., Christoph Hellwig, (Tue Apr 13, 11:08 am)
Re: [PATCH 1/4] blkdev: pass gfp_mask and flags to blkdev_ ..., Christoph Hellwig, (Tue Apr 13, 11:10 am)
Re: [PATCH 0/4] blkdev: blkdev_issue_fn cleanups v2, Christoph Hellwig, (Mon Apr 26, 8:01 am)
Re: [PATCH 0/4] blkdev: blkdev_issue_fn cleanups v2, Jens Axboe, (Mon Apr 26, 10:26 am)
Re: [PATCH 0/4] blkdev: blkdev_issue_fn cleanups v2, Dmitry Monakhov, (Mon Apr 26, 10:32 am)
Re: [PATCH 0/4] blkdev: blkdev_issue_fn cleanups v2, Jens Axboe, (Mon Apr 26, 10:47 am)
[PATCH 0/4] blkdev: blkdev_issue_fn cleanups v3, Dmitry Monakhov, (Wed Apr 28, 6:55 am)
[PATCH 2/4] blkdev: allow async blkdev_issue_flush requests, Dmitry Monakhov, (Wed Apr 28, 6:55 am)
[PATCH 4/4] blkdev: add blkdev_issue_zeroout helper function, Dmitry Monakhov, (Wed Apr 28, 6:55 am)
Re: [PATCH 0/4] blkdev: blkdev_issue_fn cleanups v3, Jens Axboe, (Wed Apr 28, 11:17 am)