Skip to content

Commit a6fc047

Browse files
mikechristiemstsirkin
authored andcommitted
vhost: take worker or vq for flushing
This patch has the core work flush function take a worker. When we support multiple workers we can then flush each worker during device removal, stoppage, etc. It also adds a helper to flush specific virtqueues, so vhost-scsi can flush IO vqs from it's ctl vq. Signed-off-by: Mike Christie <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 0921ddd commit a6fc047

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

drivers/vhost/vhost.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,27 @@ bool vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work)
265265
}
266266
EXPORT_SYMBOL_GPL(vhost_vq_work_queue);
267267

268-
void vhost_dev_flush(struct vhost_dev *dev)
268+
static void vhost_worker_flush(struct vhost_worker *worker)
269269
{
270270
struct vhost_flush_struct flush;
271271

272272
init_completion(&flush.wait_event);
273273
vhost_work_init(&flush.work, vhost_flush_work);
274274

275-
if (vhost_work_queue(dev, &flush.work))
275+
if (vhost_worker_queue(worker, &flush.work))
276276
wait_for_completion(&flush.wait_event);
277277
}
278+
279+
void vhost_vq_flush(struct vhost_virtqueue *vq)
280+
{
281+
vhost_worker_flush(vq->worker);
282+
}
283+
EXPORT_SYMBOL_GPL(vhost_vq_flush);
284+
285+
void vhost_dev_flush(struct vhost_dev *dev)
286+
{
287+
vhost_worker_flush(dev->worker);
288+
}
278289
EXPORT_SYMBOL_GPL(vhost_dev_flush);
279290

280291
/* A lockless hint for busy polling code to exit the loop */

drivers/vhost/vhost.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *,
198198
struct vhost_log *log, unsigned int *log_num);
199199
void vhost_discard_vq_desc(struct vhost_virtqueue *, int n);
200200

201+
void vhost_vq_flush(struct vhost_virtqueue *vq);
201202
bool vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work);
202203
bool vhost_vq_has_work(struct vhost_virtqueue *vq);
203204
bool vhost_vq_is_setup(struct vhost_virtqueue *vq);

0 commit comments

Comments
 (0)