From 059db03c53f64e40dff7ae062b5a00439282b4c6 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Tue, 23 Jul 2019 20:35:28 -0400 Subject: [PATCH] fixes for 5.1 Signed-off-by: Sasha Levin --- queue-5.1/series | 1 + ...bort-unaligned-nowait-directio-early.patch | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 queue-5.1/xfs-abort-unaligned-nowait-directio-early.patch diff --git a/queue-5.1/series b/queue-5.1/series index fe7470c9c5f..ddfdbb8b14a 100644 --- a/queue-5.1/series +++ b/queue-5.1/series @@ -343,3 +343,4 @@ coda-pass-the-host-file-in-vma-vm_file-on-mmap.patch include-asm-generic-bug.h-fix-cut-here-for-warn_on-for-__warn_taint-architectures.patch resource-fix-locking-in-find_next_iomem_res.patch btrfs-correctly-validate-compression-type.patch +xfs-abort-unaligned-nowait-directio-early.patch diff --git a/queue-5.1/xfs-abort-unaligned-nowait-directio-early.patch b/queue-5.1/xfs-abort-unaligned-nowait-directio-early.patch new file mode 100644 index 00000000000..8680324a3c1 --- /dev/null +++ b/queue-5.1/xfs-abort-unaligned-nowait-directio-early.patch @@ -0,0 +1,51 @@ +From 724b8a9a6f8e82d271f80316799d5b03c5cf1212 Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Thu, 18 Jul 2019 23:06:17 +0000 +Subject: xfs: abort unaligned nowait directio early + +[ Upstream commit 1fdeaea4d92c69fb9f871a787af6ad00f32eeea7 ] + +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 +Signed-off-by: Darrick J. Wong +Reviewed-by: Brian Foster +Reviewed-by: Dave Chinner +Reviewed-by: Christoph Hellwig +Signed-off-by: Sasha Levin +--- + fs/xfs/xfs_file.c | 6 +++--- + 1 file 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( + } + + if (iocb->ki_flags & IOCB_NOWAIT) { ++ /* unaligned dio always waits, bail */ ++ if (unaligned_io) ++ return -EAGAIN; + if (!xfs_ilock_nowait(ip, iolock)) + return -EAGAIN; + } else { +@@ -536,9 +539,6 @@ xfs_file_dio_aio_write( + * xfs_file_aio_write_checks() for other reasons. + */ + if (unaligned_io) { +- /* unaligned dio always waits, bail */ +- if (iocb->ki_flags & IOCB_NOWAIT) +- return -EAGAIN; + inode_dio_wait(inode); + } else if (iolock == XFS_IOLOCK_EXCL) { + xfs_ilock_demote(ip, XFS_IOLOCK_EXCL); +-- +2.20.1 + -- 2.47.3