]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - 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
1 From 834ffca6f7e345a79f6f2e2d131b0dfba8a4b67a Mon Sep 17 00:00:00 2001
2 From: Dave Chinner <dchinner@redhat.com>
3 Date: Tue, 2 Sep 2014 12:12:52 +1000
4 Subject: xfs: don't zero partial page cache pages during O_DIRECT writes
5
6 From: Dave Chinner <dchinner@redhat.com>
7
8 commit 834ffca6f7e345a79f6f2e2d131b0dfba8a4b67a upstream.
9
10 Similar to direct IO reads, direct IO writes are using
11 truncate_pagecache_range to invalidate the page cache. This is
12 incorrect due to the sub-block zeroing in the page cache that
13 truncate_pagecache_range() triggers.
14
15 This patch fixes things by using invalidate_inode_pages2_range
16 instead. It preserves the page cache invalidation, but won't zero
17 any pages.
18
19 Signed-off-by: Dave Chinner <dchinner@redhat.com>
20 Reviewed-by: Brian Foster <bfoster@redhat.com>
21 Reviewed-by: Christoph Hellwig <hch@lst.de>
22 Signed-off-by: Dave Chinner <david@fromorbit.com>
23 Signed-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 /*