From patchwork Tue Aug 9 17:46:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sage Weil X-Patchwork-Id: 1050562 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p79HopG2017614 for ; Tue, 9 Aug 2011 17:50:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754146Ab1HIRus (ORCPT ); Tue, 9 Aug 2011 13:50:48 -0400 Received: from cobra.newdream.net ([66.33.216.30]:38848 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754079Ab1HIRus (ORCPT ); Tue, 9 Aug 2011 13:50:48 -0400 Received: from localhost.localdomain (aon.hq.newdream.net [64.111.111.107]) by cobra.newdream.net (Postfix) with ESMTPA id CDFB8BC69F; Tue, 9 Aug 2011 10:55:13 -0700 (PDT) From: Sage Weil To: linux-btrfs@vger.kernel.org Cc: Sage Weil Subject: [PATCH] Btrfs: reserve sufficient space for ioctl clone Date: Tue, 9 Aug 2011 10:46:37 -0700 Message-Id: <1312911997-5075-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 (demeter1.kernel.org [140.211.167.41]); Tue, 09 Aug 2011 17:50:52 +0000 (UTC) Fix a crash/BUG_ON in the clone ioctl due to insufficient reservation. We need to reserve space for: - adjusting the old extent (possibly splitting it) - adding the new extent - updating the inode Signed-off-by: Sage Weil --- fs/btrfs/ioctl.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a3c4751..f038d4a 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2320,7 +2320,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, else new_key.offset = destoff; - trans = btrfs_start_transaction(root, 1); + /* + * 1 - adjusting old extent (we may have to split it) + * 1 - add new extent + * 1 - inode update + */ + trans = btrfs_start_transaction(root, 3); if (IS_ERR(trans)) { ret = PTR_ERR(trans); goto out;