]> git.hungrycats.org Git - linux/commit
btrfs: allow use of global block reserve for balance item deletion
authorDavid Sterba <dsterba@suse.com>
Thu, 25 Jun 2020 10:35:28 +0000 (12:35 +0200)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 31 Aug 2020 19:15:44 +0000 (15:15 -0400)
commitdc4048178ff3c44d4e4fdb626439497f53c9aa25
tree973582c7d48cb09274777f08ce822983c02ff618
parent2a7dad4380fe6a0ebce38fca8603f593a7c69887
btrfs: allow use of global block reserve for balance item deletion

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 <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 207659ef151c023c58226bafea5ebcd849638e2c)
fs/btrfs/volumes.c