]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.16.3/xfs-don-t-zero-partial-page-cache-pages-during-o_direct-writes.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / xfs-don-t-zero-partial-page-cache-pages-during-o_direct-writes.patch
CommitLineData
8b77cbea
GKH
1From 834ffca6f7e345a79f6f2e2d131b0dfba8a4b67a Mon Sep 17 00:00:00 2001
2From: Dave Chinner <dchinner@redhat.com>
3Date: Tue, 2 Sep 2014 12:12:52 +1000
4Subject: xfs: don't zero partial page cache pages during O_DIRECT writes
5
6From: Dave Chinner <dchinner@redhat.com>
7
8commit 834ffca6f7e345a79f6f2e2d131b0dfba8a4b67a upstream.
9
10Similar to direct IO reads, direct IO writes are using
11truncate_pagecache_range to invalidate the page cache. This is
12incorrect due to the sub-block zeroing in the page cache that
13truncate_pagecache_range() triggers.
14
15This patch fixes things by using invalidate_inode_pages2_range
16instead. It preserves the page cache invalidation, but won't zero
17any pages.
18
19Signed-off-by: Dave Chinner <dchinner@redhat.com>
20Reviewed-by: Brian Foster <bfoster@redhat.com>
21Reviewed-by: Christoph Hellwig <hch@lst.de>
22Signed-off-by: Dave Chinner <david@fromorbit.com>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25---
26 fs/xfs/xfs_file.c | 10 +++++++++-
27 1 file changed, 9 insertions(+), 1 deletion(-)
28
29--- a/fs/xfs/xfs_file.c
30+++ b/fs/xfs/xfs_file.c
31@@ -634,7 +634,15 @@ xfs_file_dio_aio_write(
32 pos, -1);
33 if (ret)
34 goto out;
35- truncate_pagecache_range(VFS_I(ip), pos, -1);
36+ /*
37+ * Invalidate whole pages. This can return an error if
38+ * we fail to invalidate a page, but this should never
39+ * happen on XFS. Warn if it does fail.
40+ */
41+ ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
42+ pos >> PAGE_CACHE_SHIFT, -1);
43+ WARN_ON_ONCE(ret);
44+ ret = 0;
45 }
46
47 /*