]> git.ipfire.org Git - thirdparty/linux.git/commit
md/raid5: account discard IO
authorYu Kuai <yukuai@fygo.io>
Fri, 5 Jun 2026 07:26:37 +0000 (15:26 +0800)
committerYu Kuai <yukuai@fygo.io>
Sat, 20 Jun 2026 19:16:24 +0000 (03:16 +0800)
commit74ddbf98e2db646ec58f7e7731c936b7a4a470fe
tree834d3b3c3970e82bd3264acaef0ec0af58b941fb
parenta4c55c902670f2784d3001652183aafa17712cfe
md/raid5: account discard IO

Raid5 handles discard bios internally through make_discard_request() and
never passes them through md_account_bio(). As a result, discard IO is
missing the md-device iostat accounting that normal raid5 IO and discard
IO in other raid levels get from md_account_bio().

Before accounting the bio, trim the request to the full data stripes that
raid5 will actually discard. The first full stripe is the ceiling of the
bio start divided by data-stripe sectors, and the last full stripe is the
floor of the bio end divided by data-stripe sectors. Account that exact
MD logical full-stripe range, then restore the original iterator so bio
completion and iostat still cover the original request.

Link: https://patch.msgid.link/20260605072639.2434847-2-yukuai@kernel.org
Signed-off-by: Yu Kuai <yukuai@fygo.io>
drivers/md/raid5.c