This is a note to let you know that I've just added the patch titled xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-fix-iocb_nowait-handling-in-xfs_file_dio_aio_read.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Wed Oct 5 12:34:43 PM CEST 2022 From: Chandan Babu R <chandan.babu@xxxxxxxxxx> Date: Wed, 5 Oct 2022 12:30:59 +0530 Subject: xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read To: gregkh@xxxxxxxxxxxxxxxxxxx Cc: sashal@xxxxxxxxxx, mcgrof@xxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, djwong@xxxxxxxxxx, chandan.babu@xxxxxxxxxx, amir73il@xxxxxxxxx, leah.rumancik@xxxxxxxxx Message-ID: <20221005070105.41929-6-chandan.babu@xxxxxxxxxx> From: Christoph Hellwig <hch@xxxxxx> commit 7b53b868a1812a9a6ab5e69249394bd37f29ce2c upstream. Direct I/O reads can also be used with RWF_NOWAIT & co. Fix the inode locking in xfs_file_dio_aio_read to take IOCB_NOWAIT into account. Signed-off-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx> Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/xfs_file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -187,7 +187,12 @@ xfs_file_dio_aio_read( file_accessed(iocb->ki_filp); - xfs_ilock(ip, XFS_IOLOCK_SHARED); + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) + return -EAGAIN; + } else { + xfs_ilock(ip, XFS_IOLOCK_SHARED); + } ret = iomap_dio_rw(iocb, to, &xfs_iomap_ops, NULL); xfs_iunlock(ip, XFS_IOLOCK_SHARED); Patches currently in stable-queue which might be from chandan.babu@xxxxxxxxxx are queue-5.4/xfs-refactor-remote-attr-value-buffer-invalidation.patch queue-5.4/xfs-fix-s_maxbytes-computation-on-32-bit-kernels.patch queue-5.4/xfs-fix-misuse-of-the-xfs_attr_incomplete-flag.patch queue-5.4/xfs-fix-iocb_nowait-handling-in-xfs_file_dio_aio_read.patch queue-5.4/xfs-introduce-xfs_max_fileoff.patch queue-5.4/xfs-fix-memory-corruption-during-remote-attr-value-buffer-invalidation.patch queue-5.4/xfs-streamline-xfs_attr3_leaf_inactive.patch queue-5.4/xfs-move-incore-structures-out-of-xfs_da_format.h.patch queue-5.4/xfs-truncate-should-remove-all-blocks-not-just-to-the-end-of-the-page-cache.patch queue-5.4/xfs-fix-uninitialized-variable-in-xfs_attr3_leaf_inactive.patch queue-5.4/xfs-remove-unused-variable-done.patch