[Devel] [PATCH hci-8.1 v3 9/9] drivers/vhost/blk: fix a hang on release after the vhost worker is killed

no-reply at sashiko.virtuozzo.com no-reply at sashiko.virtuozzo.com
Tue Nov 17 14:01:25 MSK 2026


> When the owner is killed, vhost_worker_killed() detaches the worker
> from the vqs. A bio completing after that fails to queue the
> completion work, so its request stays on llhead and is never removed
> from req_inflight. vhost_blk_flush() on release then waits forever
> and the process is stuck in D state. Any kill of a VM with I/O in
> flight can hit this.
> 
> If the work cannot be queued, drop the completed requests right in
> the bio end_io: forget them without writing a status, as there is no
> guest left to see it. llist_del_all() makes sure a request is dropped
> once even if it races with the last run of the host kick handler.
> forget_request() can now run in irq context, so take flush_lock with
> interrupts disabled. The end_io may run in atomic context and the
> request buffers may be vmalloc'ed, so free them on release instead:
> a dropped request is the one left with ->inflight set.
> 
> Once a request is on llhead, a concurrent consumer may forget it and
> let release free the request array and blk while the end_io is still
> using blk_vq. Keep the end_io tail in an RCU read-side section and
> wait for a grace period before freeing the requests. The same window
> existed before with the host kick handler as the consumer.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-152175
> 
> Fixes: c57a98d65796 ("drivers/vhost: vhost-blk accelerator for virtio-blk guests")
> Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
> Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117104329.3079812-1-alexander.ivanov@virtuozzo.com?part=9




More information about the Devel mailing list