Commit 1fdeaea4 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: abort unaligned nowait directio early

Dave Chinner noticed that xfs_file_dio_aio_write returns EAGAIN without
dropping the IOLOCK when its deciding not to wait, which means that we
leak the IOLOCK there.  Since we now make unaligned directio always
wait, we have the opportunity to bail out before trying to take the
lock, which should reduce the overhead of this never-gonna-work case
considerably while also solving the dropped lock problem.
Reported-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 362f5e74
...@@ -517,6 +517,9 @@ xfs_file_dio_aio_write( ...@@ -517,6 +517,9 @@ xfs_file_dio_aio_write(
} }
if (iocb->ki_flags & IOCB_NOWAIT) { if (iocb->ki_flags & IOCB_NOWAIT) {
/* unaligned dio always waits, bail */
if (unaligned_io)
return -EAGAIN;
if (!xfs_ilock_nowait(ip, iolock)) if (!xfs_ilock_nowait(ip, iolock))
return -EAGAIN; return -EAGAIN;
} else { } else {
...@@ -536,9 +539,6 @@ xfs_file_dio_aio_write( ...@@ -536,9 +539,6 @@ xfs_file_dio_aio_write(
* xfs_file_aio_write_checks() for other reasons. * xfs_file_aio_write_checks() for other reasons.
*/ */
if (unaligned_io) { if (unaligned_io) {
/* unaligned dio always waits, bail */
if (iocb->ki_flags & IOCB_NOWAIT)
return -EAGAIN;
inode_dio_wait(inode); inode_dio_wait(inode);
} else if (iolock == XFS_IOLOCK_EXCL) { } else if (iolock == XFS_IOLOCK_EXCL) {
xfs_ilock_demote(ip, XFS_IOLOCK_EXCL); xfs_ilock_demote(ip, XFS_IOLOCK_EXCL);
......
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