Re: [PATCH v5 25/29] md/raid10: split reshape bios before bitmap accounting

[email protected] Sun, 02 Aug 2026 20:46:43 +0000
Newsgroups org.kernel.vger.linux-raid
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:
- [High] Double-splitting a bio using the same mempool-backed bioset causes=
 a deadlock under concurrent load.
--

--- Patch [25]: [PATCH v5 25/29] md/raid10: split reshape bios before bitma=
p accounting ---
commit 6f3a3e2c85f7d5d7d630d6c3cb813006807edbdc
Author: Yu Kuai <[email protected]>

md/raid10: split reshape bios before bitmap accounting

Use the shared mddev_bio_split_at_reshape_offset() helper so RAID10
submits only one-side bios to llbitmap during reshape.

> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1873,6 +1874,15 @@ static bool raid10_make_request(struct mddev *mdde=
v, struct bio *bio)
>  		sectors =3D chunk_sects -
>  			(bio->bi_iter.bi_sector &
>  			 (chunk_sects - 1));
> +
> +	bio =3D mddev_bio_split_at_reshape_offset(mddev, bio, &sectors,
> +						&conf->bio_split);

[Severity: High]
Does this introduce a mempool deadlock if we need to split the bio again la=
ter?

If this initial split succeeds, the thread holds a bio from the conf->bio_s=
plit
mempool. Later, the thread proceeds to __make_request() and then to
raid10_write_request().

If the target disks have bad blocks, max_sectors is further reduced, causin=
g a
second split attempt from the exact same mempool:

raid10_write_request() {
    ...
    if (max_sectors < r10_bio->sectors) {
        ...
        bio =3D bio_submit_split_bioset(bio, r10_bio->sectors,
                                      &conf->bio_split);
    ...
}

Since the conf->bio_split bioset is initialized with BIO_POOL_SIZE (2), if =
two
concurrent I/O requests cross chunk boundaries and hit bad blocks
simultaneously, could both threads allocate one bio each, and then both
permanently block in mempool_alloc() waiting for a second bio?

> +	if (!bio) {
> +		if (rw =3D=3D WRITE)
> +			md_write_end(mddev);
> +		return true;
> +	}
> +
>  	if (!__make_request(mddev, bio, sectors))
>  		md_write_end(mddev);

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260802195038.1642=
[email protected]?part=3D25