On 11/19/25 7:27 PM, Kevin Wolf wrote: > When new requests arrive at a BlockBackend that is currently drained, > these requests are queued until the drain section ends. > > There is a race window between blk_root_drained_end() waking up a queued > request in an iothread from the main thread and blk_wait_while_drained() > actually being woken up in the iothread and calling blk_in_flight(). If > the BlockBackend is drained again during this window, drain won't wait > for this request and it will sneak in when the BlockBackend is already > supposed to be quiesced. This causes assertion failures in > bdrv_drain_all_begin() and can have other unintended consequences. > > Fix this by increasing the in_flight counter immediately when scheduling > the request to be resumed so that the next drain will wait for it to > complete. > > Cc: [email protected] > Reported-by: Andrey Drobyshev <[email protected]> > Signed-off-by: Kevin Wolf <[email protected]> > --- > block/block-backend.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-)
I can confirm that the crash is no longer reproducible with this fix applied. Thanks for looking into this! Tested-by: Andrey Drobyshev <[email protected]>
