Commit 942491c9 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: fix AIM7 regression

Apparently our current rwsem code doesn't like doing the trylock, then
lock for real scheme.  So change our read/write methods to just do the
trylock for the RWF_NOWAIT case.  This fixes a ~25% regression in
AIM7.

Fixes: 91f9943e ("fs: support RWF_NOWAIT for buffered reads")
Reported-by: default avatarkernel test robot <xiaolong.ye@intel.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 785545c8
...@@ -237,11 +237,13 @@ xfs_file_dax_read( ...@@ -237,11 +237,13 @@ xfs_file_dax_read(
if (!count) if (!count)
return 0; /* skip atime */ return 0; /* skip atime */
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) { if (iocb->ki_flags & IOCB_NOWAIT) {
if (iocb->ki_flags & IOCB_NOWAIT) if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
return -EAGAIN; return -EAGAIN;
} else {
xfs_ilock(ip, XFS_IOLOCK_SHARED); xfs_ilock(ip, XFS_IOLOCK_SHARED);
} }
ret = dax_iomap_rw(iocb, to, &xfs_iomap_ops); ret = dax_iomap_rw(iocb, to, &xfs_iomap_ops);
xfs_iunlock(ip, XFS_IOLOCK_SHARED); xfs_iunlock(ip, XFS_IOLOCK_SHARED);
...@@ -259,9 +261,10 @@ xfs_file_buffered_aio_read( ...@@ -259,9 +261,10 @@ xfs_file_buffered_aio_read(
trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos); trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos);
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) { if (iocb->ki_flags & IOCB_NOWAIT) {
if (iocb->ki_flags & IOCB_NOWAIT) if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
return -EAGAIN; return -EAGAIN;
} else {
xfs_ilock(ip, XFS_IOLOCK_SHARED); xfs_ilock(ip, XFS_IOLOCK_SHARED);
} }
ret = generic_file_read_iter(iocb, to); ret = generic_file_read_iter(iocb, to);
...@@ -552,9 +555,10 @@ xfs_file_dio_aio_write( ...@@ -552,9 +555,10 @@ xfs_file_dio_aio_write(
iolock = XFS_IOLOCK_SHARED; iolock = XFS_IOLOCK_SHARED;
} }
if (!xfs_ilock_nowait(ip, iolock)) { if (iocb->ki_flags & IOCB_NOWAIT) {
if (iocb->ki_flags & IOCB_NOWAIT) if (!xfs_ilock_nowait(ip, iolock))
return -EAGAIN; return -EAGAIN;
} else {
xfs_ilock(ip, iolock); xfs_ilock(ip, iolock);
} }
...@@ -606,9 +610,10 @@ xfs_file_dax_write( ...@@ -606,9 +610,10 @@ xfs_file_dax_write(
size_t count; size_t count;
loff_t pos; loff_t pos;
if (!xfs_ilock_nowait(ip, iolock)) { if (iocb->ki_flags & IOCB_NOWAIT) {
if (iocb->ki_flags & IOCB_NOWAIT) if (!xfs_ilock_nowait(ip, iolock))
return -EAGAIN; return -EAGAIN;
} else {
xfs_ilock(ip, iolock); xfs_ilock(ip, iolock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment