diff mbox series

[10/10] block: remove __blkdev_issue_discard

Message ID 20240307151157.466013-11-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/10] block: remove the discard_granularity check in __blkdev_issue_discard | expand

Commit Message

Christoph Hellwig March 7, 2024, 3:11 p.m. UTC
Fold what is left of __blkdev_issue_discard into blkdev_issue_discard and
simplify the error handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-lib.c        | 29 +++++++++--------------------
 include/linux/blkdev.h |  2 --
 2 files changed, 9 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 4f2d52210b129c..39e6e21eb2982d 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -78,23 +78,6 @@  bool blk_next_discard_bio(struct block_device *bdev, struct bio **biop,
 }
 EXPORT_SYMBOL_GPL(blk_next_discard_bio);
 
-int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
-		sector_t nr_sects, gfp_t gfp_mask, struct bio **biop)
-{
-	struct bio *bio = *biop;
-
-	while (blk_next_discard_bio(bdev, &bio, &sector, &nr_sects, gfp_mask)) {
-		if (fatal_signal_pending(current)) {
-			await_bio_chain(bio);
-			return -EINTR;
-		}
-	}
-
-	*biop = bio;
-	return 0;
-}
-EXPORT_SYMBOL(__blkdev_issue_discard);
-
 /**
  * blkdev_issue_discard - queue a discard
  * @bdev:	blockdev to issue discard for
@@ -113,16 +96,22 @@  int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 	int ret;
 
 	blk_start_plug(&plug);
-	ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, &bio);
-	if (!ret && bio) {
+	while (blk_next_discard_bio(bdev, &bio, &sector, &nr_sects, gfp_mask))
+		if (fatal_signal_pending(current))
+			goto fatal_signal;
+	if (bio) {
 		ret = submit_bio_wait(bio);
 		if (ret == -EOPNOTSUPP)
 			ret = 0;
 		bio_put(bio);
 	}
 	blk_finish_plug(&plug);
-
 	return ret;
+
+fatal_signal:
+	blk_finish_plug(&plug);
+	await_bio_chain(bio);
+	return -EINTR;
 }
 EXPORT_SYMBOL(blkdev_issue_discard);
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b87cd889008291..a1e638fb90fa77 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1057,8 +1057,6 @@  extern void blk_io_schedule(void);
 
 int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		sector_t nr_sects, gfp_t gfp_mask);
-int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
-		sector_t nr_sects, gfp_t gfp_mask, struct bio **biop);
 bool blk_next_discard_bio(struct block_device *bdev, struct bio **biop,
 		sector_t *sector, sector_t *nr_sects, gfp_t gfp_mask);
 int blkdev_issue_secure_erase(struct block_device *bdev, sector_t sector,