Skip to contentSkip to conversation

md: raid0: account for split bio in iostat accounting

PATCH RESEND Superseded David Jeffery 2 participants 2 messages Aug 14, 2023 – Aug 15, 2023 MD RAID

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 md: raid0: account for split bio in iostat accounting

When a bio is split by md raid0, the newly created bio will not be tracked by md for I/O accounting. Only the portion of I/O still assigned to the original bio which was reduced by the split will be accounted for. This results in md iostat data sometimes showing I/O values far below the actual amount of data being sent through md.

md_account_bio() needs to be called for all bio generated by the bio split.

Fixes 10764815ff47 ("md: add io accounting for raid0 and raid5")

---

No change to the patch itself. Added Fixes and Reviewed-by lines.

A simple example of the issue was generated using a raid0 device on partitions to the same device. Since all raid0 I/O then goes to one device, it makes it easy to see a gap between the md device and its sd storage. Reading an lvm device on top of the md device, the iostat output (some 0 columns and extra devices removed to make the data more compact) was:

Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read

md2               0.00         0.00         0.00         0.00          0
sde               0.00         0.00         0.00         0.00          0
md2            1364.00    411496.00         0.00         0.00     411496
sde            1734.00    646144.00         0.00         0.00     646144
md2            1699.00    510680.00         0.00         0.00     510680
sde            2155.00    802784.00         0.00         0.00     802784
md2             803.00    241480.00         0.00         0.00     241480
sde            1016.00    377888.00         0.00         0.00     377888
md2               0.00         0.00         0.00         0.00          0
sde               0.00         0.00         0.00         0.00          0

I/O was generated doing large direct I/O reads (12M) with dd to a linear lvm volume on top of the 4 leg raid0 device.

The md2 reads were showing as roughly 2/3 of the reads to the sde device containing all of md2's raid partitions. The sum of reads to sde was 1826816 kB, which was the expected amount as it was the amount read by dd. With the patch, the total reads from md will match the reads from sde and be consistent with the amount of I/O generated.

 drivers/md/raid0.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/raid0.c +1 -2
index d1ac73fcd852..1fd559ac8c68 100644
@@ -597,8 +597,7 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)
 		bio = split;
 	}
 
-	if (bio->bi_pool != &mddev->bio_set)
-		md_account_bio(mddev, &bio);
+	md_account_bio(mddev, &bio);
 
 	orig_sector = sector;
 	zone = find_zone(mddev->private, &sector);
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 7 lines · David Jeffery

When a bio is split by md raid0, the newly created bio will not be tracked by md for I/O accounting. Only the portion of I/O still assigned to the original bio which was reduced by the split will be accounted for. This results in md iostat data sometimes showing I/O values far below the actual amount of data being sent through md.

Quoted 7 lines

md_account_bio() needs to be called for all bio generated by the bio split.

Fixes 10764815ff47 ("md: add io accounting for raid0 and raid5")

It appears this patch conflicts with Jan's set:

https://lore.kernel.org/linux-raid/[email protected]/

Please rebase on top of md-next and resubmit the patch:

https://git.kernel.org/pub/scm/linux/kernel/git/song/md.git/log/?h=md-next

Quoted 22 lines

---

No change to the patch itself. Added Fixes and Reviewed-by lines.

A simple example of the issue was generated using a raid0 device on partitions to the same device. Since all raid0 I/O then goes to one device, it makes it easy to see a gap between the md device and its sd storage. Reading an lvm device on top of the md device, the iostat output (some 0 columns and extra devices removed to make the data more compact) was:

Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read

md2               0.00         0.00         0.00         0.00          0
sde               0.00         0.00         0.00         0.00          0
md2            1364.00    411496.00         0.00         0.00     411496
sde            1734.00    646144.00         0.00         0.00     646144
md2            1699.00    510680.00         0.00         0.00     510680
sde            2155.00    802784.00         0.00         0.00     802784
md2             803.00    241480.00         0.00         0.00     241480
sde            1016.00    377888.00         0.00         0.00     377888
md2               0.00         0.00         0.00         0.00          0
sde               0.00         0.00         0.00         0.00          0
Quoted 8 lines

I/O was generated doing large direct I/O reads (12M) with dd to a linear lvm volume on top of the 4 leg raid0 device.

The md2 reads were showing as roughly 2/3 of the reads to the sde device containing all of md2's raid partitions. The sum of reads to sde was 1826816 kB, which was the expected amount as it was the amount read by dd. With the patch, the total reads from md will match the reads from sde and be consistent with the amount of I/O generated.

We can include this part in the commit log to keep more context for future reference.

Thanks,
Song