Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3321683rwa; Tue, 23 Aug 2022 02:48:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR45jrbMtFgOVbr9oAkB7a2pdGG/NNWZFEbUykEo084gFerIP+RNTcH0P5IA49KwCw2CVZqS X-Received: by 2002:a17:907:842:b0:731:3310:4187 with SMTP id ww2-20020a170907084200b0073133104187mr14868449ejb.578.1661248092725; Tue, 23 Aug 2022 02:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248092; cv=none; d=google.com; s=arc-20160816; b=P2z4njRlIlbZsB3WH1g3akId8ZQHFoNKRUC7JgPSHB5yvhT5eDTNO+Cn8oKGM9t1Z2 hXxXlN5l/6lyFpeiAuU/sHSl4Cp/5Hp9dOInhTfVfUTAQgNSQsGgkDu0KBkGuiF/bDYh Hm6Mjj/WWvTx98SNmOm8DWW+0ilxkElRsBnzoXB6mqkwda0+RB86Gmx6ydjO53ZviviH 36bEjlBjX36IMmWZCG0fJOGGFm6bcmYloWujmiC2GWpQt1ku2QP1gZr0Q2B5+hp6lWP5 11/p8pDT+FIGAlp/Uqqz3wiVi2PqzCpPfPGD+UMBBENn+UK+9veeJIpHwil1rQVdOLmY vlGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AdeOOngbDP7EoSBSrbvvBUs8LoyCC9WqvIfFPLo6zcs=; b=logRzgTk8jfmXGHEgBURi2W/+ajc1yEV4QlrzEKw+x3/wYXG1TH74NhCRxkY//MVte G57ZJVfGbs/fDpBQHNIKO1mXc4et/z74isMjbgBT/KyLUhH+cEAa1ZgiHY1Ba0gyUIle SmvPwkgUaFJ+jf27uqVRkzW/BneBIo7SrkMOog89DQLRjE3CM02k8hBL/lM7zMJEAnXv +gtuJFe+XqwIDifsC/q6niCozcRPExedINkKeVqGteGkazn2w3ogIlOkGFOdmC6wixfR jU6wkofK5JGPxqIvzc08eSaZ4w4Y8T3EjvBONCHizXA1UQceazJTr3JYVVS/1ujivKPK jLUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1usutJx/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa38-20020a17090786a600b0073d7ad9607bsi5355264ejc.551.2022.08.23.02.47.46; Tue, 23 Aug 2022 02:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1usutJx/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350666AbiHWJgj (ORCPT + 99 others); Tue, 23 Aug 2022 05:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351207AbiHWJe4 (ORCPT ); Tue, 23 Aug 2022 05:34:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EDAB96743; Tue, 23 Aug 2022 01:39:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 92E6FB81C54; Tue, 23 Aug 2022 08:39:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8310C433D6; Tue, 23 Aug 2022 08:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243964; bh=YWBuCLLxymV+QhIOUC/mNWOy2xc9AppdGJvuTmckJK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1usutJx/KK5pMiLr+C3EIfX4EN4sk5f4lVeCO1cRKh6SdVV9hgcr10W+7nSy0r5mu wu/enQwK+i9hnRK0/+ywB9M8BzG0ruXMFeInWGHS+4oRVMieZwtfiT7Jpj49BhDGP2 PtomYh0Ls78KgZmffNTj2PYLg0zpnJ6RkGd2WZnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Burkov , Josef Bacik , David Sterba Subject: [PATCH 5.15 015/244] btrfs: reset RO counter on block group if we fail to relocate Date: Tue, 23 Aug 2022 10:22:54 +0200 Message-Id: <20220823080059.584832295@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik commit 74944c873602a3ed8d16ff7af3f64af80c0f9dac upstream. With the automatic block group reclaim code we will preemptively try to mark the block group RO before we start the relocation. We do this to make sure we should actually try to relocate the block group. However if we hit an error during the actual relocation we won't clean up our RO counter and the block group will remain RO. This was observed internally with file systems reporting less space available from df when we had failed background relocations. Fix this by doing the dec_ro in the error case. Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones") CC: stable@vger.kernel.org # 5.15+ Reviewed-by: Boris Burkov Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/block-group.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1575,9 +1575,11 @@ void btrfs_reclaim_bgs_work(struct work_ div64_u64(zone_unusable * 100, bg->length)); trace_btrfs_reclaim_block_group(bg); ret = btrfs_relocate_chunk(fs_info, bg->start); - if (ret) + if (ret) { + btrfs_dec_block_group_ro(bg); btrfs_err(fs_info, "error relocating chunk %llu", bg->start); + } next: btrfs_put_block_group(bg);