From patchwork Thu Aug 20 09:17:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265874 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=-9.8 required=3.0 tests=BAYES_00,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=ham 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 3B2B3C433DF for ; Thu, 20 Aug 2020 09:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0498F22CF6 for ; Thu, 20 Aug 2020 09:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915446; bh=CBIuRgCwHt3xmyNXNvTeyTlBOfldpXpbVi5vYfYu2mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FGePQrXd422jBBBoulWduVJXA2CXqwsnHT70fKRGCv2W7QeSUMPsXAd2BZXdRLqiw DSJL+KKbt+kc7mlxwq3ZuI6CzWAmnOsUwTD52gB4k+kYK+/1hhwW2I312p5B6OQt4V APr2c3+5Mz3lrYCriPuTXi/2RUr7mzL6VI7LPr/E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgHTJYC (ORCPT ); Thu, 20 Aug 2020 05:24:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:59830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbgHTJX5 (ORCPT ); Thu, 20 Aug 2020 05:23:57 -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 0885B22CE3; Thu, 20 Aug 2020 09:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915436; bh=CBIuRgCwHt3xmyNXNvTeyTlBOfldpXpbVi5vYfYu2mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddzZR7YXeMmFsqXjC1VWoRCCpoXiKIVNjk5mTruKjrjKu+7Cg9DxoYsYyTDCGQycy nizZtSQCuLA9rNOHZJu6tS4hiBY4hJyOYa0dm1gqCr9NaLwAKJm9GVEpAhz5ZFLW7H KSYogZyJyGStN1IJ6mZ4yuv45UZZZ+q6HqAeKwU8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , David Sterba Subject: [PATCH 5.8 013/232] btrfs: allow use of global block reserve for balance item deletion Date: Thu, 20 Aug 2020 11:17:44 +0200 Message-Id: <20200820091613.366183293@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Sterba commit 3502a8c0dc1bd4b4970b59b06e348f22a1c05581 upstream. On a filesystem with exhausted metadata, but still enough to start balance, it's possible to hit this error: [324402.053842] BTRFS info (device loop0): 1 enospc errors during balance [324402.060769] BTRFS info (device loop0): balance: ended with status: -28 [324402.172295] BTRFS: error (device loop0) in reset_balance_state:3321: errno=-28 No space left It fails inside reset_balance_state and turns the filesystem to read-only, which is unnecessary and should be fixed too, but the problem is caused by lack for space when the balance item is deleted. This is a one-time operation and from the same rank as unlink that is allowed to use the global block reserve. So do the same for the balance item. Status of the filesystem (100GiB) just after the balance fails: $ btrfs fi df mnt Data, single: total=80.01GiB, used=38.58GiB System, single: total=4.00MiB, used=16.00KiB Metadata, single: total=19.99GiB, used=19.48GiB GlobalReserve, single: total=512.00MiB, used=50.11MiB CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Johannes Thumshirn Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3231,7 +3231,7 @@ static int del_balance_item(struct btrfs if (!path) return -ENOMEM; - trans = btrfs_start_transaction(root, 0); + trans = btrfs_start_transaction_fallback_global_rsv(root, 0); if (IS_ERR(trans)) { btrfs_free_path(path); return PTR_ERR(trans);