Bug 1219930

Summary: btrfs-balance kernel 6.7 metadata over-allocation
Product: [openSUSE] openSUSE Tumbleweed Reporter: Martin Wilck <martin.wilck>
Component: Kernel:FilesystemsAssignee: Filipe Manana <fdmanana>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: dsterba, fvogt, jslaby, pujos.michael, rbranco
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Martin Wilck 2024-02-14 14:41:26 UTC
Upstream report:

https://lore.kernel.org/linux-btrfs/CAL3q7H5UaYcAYHijBO+QTnnpruVQXvdirg05_X94KRKrKnXDZw@mail.gmail.com/T/

Patches have been submitted for 6.8-rc5:

https://lore.kernel.org/linux-btrfs/cover.1707900530.git.dsterba@suse.com/T/#u

The patches aren't in the stable tree yet, and there are no backports in the openSUSE stable branch as of now, afaict.

The default setting for scheduled btrfs balance in the btrfsmaintenance package is "weekly", and 6.7 is in TW since beginning of February, so people will be hurt by this issue now.
Comment 1 Martin Wilck 2024-02-14 14:42:40 UTC
Assiging to Filipe, as he's been working on the issue upstream.
Comment 2 Michael Pujos 2024-02-14 16:01:12 UTC
The 

In the meantime, the wasted metadata space can be reclaimed with:

sudo btrfs balance start -musage=1 /

if this command results in 'No space left on device' like it did on my system (despite 'estimated free space' being multiple GBs), try first with -musage=30 then again with -musage=1
Comment 3 Jiri Slaby 2024-02-15 07:14:04 UTC
Could you push those to the stable branch, please?
Comment 4 Martin Wilck 2024-02-16 19:53:55 UTC
I am not sure which of Filipe's patches are required for fixing this issue. I'd be really grateful if Filipe could have a look himself.
Comment 5 Jiri Slaby 2024-02-17 07:49:00 UTC
In the meantime, I took David's:
https://lore.kernel.org/all/20240215133633.25420-1-dsterba@suse.com/
Comment 6 Jiri Slaby 2024-02-17 07:49:27 UTC
(In reply to Jiri Slaby from comment #5)
> In the meantime, I took David's:
> https://lore.kernel.org/all/20240215133633.25420-1-dsterba@suse.com/

1693d5442c45 btrfs: add and use helper to check if block group is used
f4a9f219411f btrfs: do not delete unused block group if it may be used soon
12c5128f101b btrfs: add new unused block groups to the list of unused block groups
2f6397e448e6 btrfs: don't refill whole delayed refs block reserve when starting transaction