[PATCH RFC 5/7] md/raid5: convert to use bio_submit_split()

Yu Kuai posted 7 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH RFC 5/7] md/raid5: convert to use bio_submit_split()
Posted by Yu Kuai 1 month, 1 week ago
From: Yu Kuai <yukuai3@huawei.com>

On the one hand unify bio split code, prepare to fix disordered split
IO; On the other hand fix missing blkcg_bio_issue_init() and
trace_block_split() for split IO.

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

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 023649fe2476..9ae749e66e9d 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5468,17 +5468,19 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
 
 static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio)
 {
-	struct bio *split;
 	sector_t sector = raid_bio->bi_iter.bi_sector;
 	unsigned chunk_sects = mddev->chunk_sectors;
 	unsigned sectors = chunk_sects - (sector & (chunk_sects-1));
 
 	if (sectors < bio_sectors(raid_bio)) {
 		struct r5conf *conf = mddev->private;
-		split = bio_split(raid_bio, sectors, GFP_NOIO, &conf->bio_split);
-		bio_chain(split, raid_bio);
-		submit_bio_noacct(raid_bio);
-		raid_bio = split;
+
+		raid_bio = bio_submit_split(raid_bio, sectors,
+					    &conf->bio_split);
+		if (!raid_bio)
+			return NULL;
+
+		raid_bio->bi_opf &= ~REQ_NOMERGE;
 	}
 
 	if (!raid5_read_one_chunk(mddev, raid_bio))
-- 
2.39.2
Re: [PATCH RFC 5/7] md/raid5: convert to use bio_submit_split()
Posted by Christoph Hellwig 1 month, 1 week ago
On Mon, Aug 25, 2025 at 05:36:58PM +0800, Yu Kuai wrote:
> +		raid_bio = bio_submit_split(raid_bio, sectors,
> +					    &conf->bio_split);
> +		if (!raid_bio)
> +			return NULL;
> +
> +		raid_bio->bi_opf &= ~REQ_NOMERGE;

It almost feels as if md wants a little helper that wraps
bio_submit_split and also clears REQ_NOMERGE?
Re: [PATCH RFC 5/7] md/raid5: convert to use bio_submit_split()
Posted by Yu Kuai 1 month, 1 week ago
Hi,

在 2025/08/25 19:00, Christoph Hellwig 写道:
> On Mon, Aug 25, 2025 at 05:36:58PM +0800, Yu Kuai wrote:
>> +		raid_bio = bio_submit_split(raid_bio, sectors,
>> +					    &conf->bio_split);
>> +		if (!raid_bio)
>> +			return NULL;
>> +
>> +		raid_bio->bi_opf &= ~REQ_NOMERGE;
> 
> It almost feels as if md wants a little helper that wraps
> bio_submit_split and also clears REQ_NOMERGE?
> 

Yes.

And with the respect bio_submit_split() set this flag and then we clear
it, will it make more sense to set this flag after bio_submit_split()
from block layer?

Thanks,
Kuai

> .
> 

Re: [PATCH RFC 5/7] md/raid5: convert to use bio_submit_split()
Posted by Christoph Hellwig 1 month, 1 week ago
On Tue, Aug 26, 2025 at 09:15:34AM +0800, Yu Kuai wrote:
> > > +		raid_bio->bi_opf &= ~REQ_NOMERGE;
> > 
> > It almost feels as if md wants a little helper that wraps
> > bio_submit_split and also clears REQ_NOMERGE?
> > 
> 
> Yes.
> 
> And with the respect bio_submit_split() set this flag and then we clear
> it, will it make more sense to set this flag after bio_submit_split()
> from block layer?

Yes.