Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1233839pxa; Thu, 20 Aug 2020 06:20:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfOPtDLiuR7H5qIgGcC5tYUubIf84xyS/NTZ94xh7cdHArjAHP1UBtvuxt5zut3y6QshDj X-Received: by 2002:a17:906:9392:: with SMTP id l18mr3148077ejx.357.1597929651870; Thu, 20 Aug 2020 06:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597929651; cv=none; d=google.com; s=arc-20160816; b=By7lXGj2cVSF8F+akTyuZs7h4vkNqaoXaoljGmMavuivoNUl4LY7ynAO8bMqfEp5bQ AC5QPYB0gPcwonATFHT9w63KI3c6MufDhy194ADCtrpNB9tMizQzUf36MTntJVj/rnNf 8f0D1GRkvATSzze+8GH2t0/vA3GaEefrAv9fWpzhUHUz0V9dgYsN0PKaopyv8IWMahbc zVPZz1f/WzLwUfIXQMK1kX0sKtpQDJq/OrO/ZfZAcFdhNU86jJ+UuISoI4vBLKMYItg0 qULeWXZj1b96RsIcmpy8Mg5Cubk92PMfmlQDP4KbCw+XihI7key+BJmxlzm/g84Zlop1 nORw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UyRmksJNSQCe86tp6bshb1MIydfq7vur09dOQ4RqkRs=; b=G98OMP6nCgr/tz2dubpjiDlFmeDnuUhBFz9MTU4LTswXsu0CQd5PN76dk6lOZx1CBB Ks0WfrzoRdz5I5yFOikK80EZ6nbBEtJcAcL4q6m4ilCjOzQOyVsl6qfl8L1PLno4YYs/ k4nPqbpJRqQfyGeARXHiP5Dd8rmTOYYxFgR9+/Bu+hqpz3NjKfg/FCiV8HPiWwz3xZ0D 4qfLa6RY3Cl7sosYxV3i9JJqAkOThWtQnHk/pCh3WYU8HATBXzGA58yzAAOospiBgqu+ /8DVuLsqCIWOTVE2JLAaxoevpGxDKv+98LYU3q1SHUUEh7EQNbKgBWP/5kD8YMMF6hKO zbvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eVYNB8h6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si1138688eje.233.2020.08.20.06.20.26; Thu, 20 Aug 2020 06:20:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eVYNB8h6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729451AbgHTNRo (ORCPT + 99 others); Thu, 20 Aug 2020 09:17:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:48070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728172AbgHTJez (ORCPT ); Thu, 20 Aug 2020 05:34:55 -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 BBC7B20724; Thu, 20 Aug 2020 09:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597916095; bh=7cAz3Ec2k+7Y8nlZLkYt3m3jyL4YEhx1BCEiANHBXnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVYNB8h6WrwwGG52s+B8KvIB/FgJ9Egxag0xMvTrz32Tnme5EZnbxgYfDjkwYR60R W3dApJnv/kfFdiCGX39329y/OAE/o4pWtEYTlpvzCW4Ra9JQCqzs5KGcNcSTL64yWc uDlOfoSniVhuIhMPs6ma/x7FPUlrVJKgLtRKO4Gw= 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.7 010/204] btrfs: allow use of global block reserve for balance item deletion Date: Thu, 20 Aug 2020 11:18:27 +0200 Message-Id: <20200820091606.724524770@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091606.194320503@linuxfoundation.org> References: <20200820091606.194320503@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -3235,7 +3235,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);