[PATCH 4/5] block: move await_bio_chain to bio.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



we'll want to use it from more than blk-lib.c, so this seems like
the better place.  Also rename it so that the name starts with bio_.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 block/bio.c     | 20 ++++++++++++++++++++
 block/blk-lib.c | 28 ++++------------------------
 block/blk.h     |  1 +
 3 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 32ff538b29e564..33972deed87fb3 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1396,6 +1396,26 @@ int submit_bio_wait(struct bio *bio)
 }
 EXPORT_SYMBOL(submit_bio_wait);
 
+static void bio_wait_end_io(struct bio *bio)
+{
+	complete(bio->bi_private);
+	bio_put(bio);
+}
+
+/*
+ * bio_await_chain - ends @bio and waits for every chained bio to complete
+ */
+void bio_await_chain(struct bio *bio)
+{
+	DECLARE_COMPLETION_ONSTACK_MAP(done,
+			bio->bi_bdev->bd_disk->lockdep_map);
+
+	bio->bi_private = &done;
+	bio->bi_end_io = bio_wait_end_io;
+	bio_endio(bio);
+	blk_wait_io(&done);
+}
+
 void __bio_advance(struct bio *bio, unsigned bytes)
 {
 	if (bio_integrity(bio))
diff --git a/block/blk-lib.c b/block/blk-lib.c
index fd97f4dd34e7f4..8021bc3831d56a 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -35,26 +35,6 @@ static sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
 	return round_down(UINT_MAX, discard_granularity) >> SECTOR_SHIFT;
 }
 
-static void await_bio_endio(struct bio *bio)
-{
-	complete(bio->bi_private);
-	bio_put(bio);
-}
-
-/*
- * await_bio_chain - ends @bio and waits for every chained bio to complete
- */
-static void await_bio_chain(struct bio *bio)
-{
-	DECLARE_COMPLETION_ONSTACK_MAP(done,
-			bio->bi_bdev->bd_disk->lockdep_map);
-
-	bio->bi_private = &done;
-	bio->bi_end_io = await_bio_endio;
-	bio_endio(bio);
-	blk_wait_io(&done);
-}
-
 struct bio *blk_alloc_discard_bio(struct block_device *bdev,
 		sector_t *sector, sector_t *nr_sects, gfp_t gfp_mask)
 {
@@ -93,7 +73,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 	}
 
 	if (*biop)
-		await_bio_chain(*biop);
+		bio_await_chain(*biop);
 	return -EINTR;
 }
 EXPORT_SYMBOL(__blkdev_issue_discard);
@@ -158,7 +138,7 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
 		sector += len;
 		cond_resched();
 		if (fatal_signal_pending(current)) {
-			await_bio_chain(bio);
+			bio_await_chain(bio);
 			return -EINTR;
 		}
 	}
@@ -206,7 +186,7 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
 		}
 		cond_resched();
 		if (fatal_signal_pending(current)) {
-			await_bio_chain(bio);
+			bio_await_chain(bio);
 			return -EINTR;
 		}
 	}
@@ -352,7 +332,7 @@ int blkdev_issue_secure_erase(struct block_device *bdev, sector_t sector,
 		nr_sects -= len;
 		cond_resched();
 		if (fatal_signal_pending(current)) {
-			await_bio_chain(bio);
+			bio_await_chain(bio);
 			ret = -EINTR;
 			bio = NULL;
 			break;
diff --git a/block/blk.h b/block/blk.h
index a19b7b42e6503c..78528bfbd58c37 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -38,6 +38,7 @@ void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic);
 void blk_queue_start_drain(struct request_queue *q);
 int __bio_queue_enter(struct request_queue *q, struct bio *bio);
 void submit_bio_noacct_nocheck(struct bio *bio);
+void bio_await_chain(struct bio *bio);
 
 static inline bool blk_try_enter_queue(struct request_queue *q, bool pm)
 {
-- 
2.39.2





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux