From patchwork Mon Feb 2 08:08:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Forrest Liu X-Patchwork-Id: 5759741 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A4EA49F336 for ; Mon, 2 Feb 2015 08:09:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E13C9201BC for ; Mon, 2 Feb 2015 08:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8955201BB for ; Mon, 2 Feb 2015 08:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932861AbbBBIJM (ORCPT ); Mon, 2 Feb 2015 03:09:12 -0500 Received: from mail.synology.com ([59.124.41.242]:64075 "EHLO mail.synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932677AbbBBIIz (ORCPT ); Mon, 2 Feb 2015 03:08:55 -0500 Received: from localhost.localdomain (unknown [192.168.0.152]) (Authenticated sender: forrestl@synology.com) by mail.synology.com (Postfix) with ESMTPSA id 39022BDEC6; Mon, 2 Feb 2015 16:08:51 +0800 (CST) From: Forrest Liu To: linux-btrfs@vger.kernel.org Cc: Forrest Liu Subject: [PATCH] Btrfs: fix BUG_ON in btrfs_orphan_add() when delete unused block group Date: Mon, 2 Feb 2015 16:08:48 +0800 Message-Id: <1422864528-8625-1-git-send-email-forrestl@synology.com> X-Mailer: git-send-email 1.9.1 X-MailScanner-ID: 39022BDEC6.AFA3A X-MailScanner: Found to be clean X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (cached, score=0.787, required 8, ALL_TRUSTED -1.00, AWL 0.99, BAYES_00 -1.90, DNS_FROM_AHBL_RHSBL 2.70) X-MailScanner-From: forrestl@synology.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP btrfs_orphan_reserve_metadata() will grab metadata reservation from transaction handle, and the transaction handle was passed from btrfs_delete_unused_bgs() when delete unused block group. Repace btrfs_join_transaction() with btrfs_start_transaction() in btrfs_delete_unused_bgs() to prevent BUG_ON() in btrfs_orphan_add() Signed-off-by: Forrest Liu --- fs/btrfs/extent-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 53294da..61a3255 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -9548,7 +9548,8 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) * Want to do this before we do anything else so we can recover * properly if we fail to join the transaction. */ - trans = btrfs_join_transaction(root); + /* 1 for btrfs_orphan_reserve_metadata() */ + trans = btrfs_start_transaction(root, 1); if (IS_ERR(trans)) { btrfs_set_block_group_rw(root, block_group); ret = PTR_ERR(trans);