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 <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15481
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Feng Li <lifeng1519@gmail.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
Changpeng Liu 2022-11-17 13:21:01 +08:00
parent b1dce7a8b7
commit 558638003a

View File

@ -878,21 +878,11 @@ static int
vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev) vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev)
{ {
struct spdk_vhost_scsi_dev *svdev = to_scsi_dev(vdev); struct spdk_vhost_scsi_dev *svdev = to_scsi_dev(vdev);
struct spdk_vhost_user_dev *user_dev = vdev->ctxt; int rc, i;
int rc = 0, i;
if (user_dev->pending_async_op_num) {
return -EBUSY;
}
assert(svdev != NULL); assert(svdev != NULL);
for (i = 0; i < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS; ++i) { for (i = 0; i < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS; ++i) {
if (svdev->scsi_dev_state[i].dev) { 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); rc = spdk_vhost_scsi_dev_remove_tgt(vdev, i, NULL, NULL);
if (rc != 0) { if (rc != 0) {
SPDK_ERRLOG("%s: failed to force-remove target %d\n", vdev->name, i); SPDK_ERRLOG("%s: failed to force-remove target %d\n", vdev->name, i);