abd_iter_page: rework to handle multipage scatterlists
commitf4f156157de3f61e55db0429b10c63d02226e115
authorRob N <rob.norris@klarasystems.com>
Fri, 19 Apr 2024 23:41:31 +0000 (20 09:41 +1000)
committerGitHub <noreply@github.com>
Fri, 19 Apr 2024 23:41:31 +0000 (19 16:41 -0700)
tree7953263d50dd6c349b95d335cf37410f6fd27aa2
parent9f83eec03904b18e052fbe2c66542bd47254cf57
abd_iter_page: rework to handle multipage scatterlists

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 <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16108
module/os/linux/zfs/abd_os.c