Re: [PATCH] btrfs: clear free space tree state on rebuild failure
From: Boris Burkov
Date: Tue Sep 15 2026 - 14:37:52 EST
On Tue, Sep 15, 2026 at 02:48:45PM +0000, Guanghui Yang wrote:
> btrfs_rebuild_free_space_tree() sets
> BTRFS_FS_CREATING_FREE_SPACE_TREE and
> BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED before rebuilding the free space
> tree. Several error paths return without clearing these flags.
>
> This leaves the flags set on the live filesystem and affects delayed
> reference processing and free-space caching. Clear both flags on all
> free space tree rebuild failure paths.
>
> Fixes: 1d6a4fc85717 ("btrfs: make clear_cache mount option to rebuild FST without disabling it")
I don't think this fixes tag is correct. In that version of the code,
all error paths aborted the transaction at which point the bit being set
or not doesn't really matter, in my opinion.
Unless I am missing something about the importance of clearing the bit
on an aborted transaction, I think the better fixes tag is:
882af9f13e83 ("btrfs: handle free space tree rebuild in multiple transactions")
> Cc: stable@xxxxxxxxxxxxxxx # 6.4+
> Assisted-by: Codex:gpt-5
> Tested: make -j$(nproc) fs/btrfs/free-space-tree.o
Is this all the testing you did or did you also run fstests on this
change?
Generally looks like a good fix for start_transaction() errors, though.
Thanks,
Boris