xfs: don't zero partial page cache pages during O_DIRECT writes
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / xfs / xfs_file.c
index 1028717d95f811869f1e5a4bf44c821016122202..9f457fedbcfcc996b5b84bd9e08d084e9f8cd9bd 100644 (file)
@@ -298,7 +298,16 @@ xfs_file_aio_read(
                                xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL);
                                return ret;
                        }
-                       truncate_pagecache_range(VFS_I(ip), pos, -1);
+
+                       /*
+                        * Invalidate whole pages. This can return an error if
+                        * we fail to invalidate a page, but this should never
+                        * happen on XFS. Warn if it does fail.
+                        */
+                       ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
+                                               pos >> PAGE_CACHE_SHIFT, -1);
+                       WARN_ON_ONCE(ret);
+                       ret = 0;
                }
                xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
        }