|
@@ -927,11 +927,26 @@ xfs_vm_writepage(
|
|
|
end_index = offset >> PAGE_CACHE_SHIFT;
|
|
|
last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
|
|
|
if (page->index >= end_index) {
|
|
|
- if ((page->index >= end_index + 1) ||
|
|
|
- !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
|
|
|
+ unsigned offset_into_page = offset & (PAGE_CACHE_SIZE - 1);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Just skip the page if it is fully outside i_size, e.g. due
|
|
|
+ * to a truncate operation that is in progress.
|
|
|
+ */
|
|
|
+ if (page->index >= end_index + 1 || offset_into_page == 0) {
|
|
|
unlock_page(page);
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+ /*
|
|
|
+ * The page straddles i_size. It must be zeroed out on each
|
|
|
+ * and every writepage invocation because it may be mmapped.
|
|
|
+ * "A file is mapped in multiples of the page size. For a file
|
|
|
+ * that is not a multiple of the page size, the remaining
|
|
|
+ * memory is zeroed when mapped, and writes to that region are
|
|
|
+ * not written out to the file."
|
|
|
+ */
|
|
|
+ zero_user_segment(page, offset_into_page, PAGE_CACHE_SIZE);
|
|
|
}
|
|
|
|
|
|
end_offset = min_t(unsigned long long,
|