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: 2e23834058 ("xfs: implement direct writes to zoned RT devices")
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
Anthony Iliopoulos 2026-10-21 23:00:32 +02:00 committed by Carlos Maiolino
parent 5745f4f10a
commit 1e253beed5

View File

@ -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;
}