From patchwork Wed Dec 11 16:17:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 3327251 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5D7329F37A for ; Wed, 11 Dec 2013 16:18:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A885207CA for ; Wed, 11 Dec 2013 16:18:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2108120601 for ; Wed, 11 Dec 2013 16:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751036Ab3LKQSO (ORCPT ); Wed, 11 Dec 2013 11:18:14 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:54259 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750809Ab3LKQSN (ORCPT ); Wed, 11 Dec 2013 11:18:13 -0500 Received: from pps.filterd (m0004077 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id rBBGICuD000763 for ; Wed, 11 Dec 2013 08:18:12 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=7j9OCLn08TApYsLVhBPu3JG243Qhlgxc9sdZgyTsGdA=; b=pHBlqaVd/WJDUmKgLUwYyQiUQrBAJpuenK/uWMNCaPuBy8nSLZQOl7QeBIlGLDsDeAIJ iw7UMr5SyZLSWozWOdn423mrDkh1o58ePSEEBzOnENCyw4fIqT3lx4UlWpHW3BUTl6UE 5HUqHlBtiVXrXp1m9Eda4vmXP6MWi9CrTVY= Received: from mail.thefacebook.com (prn1-cmdf-dc01-fw1-nat.corp.tfbnw.net [173.252.71.129] (may be forged)) by mx0b-00082601.pphosted.com with ESMTP id 1gptvn03uv-2 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Wed, 11 Dec 2013 08:18:12 -0800 Received: from localhost (192.168.57.29) by mail.thefacebook.com (192.168.16.21) with Microsoft SMTP Server (TLS) id 14.3.169.1; Wed, 11 Dec 2013 08:17:54 -0800 From: Josef Bacik To: Subject: [PATCH] Btrfs-progs: reset balance before reiniting extent root Date: Wed, 11 Dec 2013 11:17:52 -0500 Message-ID: <1386778672-15357-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [192.168.57.29] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87, 1.0.14, 0.0.0000 definitions=2013-12-11_03:2013-12-11, 2013-12-11, 1970-01-01 signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we re-init the extent root we make it completely empty, so when we reset a pending balance we will fail to find refs for any blocks we may cow, which will result in errors and we will exit out. We need to reset the balance first so the normal cow stuff doesn't freak out and then we can re-init the extent tree. Thanks, Signed-off-by: Josef Bacik --- cmds-check.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index b27154f..7f07d3b 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -5931,6 +5931,12 @@ static int reinit_extent_tree(struct btrfs_fs_info *fs_info) return ret; } + ret = reset_balance(trans, fs_info); + if (ret) { + fprintf(stderr, "error reseting the pending balance\n"); + return ret; + } + /* Ok we can allocate now, reinit the extent root */ ret = btrfs_fsck_reinit_root(trans, fs_info->extent_root, 0); if (ret) { @@ -5943,12 +5949,6 @@ static int reinit_extent_tree(struct btrfs_fs_info *fs_info) return ret; } - ret = reset_balance(trans, fs_info); - if (ret) { - fprintf(stderr, "error reseting the pending balance\n"); - return ret; - } - /* * Now we have all the in-memory block groups setup so we can make * allocations properly, and the metadata we care about is safe since we