From patchwork Wed Aug 10 18:04:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sage Weil X-Patchwork-Id: 1054552 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7AI8P0o027822 for ; Wed, 10 Aug 2011 18:08:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753985Ab1HJSIV (ORCPT ); Wed, 10 Aug 2011 14:08:21 -0400 Received: from cobra.newdream.net ([66.33.216.30]:51666 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807Ab1HJSIU (ORCPT ); Wed, 10 Aug 2011 14:08:20 -0400 Received: from localhost.localdomain (aon.hq.newdream.net [64.111.111.107]) by cobra.newdream.net (Postfix) with ESMTPA id 91362BC69F; Wed, 10 Aug 2011 11:12:48 -0700 (PDT) From: Sage Weil To: linux-btrfs@vger.kernel.org Cc: Sage Weil Subject: [PATCH] Btrfs: truncate pages from clone ioctl target range Date: Wed, 10 Aug 2011 11:04:04 -0700 Message-Id: <1312999444-20475-1-git-send-email-sage@newdream.net> X-Mailer: git-send-email 1.7.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 10 Aug 2011 18:08:25 +0000 (UTC) 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 --- v1->v2: use ALIGN macro fs/btrfs/ioctl.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 514c0eb..5acb8e1 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2243,6 +2243,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;