From 1e253beed5340fdf1aa43cc684e085a6d468f5f7 Mon Sep 17 00:00:00 2001 From: Anthony Iliopoulos Date: Wed, 21 Oct 2026 23:00:32 +0200 Subject: [PATCH] xfs: skip iunlock with empty iolock flags in xfs_file_dio_write_aligned When using RWF_NOWAIT, xfs_file_write_checks may fail to acquire an exclusive lock upgrade and return -EAGAIN for aligned DIO, setting iolock to 0. In XFS_DEBUG kernels, passing no lock flags to xfs_iunlock triggers an assertion failure. Fix this by unlocking the iolock only when there are any flags set. Fixes: 2e2383405824 ("xfs: implement direct writes to zoned RT devices") Signed-off-by: Anthony Iliopoulos Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino --- fs/xfs/xfs_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 7d0c8a197575..1eab6dbb4c5f 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -766,7 +766,8 @@ xfs_file_dio_write_aligned( trace_xfs_file_direct_write(iocb, from); ret = iomap_dio_rw(iocb, from, ops, dops, dio_flags, ac, 0); out_unlock: - xfs_iunlock(ip, iolock); + if (iolock) + xfs_iunlock(ip, iolock); return ret; }