Re: [PATCH] xen/blkback: Prevent missed completion when draining I/O

Roger Pau Monné <[email protected]>
Newsgroups gmane.comp.emulators.xen.devel,gmane.linux.block,gmane.linux.kernel
Message-ID <[email protected]>
On Thu, Jul 30, 2026 at 04:40:00PM +0800, Gui-Dong Han wrote:
> xen_blk_drain_io() sets drain before checking inflight.
> xen_blkbk_unmap_and_respond_callback() decrements inflight with
> atomic_dec_and_test() before checking drain.
> 
> The pre-wait condition check was added to avoid missing a completion, but
> atomic_set() is unordered. With one I/O in flight, the drain path can set
> drain to 1 and read inflight as 1 before the completion decrement. The
> completion path then decrements inflight to 0 but can still read drain as
> 0. It skips complete(), so the drain path waits until the timeout despite
> no I/O remaining.
> 
> Add a full barrier between setting drain and reading inflight.
> atomic_dec_and_test() already provides full ordering on the completion
> side.
> 
> Fixes: 6927d92091df ("xen/blkback: Fix two races in the handling of barrier requests.")
> Signed-off-by: Gui-Dong Han <[email protected]>

Sorry for the delay, this slipped through the cracks:

Acked-by: Roger Pau Monné <[email protected]>

Thanks, Roger.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.