From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 754A1C352BE for ; Thu, 16 Apr 2020 15:35:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56A892223D for ; Thu, 16 Apr 2020 15:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587051355; bh=T4BN4e03GBFcEvPAPYiVqCCxujczy7T1jTuFHTAa5a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ICKgGHUUgjYWslb5CA0MMo4f/5ScOrF5gKLGJ+TakWWuNiC6L5lgG9oWYaBucAGqK jcMS8oga22O22G4Qq/yARe9ZQ9oqVpEC77OCs78oQg3RGnHzIJ1TyJYD9pQLBIAI1R 5SgMZ4uHHvFIi2bgDxx3eoJihvt5I9hWEsicDEjE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894500AbgDPPfn (ORCPT ); Thu, 16 Apr 2020 11:35:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:52674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898063AbgDPNkH (ORCPT ); Thu, 16 Apr 2020 09:40:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2650218AC; Thu, 16 Apr 2020 13:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044407; bh=T4BN4e03GBFcEvPAPYiVqCCxujczy7T1jTuFHTAa5a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxqWCa3qcLWfT1WI8OqCw1kknwBAyBSfxM7FeAveGSxGiSbDih8hw/9n3s/ZxMs72 Mnf2n6MGOB3DHrQTYn4cFprVHyhM6vIKoF505Fu+TMFsfQ/+Dxu16nqCPYPFaJilfj cK7UbW2l8t36odz/UC9MZ4B8MLV3zwaTgoHnV8vM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Josef Bacik , David Sterba Subject: [PATCH 5.5 164/257] btrfs: unset reloc control if we fail to recover Date: Thu, 16 Apr 2020 15:23:35 +0200 Message-Id: <20200416131347.032136250@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131325.891903893@linuxfoundation.org> References: <20200416131325.891903893@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Josef Bacik commit fb2d83eefef4e1c717205bac71cb1941edf8ae11 upstream. If we fail to load an fs root, or fail to start a transaction we can bail without unsetting the reloc control, which leads to problems later when we free the reloc control but still have it attached to the file system. In the normal path we'll end up calling unset_reloc_control() twice, but all it does is set fs_info->reloc_control = NULL, and we can only have one balance at a time so it's not racey. CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Qu Wenruo Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/relocation.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4581,9 +4581,8 @@ int btrfs_recover_relocation(struct btrf trans = btrfs_join_transaction(rc->extent_root); if (IS_ERR(trans)) { - unset_reloc_control(rc); err = PTR_ERR(trans); - goto out_free; + goto out_unset; } rc->merge_reloc_tree = 1; @@ -4603,7 +4602,7 @@ int btrfs_recover_relocation(struct btrf if (IS_ERR(fs_root)) { err = PTR_ERR(fs_root); list_add_tail(&reloc_root->root_list, &reloc_roots); - goto out_free; + goto out_unset; } err = __add_reloc_root(reloc_root); @@ -4613,7 +4612,7 @@ int btrfs_recover_relocation(struct btrf err = btrfs_commit_transaction(trans); if (err) - goto out_free; + goto out_unset; merge_reloc_roots(rc); @@ -4629,7 +4628,8 @@ out_clean: ret = clean_dirty_subvols(rc); if (ret < 0 && !err) err = ret; -out_free: +out_unset: + unset_reloc_control(rc); kfree(rc); out: if (!list_empty(&reloc_roots))