-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
abd_iter_page: rework to handle multipage scatterlists #16108
abd_iter_page: rework to handle multipage scatterlists #16108
Conversation
@behlendorf @tonyhutter fwiw, assuming this passes muster, I'm softly against taking it to 2.2.4 at the last minute. While the scatterlist page iterator is not quite right, I'm pretty sure that it works properly for the only kinds of scatterlists it can currently receive, which should all be compound, and this code is off by default on 2.2 anyway. On the other hand, we know how many weird and wild Linux variants are out there, and we wanted this on 2.2 so we could ask people already hitting peculiar cases to try it, so one could argue they're already in a weird world. So I could go either way, but my default position is to err towards caution. I won't argue if you wanted to go the other way. |
83197b8
to
553c0d7
Compare
Just crudely looking this over - is this something that only affects < 4.5 kernels? Only asking since CentOS 7 is going to go EOL in June 2024... |
@tonyhutter No, all kernels. The comments and defines are just moving some of the logic from the existing 4.5 check up, because I need the newer You're right though, its not easy to follow though. I'll rework the commentary (code stays the same). |
553c0d7
to
a9068d9
Compare
Pushed update, lmk! |
Previously, abd_iter_page() would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create in abd_alloc_chunks(). However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong. This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reported-by: Brian Atkinson <[email protected]> Signed-off-by: Rob Norris <[email protected]>
a9068d9
to
e4ae602
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm this PR does fix the issue I was encountering in the Direct I/O PR (#10018).
Previously, abd_iter_page() would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create in abd_alloc_chunks(). However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong. This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reported-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#16108 (cherry picked from commit f4f1561)
Previously, abd_iter_page() would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create in abd_alloc_chunks(). However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong. This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reported-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#16108 (cherry picked from commit f4f1561)
Previously, abd_iter_page() would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create in abd_alloc_chunks(). However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong. This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reported-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#16108 (cherry picked from commit f4f1561)
Previously, abd_iter_page() would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create in abd_alloc_chunks(). However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong. This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reported-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#16108
Previously, abd_iter_page() would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create in abd_alloc_chunks(). However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong. This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reported-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#16108
Motivation and Context
@bwatkinson reported assertion trips and memory corruption after rebasing #10018 onto recent master. He traced the problem to scatterlists received from userspace carrying multiple contiguous non-compound pages, and asked me about it.
Description
Previously,
abd_iter_page()
would assume that every scatterlist would contain a single page (compound or no), because that's all we ever create inabd_alloc_chunks()
. However, scatterlists can contain multiple pages of arbitrary provenance, and if we get one of those, we'd get all the math wrong.This reworks things to handle multiple pages in a scatterlist, by properly finding the right page within it for the given offset, and understanding better where the end of the page is and not crossing it.
How Has This Been Tested?
Full ZTS run completed successfully against kernel 6.1.76.
Compile checked, sanity tested and "known troublesome" tests (ie
zpool_reopen_003_pos
) passed on 3.10-EL7, 4.14.336, 5.10.214, 6.1.83 and 6.8.2.Using @bwatkinson's rebase of #10018 to master, the
-T direct
test suite asserts out early without this change (specifically thedio_aligned_block
test), and all tests pass with it. See robn/directio-test.Types of changes
Checklist:
Signed-off-by
.