HomeFreeBSD

vdev_disk: fix alignment check when buffer has non-zero starting offset

Description

vdev_disk: fix alignment check when buffer has non-zero starting offset

If a linear buffer spans multiple pages, and the first page has a
non-zero starting offset, the checker would not include the offset, and
so would think there was an alignment gap at the end of the first page,
rather than at the start.

That is, for a 16K buffer spread across five pages with an initial 512B
offset:

[.XXXXXXX][XXXXXXXX][XXXXXXXX][XXXXXXXX][XXXXXXX.]

It would be interpreted as:

[XXXXXXX.][XXXXXXXX]...

And be rejected as misaligned.

Since it's already a linear ABD, the "linearising" copy would just reuse
the buffer as-is, and the second check would failing, tripping the
VERIFY in vdev_disk_io_rw().

This commit fixes all this by including the offset in the check for
end-of-page alignment.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16076

Details

Provenance
rob.norris_klarasystems.comAuthored on Apr 10 2024, 3:14 AM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Apr 11 2024, 9:43 PM
Parents
rGbc27c494049e: tests: add test for vdev_disk page alignment check
Branches
Unknown
Tags
Unknown