aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-04-17 11:49:36 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-04-23 11:36:23 -0400
commit1fdeaea4d92c69fb9f871a787af6ad00f32eeea7 (patch)
treee98d1575435dd511b7dc778b1010f867ea6a5ea5 /fs/xfs
parent362f5e745ae2ee2be9cf181b3a22917d619b81a1 (diff)
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: Dave Chinner <david@fromorbit.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index a7ceae90110e..76748255f843 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -517,6 +517,9 @@ xfs_file_dio_aio_write(
517 } 517 }
518 518
519 if (iocb->ki_flags & IOCB_NOWAIT) { 519 if (iocb->ki_flags & IOCB_NOWAIT) {
520 /* unaligned dio always waits, bail */
521 if (unaligned_io)
522 return -EAGAIN;
520 if (!xfs_ilock_nowait(ip, iolock)) 523 if (!xfs_ilock_nowait(ip, iolock))
521 return -EAGAIN; 524 return -EAGAIN;
522 } else { 525 } else {
@@ -536,9 +539,6 @@ xfs_file_dio_aio_write(
536 * xfs_file_aio_write_checks() for other reasons. 539 * xfs_file_aio_write_checks() for other reasons.
537 */ 540 */
538 if (unaligned_io) { 541 if (unaligned_io) {
539 /* unaligned dio always waits, bail */
540 if (iocb->ki_flags & IOCB_NOWAIT)
541 return -EAGAIN;
542 inode_dio_wait(inode); 542 inode_dio_wait(inode);
543 } else if (iolock == XFS_IOLOCK_EXCL) { 543 } else if (iolock == XFS_IOLOCK_EXCL) {
544 xfs_ilock_demote(ip, XFS_IOLOCK_EXCL); 544 xfs_ilock_demote(ip, XFS_IOLOCK_EXCL);