Cmt: [SRU][K:master-next][PATCH 1/1] block: handle bio_split_to_limits() NULL return

Roxana Nicolescu roxana.nicolescu at canonical.com
Wed May 31 10:04:09 UTC 2023


On 30/05/2023 19:25, Alexander Mikhalitsyn wrote:
> From: Jens Axboe <axboe at kernel.dk>
>
> BugLink: https://bugs.launchpad.net/bugs/2020901
>
> commit 613b14884b8595e20b9fac4126bf627313827fbe upstream.
>
> This can't happen right now, but in preparation for allowing
> bio_split_to_limits() returning NULL if it ended the bio, check for it
> in all the callers.
>
> Signed-off-by: Jens Axboe <axboe at kernel.dk>
> Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> (backported from commit 613b14884b8595e20b9fac4126bf627313827fbe)

This commit message is actually 7ec9a45fc4ee7fc1054c2cabf8b09a6bc708472e 
from the stable tree. I see it has the sob of Greg. The one in mainline 
does not have it.
But the commit in the stable tree does not contain drivers/md/dm.c 
changes, so I am not sure which commit you actually applied here.

And this is not a clean cherry-pick, hence it needs some explanation on 
how you solved it.

Format is:

[axboe: <Your explanation>]
Something like "Context adjustment due to missing commits ..."

> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn at canonical.com>
> ---
>   block/blk-merge.c             | 4 +++-
>   block/blk-mq.c                | 3 +++
>   drivers/block/drbd/drbd_req.c | 2 ++
>   drivers/block/pktcdvd.c       | 2 ++
>   drivers/block/ps3vram.c       | 2 ++
>   drivers/md/dm.c               | 2 ++
>   drivers/md/md.c               | 2 ++
>   drivers/nvme/host/multipath.c | 2 ++
>   drivers/s390/block/dcssblk.c  | 2 ++
>   9 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-merge.c b/block/blk-merge.c
> index 88e39b955bd6..1af8043900f4 100644
> --- a/block/blk-merge.c
> +++ b/block/blk-merge.c
> @@ -348,11 +348,13 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,
>   		break;
>   	default:
>   		split = blk_bio_segment_split(q, *bio, &q->bio_split, nr_segs);
> +		if (IS_ERR(split))
> +			*bio = split = NULL;
>   		break;
>   	}
>   
>   	if (split) {
> -		/* there isn't chance to merge the splitted bio */
> +		/* there isn't chance to merge the split bio */
>   		split->bi_opf |= REQ_NOMERGE;
>   
>   		blkcg_bio_issue_init(split);
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 7c7e632871e7..8b22429cf94e 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2818,6 +2818,9 @@ void blk_mq_submit_bio(struct bio *bio)
>   	if (blk_may_split(q, bio))
>   		__blk_queue_split(q, &bio, &nr_segs);
>   
> +	if (!bio)
> +		return;
> +
>   	if (!bio_integrity_prep(bio))
>   		return;
>   
> diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
> index e60d3c6314c6..f323a4714f6a 100644
> --- a/drivers/block/drbd/drbd_req.c
> +++ b/drivers/block/drbd/drbd_req.c
> @@ -1609,6 +1609,8 @@ void drbd_submit_bio(struct bio *bio)
>   	struct drbd_device *device = bio->bi_bdev->bd_disk->private_data;
>   
>   	blk_queue_split(&bio);
> +	if (!bio)
> +		return;
>   
>   	/*
>   	 * what we "blindly" assume:
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index 789093375344..1988bb05c0c7 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -2400,6 +2400,8 @@ static void pkt_submit_bio(struct bio *bio)
>   	struct bio *split;
>   
>   	blk_queue_split(&bio);
> +	if (!bio)
> +		return;
>   
>   	pkt_dbg(2, pd, "start = %6llx stop = %6llx\n",
>   		(unsigned long long)bio->bi_iter.bi_sector,
> diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
> index 4f90819e245e..2a431178dc7e 100644
> --- a/drivers/block/ps3vram.c
> +++ b/drivers/block/ps3vram.c
> @@ -587,6 +587,8 @@ static void ps3vram_submit_bio(struct bio *bio)
>   	dev_dbg(&dev->core, "%s\n", __func__);
>   
>   	blk_queue_split(&bio);
> +	if (!bio)
> +		return;
>   
>   	spin_lock_irq(&priv->lock);
>   	busy = !bio_list_empty(&priv->list);
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 5acee96b5a7b..bf904c153d41 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1674,6 +1674,8 @@ static void dm_split_and_process_bio(struct mapped_device *md,
>   		 * otherwise associated queue_limits won't be imposed.
>   		 */
>   		blk_queue_split(&bio);
> +		if (!bio)
> +			return;
>   	}
>   
>   	init_clone_info(&ci, md, map, bio, is_abnormal);
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 946434ced070..772a89843226 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -465,6 +465,8 @@ static void md_submit_bio(struct bio *bio)
>   	}
>   
>   	blk_queue_split(&bio);
> +	if (!bio)
> +		return;
>   
>   	if (mddev->ro == 1 && unlikely(rw == WRITE)) {
>   		if (bio_sectors(bio) != 0)
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index d62c4a0f89ab..571c4791faa8 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -351,6 +351,8 @@ static void nvme_ns_head_submit_bio(struct bio *bio)
>   	 * pool from the original queue to allocate the bvecs from.
>   	 */
>   	blk_queue_split(&bio);
> +	if (!bio)
> +		return;
>   
>   	srcu_idx = srcu_read_lock(&head->srcu);
>   	ns = nvme_find_path(head);
> diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
> index f4401b2d30e0..18506cc222ba 100644
> --- a/drivers/s390/block/dcssblk.c
> +++ b/drivers/s390/block/dcssblk.c
> @@ -865,6 +865,8 @@ dcssblk_submit_bio(struct bio *bio)
>   	unsigned long bytes_done;
>   
>   	blk_queue_split(&bio);
> +	if (!bio)
> +		return;
>   
>   	bytes_done = 0;
>   	dev_info = bio->bi_bdev->bd_disk->private_data;
Hey,

I have some comments inline.

Thanks,
Roxana



More information about the kernel-team mailing list