From c706c20c50ad3cc5f0c5d7532473311ab6f65b37 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Thu, 3 Mar 2022 10:58:36 +0100 Subject: [PATCH] lib/vhost: move pending_async_op_num from generic vhost pending_async_op_num is specific to vhost_user. To prepare for virtio_blk transport abstraction, checking for the pending operations is moved to vhost_user specific code from vhost_blk. Ideally the vhost_user_dev_unregister() should be the only function that checks this field, but due to order of calls in vhost_scsi it needs to remain there separetly. This should not pose any issue, as vhost_scsi is still dependent directly on vhost_user. Signed-off-by: Tomasz Zawadzki Change-Id: I53dde73766dcf8596715560f6909a4679f8da930 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11811 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/vhost/rte_vhost_user.c | 4 ++++ lib/vhost/vhost.c | 4 ---- lib/vhost/vhost_scsi.c | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/vhost/rte_vhost_user.c b/lib/vhost/rte_vhost_user.c index d465153f6..05d935cfa 100644 --- a/lib/vhost/rte_vhost_user.c +++ b/lib/vhost/rte_vhost_user.c @@ -1756,6 +1756,10 @@ vhost_user_dev_register(struct spdk_vhost_dev *vdev, const char *name, struct sp int vhost_user_dev_unregister(struct spdk_vhost_dev *vdev) { + if (vdev->pending_async_op_num) { + return -EBUSY; + } + if (!TAILQ_EMPTY(&vdev->vsessions)) { SPDK_ERRLOG("Controller %s has still valid connection.\n", vdev->name); return -EBUSY; diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index eea486699..09176dc3c 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -196,10 +196,6 @@ vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w) int spdk_vhost_dev_remove(struct spdk_vhost_dev *vdev) { - if (vdev->pending_async_op_num) { - return -EBUSY; - } - return vdev->backend->remove_device(vdev); } diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 6ff07e130..b9e47c672 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -895,6 +895,10 @@ vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev) struct spdk_vhost_scsi_dev *svdev = to_scsi_dev(vdev); int rc, i; + if (vdev->pending_async_op_num) { + return -EBUSY; + } + assert(svdev != NULL); for (i = 0; i < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS; ++i) { if (svdev->scsi_dev_state[i].dev) {