summaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-01-15 09:11:17 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2020-01-15 22:13:11 -0800
commit7b53b868a1812a9a6ab5e69249394bd37f29ce2c (patch)
tree74c8def00ecd0a67f1fb645e1c6001f728e0b8a3 /fs/xfs
parentca78eee7b4ac13b63f5e872f7c3a5ca66b2df8da (diff)
downloadlinux-stable-7b53b868a1812a9a6ab5e69249394bd37f29ce2c.tar.gz
linux-stable-7b53b868a1812a9a6ab5e69249394bd37f29ce2c.tar.bz2
linux-stable-7b53b868a1812a9a6ab5e69249394bd37f29ce2c.zip
xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read
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@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_file.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index c93250108952..b8a4a3f29b36 100644
--- 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_read_iomap_ops, NULL,
is_sync_kiocb(iocb));
xfs_iunlock(ip, XFS_IOLOCK_SHARED);