diff --git a/include/spdk/vhost.h b/include/spdk/vhost.h index 1b0e80793..eaf8d966f 100644 --- a/include/spdk/vhost.h +++ b/include/spdk/vhost.h @@ -230,15 +230,9 @@ struct spdk_scsi_dev *spdk_vhost_scsi_dev_get_tgt(struct spdk_vhost_dev *vdev, u /** * Detach and destruct SCSI target from a vhost SCSI device. * - * If vhost SCSI device has an active socket connection, it is - * required that it has negotiated \c VIRTIO_SCSI_F_HOTPLUG feature - * flag.Otherwise an -ENOTSUP error code is returned. If the flag has - * been negotiated, the device will be marked to be deleted. Actual - * deletion is deferred until after all pending I/O to this device - * has finished. - * - * Once the target has been deleted (whether or not vhost SCSI - * device is in use) given callback will be called. + * The device will be deleted after all pending I/O is finished. + * If the driver supports VIRTIO_SCSI_F_HOTPLUG, then a hotremove + * notification will be sent. * * \param vdev vhost SCSI device * \param scsi_tgt_num slot id to delete target from diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 4c1ec29f8..fd3f7a03d 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -923,12 +923,6 @@ spdk_vhost_scsi_dev_remove_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tgt_nu return rc; } - if (!spdk_vhost_dev_has_feature(vdev->session, VIRTIO_SCSI_F_HOTPLUG)) { - SPDK_WARNLOG("%s: 'Target %u' is in use and hot-detach is not enabled for this controller.\n", - svdev->vdev.name, scsi_tgt_num); - return -ENOTSUP; - } - scsi_dev_state = &svdev->scsi_dev_state[scsi_tgt_num]; if (scsi_dev_state->removed) { SPDK_WARNLOG("%s: 'Target %u' has been already marked to hotremove.\n", svdev->vdev.name, @@ -939,7 +933,11 @@ spdk_vhost_scsi_dev_remove_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tgt_nu scsi_dev_state->remove_cb = cb_fn; scsi_dev_state->remove_ctx = cb_arg; scsi_dev_state->removed = true; - eventq_enqueue(svdev, scsi_tgt_num, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_REMOVED); + + if (spdk_vhost_dev_has_feature(vdev->session, VIRTIO_SCSI_F_HOTPLUG)) { + eventq_enqueue(svdev, scsi_tgt_num, VIRTIO_SCSI_T_TRANSPORT_RESET, + VIRTIO_SCSI_EVT_RESET_REMOVED); + } SPDK_INFOLOG(SPDK_LOG_VHOST, "%s: queued 'Target %u' for hot-detach.\n", vdev->name, scsi_tgt_num); return 0;