Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3324624rwa; Tue, 23 Aug 2022 02:52:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR4qCaNGAUd4g2CkWPCPXXaFVwzI6no9/d+mEDKIF+WNmwdvLBxY6P3PxteOgqfalBtVbauk X-Received: by 2002:a17:902:8603:b0:172:ede7:6076 with SMTP id f3-20020a170902860300b00172ede76076mr8160628plo.72.1661248333466; Tue, 23 Aug 2022 02:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248333; cv=none; d=google.com; s=arc-20160816; b=CKAfHV54X+PFGw2PfjUohTXRDAs3n9/pMW92QGWdyNSOGFwynO9GUbCp8I3NDUp2cv 2aJpEKN+VWhoG31bu6gH3uypxSLlS5VrOgVAmgcf6aSKDi1UNK/D4THCEfVg8yQBtNlw 50BMcbhaDWGqOkRpJ/ivpBc3txGVrYUDF/ulsv1FTFsyBy5rZp0zJK5QLIdEKtQEfwce AUuiiEdlO5OxE92/tS5VhWXidq3LeEkdVcWsJFrAawddBLpZuWROyQu/a6OVyYQWTPi1 Ubapa7ifMEyijlfFMc5BA7eANfeyVXp0XBMiCDxVA7nrTppAeHk/zzqXwmgFPI4dLNtI BgyA== 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=1tFi/dfm7MIyJunTfvby/OhTOJ8852feI7WVMxwOLCI=; b=Bk0vEXR/TBFunqb2HdLmiiXBpkoXuxPAEtuepgPihSb8aLG7Gxh5byACd8fpvqT7WA BbIuoYlnjDoVpdL5n7aGhw4L124ZB45x/Myf0z+kQ1h2OMfIl0nJJwHjTcGyJDxbQrM8 Qs1ZtejJSmb89bFb3ODonlyMPoY0QZoVhWCXKWEYCgvnI1qUeu4BYGQt8UwTQlxqUT+V 8zBQTTBpdA+Dpg6daoVjbENGHdi6YjaGDzuP7Zn/JTfOYNxjA+Rw4tuaw7jIv5DOB7KI 7Itst1sZbCcGWgNyD6YAdguezsd7NWD56y8qdLsM0X0oof0JQOvzu93eclZ29bGG09f/ kOtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ufgXN2kN; 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 j4-20020a056a00174400b0052c79a96579si5681349pfc.360.2022.08.23.02.52.02; Tue, 23 Aug 2022 02:52:13 -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=ufgXN2kN; 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 S241802AbiHWIJN (ORCPT + 99 others); Tue, 23 Aug 2022 04:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241631AbiHWII1 (ORCPT ); Tue, 23 Aug 2022 04:08:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E28B56CD01; Tue, 23 Aug 2022 01:05:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8987A611DD; Tue, 23 Aug 2022 08:05:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BF20C433C1; Tue, 23 Aug 2022 08:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661241918; bh=8u3wijuX4ETCv7WV+Sw2MPFZfSqAw8ruOcubsYmUVNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ufgXN2kNhqPSvt//z2dR5B/JrqNbMmTuXl5AqWJNlJKEGA6kxFQPWE5MJrMyoTDBv 1tzK4BwdB+ZOJgmvOvrO3UI95QqCdGagCEH9OM+UsnyM2E0rnZab7JZINrOAbBHsGV c8faVeIMG/ejike7GqObDaHl3jiFDA8aweO+M/IY= 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.19 019/365] btrfs: reset RO counter on block group if we fail to relocate Date: Tue, 23 Aug 2022 09:58:40 +0200 Message-Id: <20220823080119.003247301@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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 @@ -1640,9 +1640,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);