Skip to content

Commit

Permalink
xfs: fix AIM7 regression
Browse files Browse the repository at this point in the history
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: 91f9943 ("fs: support RWF_NOWAIT for buffered reads")
Reported-by: kernel test robot <xiaolong.ye@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
  • Loading branch information
Christoph Hellwig authored and Darrick J. Wong committed Oct 24, 2017
1 parent 785545c commit 942491c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@ xfs_file_dax_read(
if (!count)
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;
} else {
xfs_ilock(ip, XFS_IOLOCK_SHARED);
}

ret = dax_iomap_rw(iocb, to, &xfs_iomap_ops);
xfs_iunlock(ip, XFS_IOLOCK_SHARED);

Expand All @@ -259,9 +261,10 @@ xfs_file_buffered_aio_read(

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;
} else {
xfs_ilock(ip, XFS_IOLOCK_SHARED);
}
ret = generic_file_read_iter(iocb, to);
Expand Down Expand Up @@ -552,9 +555,10 @@ xfs_file_dio_aio_write(
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;
} else {
xfs_ilock(ip, iolock);
}

Expand Down Expand Up @@ -606,9 +610,10 @@ xfs_file_dax_write(
size_t count;
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;
} else {
xfs_ilock(ip, iolock);
}

Expand Down

0 comments on commit 942491c

Please sign in to comment.