@@ -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, §or, &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, §or, &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);
@@ -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,
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(-)