From db751c162565e7e5abc43400db53b595720064e6 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Mon, 12 Jun 2017 12:17:50 +0200 Subject: [PATCH] Revert "vhost: Don't panic if the task count isn't 0" This reverts commit 86f215f38d57bf1702c3ba60de9357f80d025e76. Change-Id: Id3d18ffb44586ac38c5bc080a0550e5825d5ef3a Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/364947 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/vhost/vhost.c | 6 ------ lib/vhost/vhost_scsi.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 90be2eefb1..ef8feb63a4 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -506,12 +506,6 @@ spdk_vhost_dev_unload(struct spdk_vhost_dev *vdev) spdk_vhost_free_reactor(vdev->lcore); vdev->lcore = -1; - if (vdev->task_cnt > 0) { - SPDK_ERRLOG("%s: Leaked %u tasks when shutting down\n", vdev->name, vdev->task_cnt); - } - vdev->task_cnt = 0; - vdev->vid = -1; - vdev->num_queues = 0; } struct spdk_vhost_dev * diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 6ed23e89eb..bafab3b580 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -762,6 +762,7 @@ destroy_device(int vid) struct spdk_vhost_scsi_dev *svdev; struct spdk_vhost_dev *vdev; struct spdk_vhost_timed_event event = {0}; + uint32_t i; vdev = spdk_vhost_dev_find_by_vid(vid); if (vdev == NULL) { @@ -778,6 +779,16 @@ destroy_device(int vid) spdk_poller_unregister(&svdev->controlq_poller, event.spdk_event); spdk_vhost_timed_event_wait(&event, "unregister controll queue poller"); + /* Wait for all tasks to finish */ + for (i = 1000; i && vdev->task_cnt > 0; i--) { + usleep(1000); + } + + if (vdev->task_cnt > 0) { + rte_panic("%s: pending tasks did not finish in 1s.\n", vdev->name); + } + + spdk_vhost_timed_event_send(vdev->lcore, remove_vdev_cb, svdev, 1, "remove scsi vdev"); spdk_vhost_dev_unload(vdev);