mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
block: add a bio_submit_or_kill helper
Factor the common logic for the ioctl helpers to either submit a bio or end if the process is being killed. As this is now the only user of bio_await_chain, open code that. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://patch.msgid.link/20260407140538.633364-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
6fa747550e
commit
92c3737a24
@@ -153,13 +153,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
|
||||
nr_sects = len >> SECTOR_SHIFT;
|
||||
|
||||
blk_start_plug(&plug);
|
||||
while (1) {
|
||||
if (fatal_signal_pending(current)) {
|
||||
if (prev)
|
||||
bio_await_chain(prev);
|
||||
err = -EINTR;
|
||||
goto out_unplug;
|
||||
}
|
||||
while (!fatal_signal_pending(current)) {
|
||||
bio = blk_alloc_discard_bio(bdev, §or, &nr_sects,
|
||||
GFP_KERNEL);
|
||||
if (!bio)
|
||||
@@ -167,12 +161,11 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
|
||||
prev = bio_chain_and_submit(prev, bio);
|
||||
}
|
||||
if (prev) {
|
||||
err = submit_bio_wait(prev);
|
||||
err = bio_submit_or_kill(prev, BLKDEV_ZERO_KILLABLE);
|
||||
if (err == -EOPNOTSUPP)
|
||||
err = 0;
|
||||
bio_put(prev);
|
||||
}
|
||||
out_unplug:
|
||||
blk_finish_plug(&plug);
|
||||
fail:
|
||||
filemap_invalidate_unlock(bdev->bd_mapping);
|
||||
|
||||
Reference in New Issue
Block a user