Commit 1025b461 authored by Dave Chinner's avatar Dave Chinner Committed by Greg Kroah-Hartman

xfs: don't zero partial page cache pages during O_DIRECT writes

commit 834ffca6f7e345a79f6f2e2d131b0dfba8a4b67a upstream.

Similar to direct IO reads, direct IO writes are using
truncate_pagecache_range to invalidate the page cache. This is
incorrect due to the sub-block zeroing in the page cache that
truncate_pagecache_range() triggers.

This patch fixes things by using invalidate_inode_pages2_range
instead.  It preserves the page cache invalidation, but won't zero
any pages.
Signed-off-by: default avatarDave Chinner <>
Reviewed-by: default avatarBrian Foster <>
Reviewed-by: default avatarChristoph Hellwig <>
Signed-off-by: default avatarDave Chinner <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 3430681f
......@@ -677,7 +677,15 @@ xfs_file_dio_aio_write(
pos, -1);
if (ret)
goto out;
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);
ret = 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment