public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ublk_drv: set DMA alignment mask to 3
@ 2024-05-11 14:40 Jens Axboe
  2024-05-11 15:04 ` Ming Lei
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Axboe @ 2024-05-11 14:40 UTC (permalink / raw)
  To: Ming Lei, linux-block@vger.kernel.org

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.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 851c78913de2..292fa2bdd77d 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2176,6 +2176,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
 		.max_hw_sectors		= p->max_sectors,
 		.chunk_sectors		= p->chunk_sectors,
 		.virt_boundary_mask	= p->virt_boundary_mask,
+		.dma_alignment		= 3,
 
 	};
 	struct gendisk *disk;

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-11 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-11 14:40 [PATCH] ublk_drv: set DMA alignment mask to 3 Jens Axboe
2024-05-11 15:04 ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox