|
@@ -1352,10 +1352,19 @@ xfs_reflink_remap_prep(
|
|
|
if (ret)
|
|
|
goto out_unlock;
|
|
|
|
|
|
- /* Zap any page cache for the destination file's range. */
|
|
|
- truncate_inode_pages_range(&inode_out->i_data,
|
|
|
- round_down(pos_out, PAGE_SIZE),
|
|
|
- round_up(pos_out + *len, PAGE_SIZE) - 1);
|
|
|
+ /*
|
|
|
+ * If pos_out > EOF, we may have dirtied blocks between EOF and
|
|
|
+ * pos_out. In that case, we need to extend the flush and unmap to cover
|
|
|
+ * from EOF to the end of the copy length.
|
|
|
+ */
|
|
|
+ if (pos_out > XFS_ISIZE(dest)) {
|
|
|
+ loff_t flen = *len + (pos_out - XFS_ISIZE(dest));
|
|
|
+ ret = xfs_flush_unmap_range(dest, XFS_ISIZE(dest), flen);
|
|
|
+ } else {
|
|
|
+ ret = xfs_flush_unmap_range(dest, pos_out, *len);
|
|
|
+ }
|
|
|
+ if (ret)
|
|
|
+ goto out_unlock;
|
|
|
|
|
|
return 1;
|
|
|
out_unlock:
|