From patchwork Thu Mar 31 04:00:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry D'Anna X-Patchwork-Id: 678451 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2V46Y3V000328 for ; Thu, 31 Mar 2011 04:06:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504Ab1CaEGb (ORCPT ); Thu, 31 Mar 2011 00:06:31 -0400 Received: from cthulhu.elder-gods.org ([72.66.21.34]:57784 "EHLO cthulhu.elder-gods.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273Ab1CaEGa (ORCPT ); Thu, 31 Mar 2011 00:06:30 -0400 Received: by cthulhu.elder-gods.org (Postfix, from userid 1000) id CB4CC822CAD; Thu, 31 Mar 2011 00:00:16 -0400 (EDT) From: "Larry D'Anna" To: linux-btrfs@vger.kernel.org Cc: larry@elder-gods.org, "Yan Zheng" Subject: [PATCH 2/2] btrfs: allow cross-subvolume BTRFS_IOC_CLONE Date: Thu, 31 Mar 2011 00:00:13 -0400 Message-Id: X-Mailer: git-send-email 1.7.0.rc2.40.g7d8aa In-Reply-To: References: In-Reply-To: References: 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 (demeter1.kernel.org [140.211.167.41]); Thu, 31 Mar 2011 04:06:35 +0000 (UTC) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index f9717b6..10095c7 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1804,6 +1804,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, { struct inode *inode = fdentry(file)->d_inode; struct btrfs_root *root = BTRFS_I(inode)->root; + struct btrfs_root *srcroot; struct file *src_file; struct inode *src; struct btrfs_trans_handle *trans; @@ -1846,6 +1847,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, } src = src_file->f_dentry->d_inode; + srcroot = BTRFS_I(src)->root; ret = -EINVAL; if (src == inode) @@ -1860,11 +1862,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, goto out_fput; ret = -EXDEV; - if (src->i_sb != inode->i_sb || BTRFS_I(src)->root != root) + if (src->i_sb != inode->i_sb) goto out_fput; ret = -ENOMEM; - buf = vmalloc(btrfs_level_size(root, 0)); + buf = vmalloc(btrfs_level_size(srcroot, 0)); if (!buf) goto out_fput; @@ -1924,13 +1926,13 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, * note the key will change type as we walk through the * tree. */ - ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); + ret = btrfs_search_slot(NULL, srcroot, &key, path, 0, 0); if (ret < 0) goto out; nritems = btrfs_header_nritems(path->nodes[0]); if (path->slots[0] >= nritems) { - ret = btrfs_next_leaf(root, path); + ret = btrfs_next_leaf(srcroot, path); if (ret < 0) goto out; if (ret > 0)