[Devel] [PATCH hci-8.1] drivers/vhost/blk: fix a flush hang on requests completed after worker kill

no-reply at sashiko.virtuozzo.com no-reply at sashiko.virtuozzo.com
Tue Nov 17 17:04:22 MSK 2026


> With vhost_task workers (not the default kthread ones), killing the
> owner makes vhost_worker_killed() detach the worker from the virtqueues
> and run only the work already queued. A request that completes after
> that is added to blk_vq->llhead, but vhost_vq_work_queue() returns
> false and queues nothing, so the request is never forgotten.
> req_inflight[] stays elevated and vhost_blk_flush() hangs
> uninterruptibly in release when the fd is closed. A request in flight
> at the kill is enough.
> 
> Release such requests from a work item when the worker cannot be
> queued, as vhost-scsi does in vhost_scsi_drop_cmds(). The bio
> completion may run in interrupt context, where a request cannot be
> released: that takes vq->mutex, and flush_lock with plain spin_lock().
> The guest is not answered, its memory is no longer reachable.
> 
> Once the completion publishes the request, the request can be
> forgotten and vhost_blk_flush() can return while the completion is
> still queueing work into blk, which release then frees. Queue under
> rcu_read_lock() and wait for it with synchronize_rcu() in
> vhost_blk_drop_backend(), then flush the drop work before freeing the
> requests.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-141684
> 
> Fixes: 1629db092dd7 ("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/20261117135955.3157381-1-alexander.ivanov@virtuozzo.com?part=1




More information about the Devel mailing list