[PATCH RFC v3 11/15] md/md-linear: convert to use bio_submit_split_bioset()

Yu Kuai posted 15 patches 1 month ago
[PATCH RFC v3 11/15] md/md-linear: convert to use bio_submit_split_bioset()
Posted by Yu Kuai 1 month ago
From: Yu Kuai <yukuai3@huawei.com>

Unify bio split code, prepare to fix disordered split IO.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/md-linear.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index 59d7963c7843..701e3aac0a21 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -256,19 +256,11 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 
 	if (unlikely(bio_end_sector(bio) > end_sector)) {
 		/* This bio crosses a device boundary, so we have to split it */
-		struct bio *split = bio_split(bio, end_sector - bio_sector,
+		bio = bio_submit_split_bioset(bio, end_sector - bio_sector,
 					      GFP_NOIO, &mddev->bio_set);
-
-		if (IS_ERR(split)) {
-			bio->bi_status = errno_to_blk_status(PTR_ERR(split));
-			bio_endio(bio);
+		if (!bio) {
 			return true;
 		}
-
-		bio_chain(split, bio);
-		trace_block_split(split, bio->bi_iter.bi_sector);
-		submit_bio_noacct(bio);
-		bio = split;
 	}
 
 	md_account_bio(mddev, &bio);
-- 
2.39.2
Re: [PATCH RFC v3 11/15] md/md-linear: convert to use bio_submit_split_bioset()
Posted by Bart Van Assche 4 weeks, 1 day ago
On 8/31/25 8:32 PM, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Unify bio split code, prepare to fix disordered split IO.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/md/md-linear.c | 12 ++----------
>   1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
> index 59d7963c7843..701e3aac0a21 100644
> --- a/drivers/md/md-linear.c
> +++ b/drivers/md/md-linear.c
> @@ -256,19 +256,11 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
>   
>   	if (unlikely(bio_end_sector(bio) > end_sector)) {
>   		/* This bio crosses a device boundary, so we have to split it */
> -		struct bio *split = bio_split(bio, end_sector - bio_sector,
> +		bio = bio_submit_split_bioset(bio, end_sector - bio_sector,
>   					      GFP_NOIO, &mddev->bio_set);

This patch cannot have been tested because it triggers the following
build error:

drivers/md/md-linear.c: In function ‘linear_make_request’:
./include/linux/gfp_types.h:381:25: error: passing argument 3 of 
‘bio_submit_split_bioset’ makes pointer from integer without a cast 
[-Wint-conversion]
   381 | #define GFP_NOIO        (__GFP_RECLAIM)
       |                         ^~~~~~~~~~~~~~~
       |                         |
       |                         unsigned int

Bart.
Re: [PATCH RFC v3 11/15] md/md-linear: convert to use bio_submit_split_bioset()
Posted by Yu Kuai 4 weeks, 1 day ago
Hi,

在 2025/09/04 1:43, Bart Van Assche 写道:
> On 8/31/25 8:32 PM, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Unify bio split code, prepare to fix disordered split IO.
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   drivers/md/md-linear.c | 12 ++----------
>>   1 file changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
>> index 59d7963c7843..701e3aac0a21 100644
>> --- a/drivers/md/md-linear.c
>> +++ b/drivers/md/md-linear.c
>> @@ -256,19 +256,11 @@ static bool linear_make_request(struct mddev 
>> *mddev, struct bio *bio)
>>       if (unlikely(bio_end_sector(bio) > end_sector)) {
>>           /* This bio crosses a device boundary, so we have to split 
>> it */
>> -        struct bio *split = bio_split(bio, end_sector - bio_sector,
>> +        bio = bio_submit_split_bioset(bio, end_sector - bio_sector,
>>                             GFP_NOIO, &mddev->bio_set);
> 
> This patch cannot have been tested because it triggers the following
> build error:

Yes, sorry about that. As I said I only tested with raid5 with this
RFC version. I will at least run all the test cases in the next formal
version.

Thanks,
Kuai

> 
> drivers/md/md-linear.c: In function ‘linear_make_request’:
> ./include/linux/gfp_types.h:381:25: error: passing argument 3 of 
> ‘bio_submit_split_bioset’ makes pointer from integer without a cast 
> [-Wint-conversion]
>    381 | #define GFP_NOIO        (__GFP_RECLAIM)
>        |                         ^~~~~~~~~~~~~~~
>        |                         |
>        |                         unsigned int
> 
> Bart.
> .
>