Re: [PATCH 1/2] btrfs: overwrite a leftover balance item instead of BUG_ON()

From: Qu Wenruo

Date: Thu Nov 05 2026 - 17:45:47 EST




在 2026/11/6 09:10, Siddharth Mishra 写道:
On Fri, Nov 06, 2026 at 08:39:01AM +1030, Qu Wenruo wrote:

Both assumptions can be wrong:

- insert_balance_item() inserts the item, then commits the transaction.
btrfs_commit_transaction() can fail without aborting the
transaction, for example when btrfs_start_dirty_block_groups() fails
to allocate a path.

I think no call site can handle a btrfs_commit_transaction() failure
without transaction abort.

This is a way bigger problem than what you're fixing.

Are you suggesting that the right fix is to make
btrfs_commit_transaction() abort the transaction when
btrfs_start_dirty_block_groups() fails?

At least one should check if all btrfs_commit_transaction() callers can handle such error correctly.