Re: [BUG] btrfs: Assertion failed in btrfs_exclop_balance on balance ioctl

David Sterba
2025-06-26T14:16:22Z

On Thu, Jun 26, 2025 at 04:11:51PM +0200, David Sterba wrote:
> On Thu, Jun 26, 2025 at 06:50:17PM +0930, Qu Wenruo wrote:
> >
> >
> > 在 2025/6/26 17:37, cen zhang 写道:
> > > Hello Btrfs maintainers,
> > >
> > > I would like to report a kernel BUG, which appears to be a state
> > > management issue in the balance ioctl path.
> > >
> > > The kernel panics due to a failed assertion in btrfs_exclop_balance()
> > > at fs/btrfs/fs.c:127. The assertion fs_info->exclusive_operation ==
> > > BTRFS_EXCLOP_BALANCE_PAUSED fails, indicating that the function was
> > > called with an unexpected exclusive operation state.
> > >
> > > Here are the relevant details:
> > >
> > > Kernel Version: 6.16.0-rc1-g7f6432600434-dirty
> > > Hardware: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996)
> >
> > Reproducer please?
> >
> > I guess you guys are running syzbot, then please provide the usual
> > syzbot assets.
>
> This might be the but that was once reported, I'll try to look it up,
> some edge case of the exclusive ops and the convoluted balance states.

There were several reports and proposed fixes, some of them got merged
https://lore.kernel.org/linux-btrfs/?q=xiaoshoukui

The possible and not merged fix is
https://lore.kernel.org/linux-btrfs/20230810034810.23934-1-xiaoshoukui@gmail.com/

it's adding more balance state bits, this just adds to the number of
possible states and maybe adds more unhandled cases.