From e55225be3e2a49488a13e2d5247c071040466dd1 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 16 May 2025 23:27:05 -0400 Subject: [PATCH] Add explicit DMU_DIRECTIO checks UIO_DIRECT means we can do Direct I/O, while DMU_DIRECTIO we want to do it. First does not automatically means second. Add few checks to not use Direct I/O in few cases we don't want it. Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #17342 --- module/zfs/dmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 131b1d65d..671c52ac0 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -1383,7 +1383,7 @@ dmu_read_uio_dnode(dnode_t *dn, zfs_uio_t *uio, uint64_t size, dmu_buf_t **dbp; int numbufs, i, err; - if (uio->uio_extflg & UIO_DIRECT) + if ((flags & DMU_DIRECTIO) && (uio->uio_extflg & UIO_DIRECT)) return (dmu_read_uio_direct(dn, uio, size, flags)); flags &= ~DMU_DIRECTIO; @@ -1489,7 +1489,7 @@ top: * We only allow Direct I/O writes to happen if we are block * sized aligned. Otherwise, we pass the write off to the ARC. */ - if ((uio->uio_extflg & UIO_DIRECT) && + if ((flags & DMU_DIRECTIO) && (uio->uio_extflg & UIO_DIRECT) && (write_size >= dn->dn_datablksz)) { if (zfs_dio_aligned(zfs_uio_offset(uio), write_size, dn->dn_datablksz)) { @@ -1564,10 +1564,12 @@ top: dmu_buf_rele_array(dbp, numbufs, FTAG); - if ((uio->uio_extflg & UIO_DIRECT) && size > 0) { + if ((oflags & DMU_DIRECTIO) && (uio->uio_extflg & UIO_DIRECT) && + err == 0 && size > 0) { flags = oflags; goto top; } + IMPLY(err == 0, size == 0); return (err); }