@@ -765,7 +765,7 @@ xfs_add_to_ioend(
struct xfs_mount *mp = ip->i_mount;
struct block_device *bdev = xfs_find_bdev_for_inode(inode);
unsigned len = i_blocksize(inode);
- unsigned poff = offset & (PAGE_SIZE - 1);
+ unsigned poff = offset & (page_size(page) - 1);
bool merged, same_page = false;
sector_t sector;
@@ -843,7 +843,7 @@ xfs_aops_discard_page(
if (error && !XFS_FORCED_SHUTDOWN(mp))
xfs_alert(mp, "page discard unable to remove delalloc mapping.");
out_invalidate:
- xfs_vm_invalidatepage(page, 0, PAGE_SIZE);
+ xfs_vm_invalidatepage(page, 0, page_size(page));
}
/*
@@ -984,8 +984,7 @@ xfs_do_writepage(
struct xfs_writepage_ctx *wpc = data;
struct inode *inode = page->mapping->host;
loff_t offset;
- uint64_t end_offset;
- pgoff_t end_index;
+ uint64_t end_offset;
trace_xfs_writepage(inode, page, 0, 0);
@@ -1024,10 +1023,9 @@ xfs_do_writepage(
* ---------------------------------^------------------|
*/
offset = i_size_read(inode);
- end_index = offset >> PAGE_SHIFT;
- if (page->index < end_index)
- end_offset = (xfs_off_t)(page->index + 1) << PAGE_SHIFT;
- else {
+ end_offset = file_offset_of_next_page(page);
+
+ if (end_offset > offset) {
/*
* Check whether the page to write out is beyond or straddles
* i_size or not.
@@ -1039,7 +1037,8 @@ xfs_do_writepage(
* | | Straddles |
* ---------------------------------^-----------|--------|
*/
- unsigned offset_into_page = offset & (PAGE_SIZE - 1);
+ unsigned offset_into_page = offset_in_this_page(page, offset);
+ pgoff_t end_index = offset >> PAGE_SHIFT;
/*
* Skip the page if it is fully outside i_size, e.g. due to a
@@ -1070,7 +1069,7 @@ xfs_do_writepage(
* 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_SIZE);
+ zero_user_segment(page, offset_into_page, page_size(page));
/* Adjust the end_offset to the end of file */
end_offset = offset;