ublk_drv: set DMA alignment mask to 3
authorJens Axboe <axboe@kernel.dk>
Sat, 11 May 2024 14:37:52 +0000 (08:37 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 11 May 2024 15:25:55 +0000 (09:25 -0600)
commit073341c3031b6d2ae72d5a514c8bb87cd8e92ec5
tree0d9d45e335568f1d1ec4eaf9dbccd5807105553b
parenta3166c51702bb00b8f8b84022090cbab8f37be1a
ublk_drv: set DMA alignment mask to 3

By default, this will be 511, as that's the block layer default. But
drivers these days can support memory alignments that aren't tied to
the sector sizes, instead just being limited by what the DMA engine
supports. An example is NVMe, where it's generally set to a 32-bit or
64-bit boundary. As ublk itself doesn't really care, just set it low
enough that we don't run into issues with NVMe where the required
O_DIRECT memory alignment is now more restrictive on ublk than it is
on the underlying device.

This was triggered by spurious -EINVAL returns on O_DIRECT IO on a
setup with ublk managing NVMe devices, which previously worked just
fine on the NVMe device itself. With the alignment relaxed, the test
works fine.

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c