Skip to content

Commit

Permalink
Btrfs: truncate pages from clone ioctl target range
Browse files Browse the repository at this point in the history
We need to truncate page cache pages for the clone ioctl target range or
else we'll confuse ourselves to no end.  If the old data was cached, we
used to still see it (until remount).  If the page was partially updated
we used to get a mix of old and new data.

Signed-off-by: Sage Weil <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
liewegas authored and chrismason-xx committed Aug 17, 2011
1 parent 0e58885 commit f81c9cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,10 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
btrfs_wait_ordered_range(src, off, len);
}

/* truncate page cache pages from target inode range */
truncate_inode_pages_range(&inode->i_data, off,
ALIGN(off + len, PAGE_CACHE_SIZE) - 1);

/* clone data */
key.objectid = btrfs_ino(src);
key.type = BTRFS_EXTENT_DATA_KEY;
Expand Down

0 comments on commit f81c9cd

Please sign in to comment.