vhost/scsi: don't hotplug targets to stopped sessions
This is just a cleanup. There's no need to hotplug or hotremove SCSI targets from stopped sessions, because those sessions can't access any targets anyway. When session is started, it already inherits all SCSI targets from the vhost device. When it's stopped, it releases resources of all targets. Intermediate changes have no effect whatsoever, so don't do them. Change-Id: Ibf283bcf8260e71dec8d9ea39a9461a978031ab3 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449392 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
1188bdd70d
commit
4a51888953
@ -946,6 +946,11 @@ spdk_vhost_scsi_session_add_tgt(struct spdk_vhost_dev *vdev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vsession->lcore == -1) {
|
||||
/* Nothing to do. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
svsession = (struct spdk_vhost_scsi_session *)vsession;
|
||||
vhost_sdev = &svsession->svdev->scsi_dev_state[scsi_tgt_num];
|
||||
session_sdev = &svsession->scsi_dev_state[scsi_tgt_num];
|
||||
@ -953,11 +958,6 @@ spdk_vhost_scsi_session_add_tgt(struct spdk_vhost_dev *vdev,
|
||||
session_sdev->dev = vhost_sdev->dev;
|
||||
session_sdev->status = VHOST_SCSI_DEV_PRESENT;
|
||||
|
||||
if (vsession->lcore == -1) {
|
||||
/* All done. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = spdk_scsi_dev_allocate_io_channels(svsession->scsi_dev_state[scsi_tgt_num].dev);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Couldn't allocate io channnel for SCSI target %u in device %s\n",
|
||||
@ -1083,19 +1083,18 @@ spdk_vhost_scsi_session_remove_tgt(struct spdk_vhost_dev *vdev,
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (vsession->lcore == -1) {
|
||||
/* Nothing to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Mark the target for removal */
|
||||
svsession = (struct spdk_vhost_scsi_session *)vsession;
|
||||
state = &svsession->scsi_dev_state[scsi_tgt_num];
|
||||
assert(state->status == VHOST_SCSI_DEV_PRESENT);
|
||||
state->status = VHOST_SCSI_DEV_REMOVING;
|
||||
|
||||
/* If the session isn't currently polled, unset the dev straight away */
|
||||
if (vsession->lcore == -1) {
|
||||
state->dev = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Otherwise, send a hotremove Virtio event and wait for the session's
|
||||
/* Send a hotremove Virtio event and wait for the session's
|
||||
* management poller to remove the target after all its pending I/O
|
||||
* has finished.
|
||||
*/
|
||||
@ -1312,6 +1311,7 @@ spdk_vhost_scsi_start_cb(struct spdk_vhost_dev *vdev,
|
||||
if (state->dev == NULL) {
|
||||
continue;
|
||||
}
|
||||
assert(svsession->scsi_dev_state[i].status == VHOST_SCSI_DEV_EMPTY);
|
||||
svsession->scsi_dev_state[i].dev = state->dev;
|
||||
svsession->scsi_dev_state[i].status = state->status;
|
||||
rc = spdk_scsi_dev_allocate_io_channels(state->dev);
|
||||
@ -1394,6 +1394,8 @@ destroy_session_poller_cb(void *arg)
|
||||
}
|
||||
|
||||
for (i = 0; i < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS; i++) {
|
||||
enum spdk_scsi_dev_vhost_status prev_status;
|
||||
|
||||
state = &svsession->scsi_dev_state[i];
|
||||
if (state->dev == NULL) {
|
||||
continue;
|
||||
@ -1401,9 +1403,11 @@ destroy_session_poller_cb(void *arg)
|
||||
|
||||
spdk_scsi_dev_free_io_channels(state->dev);
|
||||
|
||||
if (state->status == VHOST_SCSI_DEV_REMOVING) {
|
||||
state->dev = NULL;
|
||||
state->status = VHOST_SCSI_DEV_REMOVED;
|
||||
prev_status = state->status;
|
||||
state->status = VHOST_SCSI_DEV_EMPTY;
|
||||
state->dev = NULL;
|
||||
|
||||
if (prev_status == VHOST_SCSI_DEV_REMOVING) {
|
||||
/* try to detach it globally */
|
||||
spdk_vhost_dev_foreach_session(vsession->vdev,
|
||||
spdk_vhost_scsi_session_process_removed,
|
||||
|
Loading…
Reference in New Issue
Block a user