From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>,
Chandan Babu R <chandanbabu@kernel.org>,
Keith Busch <kbusch@kernel.org>
Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-xfs@vger.kernel.org
Subject: [PATCH 10/10] block: remove __blkdev_issue_discard
Date: Thu, 7 Mar 2024 08:11:57 -0700 [thread overview]
Message-ID: <20240307151157.466013-11-hch@lst.de> (raw)
In-Reply-To: <20240307151157.466013-1-hch@lst.de>
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 --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, §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);
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,
--
2.39.2
next prev parent reply other threads:[~2024-03-07 15:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-07 15:11 RFC: untangle and fix __blkdev_issue_discard Christoph Hellwig
2024-03-07 15:11 ` [PATCH 01/10] block: remove the discard_granularity check in __blkdev_issue_discard Christoph Hellwig
2024-03-07 15:11 ` [PATCH 02/10] block: move discard checks into the ioctl handler Christoph Hellwig
2024-03-07 21:33 ` Dave Chinner
2024-03-08 15:22 ` Christoph Hellwig
2024-03-08 21:16 ` Dave Chinner
2024-03-07 15:11 ` [PATCH 03/10] block: add a blk_next_discard_bio helper Christoph Hellwig
2024-03-07 15:11 ` [PATCH 04/10] xfs: switch to using blk_next_discard_bio directly Christoph Hellwig
2024-03-07 15:11 ` [PATCH 05/10] f2fs: " Christoph Hellwig
2024-03-07 15:11 ` [PATCH 06/10] ext4: " Christoph Hellwig
2024-03-07 16:13 ` Keith Busch
2024-03-08 15:21 ` Christoph Hellwig
2024-03-07 15:11 ` [PATCH 07/10] nvmet: " Christoph Hellwig
2024-03-07 15:11 ` [PATCH 08/10] md: " Christoph Hellwig
2024-03-07 15:11 ` [PATCH 09/10] dm-thin: " Christoph Hellwig
2024-03-07 15:11 ` Christoph Hellwig [this message]
2024-03-07 21:05 ` RFC: untangle and fix __blkdev_issue_discard Keith Busch
2024-03-08 15:21 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240307151157.466013-11-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=chandanbabu@kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox