[PATCH RFC v3 03/15] md: fix mssing blktrace bio split events

Yu Kuai posted 15 patches 1 month ago
[PATCH RFC v3 03/15] md: fix mssing blktrace bio split events
Posted by Yu Kuai 1 month ago
From: Yu Kuai <yukuai3@huawei.com>

If bio is split by internal chunksize of badblocks, the corresponding
trace_block_split() is missing, causing blktrace can't catch the split
events and make it hader to analyze IO behavior.

Fixes: 4b1faf931650 ("block: Kill bio_pair_split()")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/md-linear.c | 1 +
 drivers/md/raid0.c     | 4 ++++
 drivers/md/raid1.c     | 4 ++++
 drivers/md/raid10.c    | 8 ++++++++
 drivers/md/raid5.c     | 2 ++
 5 files changed, 19 insertions(+)

diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index 5d9b08115375..59d7963c7843 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -266,6 +266,7 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 		}
 
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		submit_bio_noacct(bio);
 		bio = split;
 	}
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index f1d8811a542a..1ba7d0c090f7 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -472,7 +472,9 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio)
 			bio_endio(bio);
 			return;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		submit_bio_noacct(bio);
 		bio = split;
 		end = zone->zone_end;
@@ -620,7 +622,9 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)
 			bio_endio(bio);
 			return true;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		raid0_map_submit_bio(mddev, bio);
 		bio = split;
 	}
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 408c26398321..29edb7b548f3 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1383,7 +1383,9 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
 			error = PTR_ERR(split);
 			goto err_handle;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		submit_bio_noacct(bio);
 		bio = split;
 		r1_bio->master_bio = bio;
@@ -1591,7 +1593,9 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 			error = PTR_ERR(split);
 			goto err_handle;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		submit_bio_noacct(bio);
 		bio = split;
 		r1_bio->master_bio = bio;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index b60c30bfb6c7..859c40a5ecf4 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1209,7 +1209,9 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
 			error = PTR_ERR(split);
 			goto err_handle;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		allow_barrier(conf);
 		submit_bio_noacct(bio);
 		wait_barrier(conf, false);
@@ -1495,7 +1497,9 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
 			error = PTR_ERR(split);
 			goto err_handle;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		allow_barrier(conf);
 		submit_bio_noacct(bio);
 		wait_barrier(conf, false);
@@ -1679,7 +1683,9 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
 			bio_endio(bio);
 			return 0;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		allow_barrier(conf);
 		/* Resend the fist split part */
 		submit_bio_noacct(split);
@@ -1694,7 +1700,9 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
 			bio_endio(bio);
 			return 0;
 		}
+
 		bio_chain(split, bio);
+		trace_block_split(split, bio->bi_iter.bi_sector);
 		allow_barrier(conf);
 		/* Resend the second split part */
 		submit_bio_noacct(bio);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 023649fe2476..0fb838879844 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5475,8 +5475,10 @@ static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio)
 
 	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);
+		trace_block_split(split, raid_bio->bi_iter.bi_sector);
 		submit_bio_noacct(raid_bio);
 		raid_bio = split;
 	}
-- 
2.39.2
Re: [PATCH RFC v3 03/15] md: fix mssing blktrace bio split events
Posted by Christoph Hellwig 4 weeks, 1 day ago
s/mssing/missing/ in the subject.

Having all these open coded trace_block_split is a bit annoying, but
we don't have to fix it in this series.
Re: [PATCH RFC v3 03/15] md: fix mssing blktrace bio split events
Posted by Yu Kuai 4 weeks, 1 day ago
Hi,

在 2025/09/03 21:25, Christoph Hellwig 写道:
> s/mssing/missing/ in the subject.
> 
> Having all these open coded trace_block_split is a bit annoying, but
> we don't have to fix it in this series.
> 
> .
> 

This patch alone is for stable backport without following patches to
convert to new helper. I'll keep this patch if you're not against this,
or I'll just remove this patch and convert to new helper directly.

Thanks,
Kuai

Re: [PATCH RFC v3 03/15] md: fix mssing blktrace bio split events
Posted by Damien Le Moal 1 month ago
On 9/1/25 12:32 PM, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> If bio is split by internal chunksize of badblocks, the corresponding

badblocks ? Unclear.

> trace_block_split() is missing, causing blktrace can't catch the split
> events and make it hader to analyze IO behavior.

maybe:

trace_block_split() is missing, resulting in blktrace inability to catch BIO
split events and making it harder to analyze the BIO sequence.

would be better.

> 
> Fixes: 4b1faf931650 ("block: Kill bio_pair_split()")

Missing Cc: stable@vger.kernel.org

> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

With that,

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

(maybe drop the RFC on this patch series ? Sending a review tag for RFC patches
is odd...)

-- 
Damien Le Moal
Western Digital Research
Re: [PATCH RFC v3 03/15] md: fix mssing blktrace bio split events
Posted by Yu Kuai 1 month ago
Hi,

在 2025/09/01 14:30, Damien Le Moal 写道:
> On 9/1/25 12:32 PM, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> If bio is split by internal chunksize of badblocks, the corresponding
> 
> badblocks ? Unclear.

This is due to raid1/10/5 internal processing, if read/write range
contain badblocks that are recorded in rdev, this bio will be split to
bypass the badblocks range, an example from raid1 is choose_bb_rdev()
will update max_sectors from read_balance(), and caller will split bio
by max_sectors.
> 
>> trace_block_split() is missing, causing blktrace can't catch the split
>> events and make it hader to analyze IO behavior.
> 
> maybe:
> 
> trace_block_split() is missing, resulting in blktrace inability to catch BIO
> split events and making it harder to analyze the BIO sequence.
> 
> would be better.
> 
OK,

>>
>> Fixes: 4b1faf931650 ("block: Kill bio_pair_split()")
> 
> Missing Cc: stable@vger.kernel.org
> 
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> 
> With that,
> 
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> 
> (maybe drop the RFC on this patch series ? Sending a review tag for RFC patches
> is odd...)

Yes, I'll send the next version without RFC now. :)

Thanks,
Kuai

>