From 558638003ac9882c016b45425e9aaafe29777e0e Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 17 Nov 2022 13:21:01 +0800 Subject: [PATCH] lib/vhost_scsi: remove unnecessary checks `vhost_user_dev_unregister` will check if the device is busy, so we don't need to check `user_dev->pending_async_op_num` here. For `vdev->registered`, with this check here, we can remove a device even it didn't have a valid QEMU connection, and since vhost-scsi supports hotplug feature, we don't need to check this flag either when it have a valid QEMU connection. Change-Id: I50cdeb5ca544e2ed93a1bc99ec3da8787a9e5df5 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15481 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Feng Li Reviewed-by: Shuhei Matsumoto --- lib/vhost/vhost_scsi.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index b9eb96806..79aa93474 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -878,21 +878,11 @@ static int vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev) { struct spdk_vhost_scsi_dev *svdev = to_scsi_dev(vdev); - struct spdk_vhost_user_dev *user_dev = vdev->ctxt; - int rc = 0, i; - - if (user_dev->pending_async_op_num) { - return -EBUSY; - } + int rc, i; assert(svdev != NULL); for (i = 0; i < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS; ++i) { if (svdev->scsi_dev_state[i].dev) { - if (vdev->registered) { - SPDK_ERRLOG("%s: SCSI target %d is still present.\n", vdev->name, i); - return -EBUSY; - } - rc = spdk_vhost_scsi_dev_remove_tgt(vdev, i, NULL, NULL); if (rc != 0) { SPDK_ERRLOG("%s: failed to force-remove target %d\n", vdev->name, i);