From aefc2da8a594d7a8059c862eab464d5f798393b3 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 23 Oct 2024 13:19:46 -0400 Subject: [PATCH] Workaround issue of Linux vdev_disk.c, (#16678) in some cases not linearizing buffers with disk sector crossing a page boundary. It is fine for hardware, but somehow required by LUKS. It is not typical for ZFS to produce such buffers, but it may happen if 6KB block is compressed to 4KB, while still having 2KB alignment. Banning the 6KB buffers helps vdevs with ashifh=12. Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt --- module/zfs/zio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/module/zfs/zio.c b/module/zfs/zio.c index a5daf73d59ba..3c7305e0e724 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -187,6 +187,20 @@ zio_init(void) continue; #endif +#if defined(__linux__) && defined(_KERNEL) + /* + * Workaround issue of Linux vdev_disk.c, in some cases not + * linearizing buffers with disk sector crossing a page + * boundary. It is fine for hardware, but somehow required by + * LUKS. It is not typical for ZFS to produce such buffers, but + * it may happen if 6KB block is compressed to 4KB, while still + * having 2KB alignment. Banning the 6KB buffers helps vdevs + * with ashifh=12. + */ + if (size > PAGESIZE && !IS_P2ALIGNED(size, PAGESIZE)) + continue; +#endif + if (IS_P2ALIGNED(size, PAGESIZE)) align = PAGESIZE; else