dm-io: clone the source bio instead of copying its biovec#973
Open
blktests-ci[bot] wants to merge 2 commits into
Open
dm-io: clone the source bio instead of copying its biovec#973blktests-ci[bot] wants to merge 2 commits into
blktests-ci[bot] wants to merge 2 commits into
Conversation
Author
|
Upstream branch: 66affa3 |
e6d9eb8 to
7d8604f
Compare
For DM_IO_BIO requests, do_region() built each destination bio by walking the source bio's biovec and re-adding the pages one at a time, tracking the remaining transfer in sectors. The vector lengths are byte granular and need not be sector aligned (e.g. a misaligned O_DIRECT buffer split across pages), so the sector-based accounting could lose a sub-sector fragment: to_sector() truncated the remainder and the outer loop spun forever submitting empty bios, hanging the I/O. There is no need to rebuild the biovec at all. The destination reads into (or writes from) exactly the same pages as the source bio, so the bio can simply clone the source's biovec with bio_alloc_clone() and remap it to the target device. The clone inherits the source's iterator and alignment, and the block layer splits it to the target's limits on submission, so the whole region maps to a single cloned bio with no manual page copying or sector accounting. This removes the per-page copy path (and its open-coded bvec dpages helpers) for bio-backed I/O and fixes the hang on misaligned direct I/O to a dm-mirror device. Page-list, vma and kmem sources keep the existing copy path. Fixes: 7eac331 ("iomap: simplify direct io validity check") Fixes: 5ff3f74 ("block: simplify direct io validity check") Reported-by: Dr. David Alan Gilbert <linux@treblig.org> Reported-by: Vjaceslavs Klimovs <vklimovs@gmail.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
BLK_STS_INVAL indicates the I/O request itself was invalid (for example a misaligned direct I/O), not that the device has failed. dm-raid1 treated any read or write completion error as a device failure: it failed the mirror leg, retried on the alternatives - which fail identically - and eventually returned EIO while spuriously degrading the array. Since commit 5ff3f74 ("block: simplify direct io validity check") the direct I/O path no longer rejects misaligned buffers up front, so an invalid bio now reaches the lower block layers, which fail it with BLK_STS_INVAL. dm-io collapses the block status into a per-region error bit before invoking the completion callback, so record BLK_STS_INVAL on the originating bio and have the dm-raid1 read, write and end_io paths propagate it instead of failing the device. This mirrors the raid1/raid10 fix in commit f7b24c7 ("md/raid1,raid10: don't fail devices for invalid IO errors") for the device-mapper mirror target. Fixes: 7eac331 ("iomap: simplify direct io validity check") Fixes: 5ff3f74 ("block: simplify direct io validity check") Reported-by: Dr. David Alan Gilbert <linux@treblig.org> Reported-by: Vjaceslavs Klimovs <vklimovs@gmail.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
Author
|
Upstream branch: bade58e |
afc7326 to
5c978fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: dm-io: clone the source bio instead of copying its biovec
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1112405