From fcf64f45d9bf4270f6c6bfe9df6ef253a7bfc766 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 29 Jun 2016 13:59:51 -0700 Subject: Fix zdb crash with 4K-only devices Here's the problem - on 4K native devices in userland on Linux using O_DIRECT, buffers must be 4K aligned or I/O will fail with EINVAL, causing zdb (and others) to coredump. Since userland probably doesn't need optimized buffer caches, we just force 4K alignment on everything. Signed-off-by: Brian Behlendorf Signed-off-by: Gvozden Neskovic Closes #4479 --- module/zfs/zio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'module') diff --git a/module/zfs/zio.c b/module/zfs/zio.c index de56a1283..3dd8cffe9 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -143,12 +143,21 @@ zio_init(void) */ if (arc_watch && !IS_P2ALIGNED(size, PAGESIZE)) continue; -#endif + /* + * Here's the problem - on 4K native devices in userland on + * Linux using O_DIRECT, buffers must be 4K aligned or I/O + * will fail with EINVAL, causing zdb (and others) to coredump. + * Since userland probably doesn't need optimized buffer caches, + * we just force 4K alignment on everything. + */ + align = 8 * SPA_MINBLOCKSIZE; +#else if (size <= 4 * SPA_MINBLOCKSIZE) { align = SPA_MINBLOCKSIZE; } else if (IS_P2ALIGNED(size, p2 >> 2)) { align = MIN(p2 >> 2, PAGESIZE); } +#endif if (align != 0) { char name[36]; -- cgit v1.2.3