mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 12:16:41 +00:00
block: Handle bio_split() errors in bio_submit_split()
bio_split() may error, so check this. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20241111112150.3756529-4-john.g.garry@oracle.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
27b26f09a7
commit
6eb0968588
@ -107,17 +107,18 @@ static unsigned int bio_allowed_max_sectors(const struct queue_limits *lim)
|
|||||||
|
|
||||||
static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
|
static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
|
||||||
{
|
{
|
||||||
if (unlikely(split_sectors < 0)) {
|
if (unlikely(split_sectors < 0))
|
||||||
bio->bi_status = errno_to_blk_status(split_sectors);
|
goto error;
|
||||||
bio_endio(bio);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (split_sectors) {
|
if (split_sectors) {
|
||||||
struct bio *split;
|
struct bio *split;
|
||||||
|
|
||||||
split = bio_split(bio, split_sectors, GFP_NOIO,
|
split = bio_split(bio, split_sectors, GFP_NOIO,
|
||||||
&bio->bi_bdev->bd_disk->bio_split);
|
&bio->bi_bdev->bd_disk->bio_split);
|
||||||
|
if (IS_ERR(split)) {
|
||||||
|
split_sectors = PTR_ERR(split);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
split->bi_opf |= REQ_NOMERGE;
|
split->bi_opf |= REQ_NOMERGE;
|
||||||
blkcg_bio_issue_init(split);
|
blkcg_bio_issue_init(split);
|
||||||
bio_chain(split, bio);
|
bio_chain(split, bio);
|
||||||
@ -128,6 +129,10 @@ static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bio;
|
return bio;
|
||||||
|
error:
|
||||||
|
bio->bi_status = errno_to_blk_status(split_sectors);
|
||||||
|
bio_endio(bio);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bio *bio_split_discard(struct bio *bio, const struct queue_limits *lim,
|
struct bio *bio_split_discard(struct bio *bio, const struct queue_limits *lim,
|
||||||
|
Loading…
Reference in New Issue
Block a user