Commit 2470278c authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Changpeng Liu
Browse files

vhost/scsi: do not fail scsi_dev_add_tgt() if hotplug is not supported



Print an error message instead. The driver can still do
a manual rescan if it wants to see the new SCSI target.

Change-Id: Ieb76ada8625bf00ad068a791b860e4b08ad5cb83
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/417268


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 5aa5f3dc
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -202,9 +202,9 @@ int spdk_vhost_scsi_dev_construct(const char *name, const char *cpumask);
 * LUN0 associated with given SPDK bdev. Currently only one LUN per
 * device is supported.
 *
 * 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 vhost SCSI device has an active connection and has negotiated
 * \c VIRTIO_SCSI_F_HOTPLUG feature,  the new SCSI target should be
 * automatically detected by the other side.
 *
 * \param vdev vhost SCSI device.
 * \param scsi_tgt_num slot to attach to.
+17 −10
Original line number Diff line number Diff line
@@ -823,11 +823,6 @@ spdk_vhost_scsi_dev_add_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tgt_num,
		return -EINVAL;
	}

	if (vdev->lcore != -1 && !spdk_vhost_dev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
		SPDK_ERRLOG("Controller %s is in use and hotplug is not supported\n", vdev->name);
		return -ENOTSUP;
	}

	if (svdev->scsi_dev[scsi_tgt_num] != NULL) {
		SPDK_ERRLOG("Controller %s target %u already occupied\n", vdev->name, scsi_tgt_num);
		return -EEXIST;
@@ -852,13 +847,25 @@ spdk_vhost_scsi_dev_add_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tgt_num,
	}
	spdk_scsi_dev_add_port(svdev->scsi_dev[scsi_tgt_num], 0, "vhost");

	if (vdev->lcore != -1) {
	SPDK_INFOLOG(SPDK_LOG_VHOST, "Controller %s: defined target '%s' using bdev '%s'\n",
		     vdev->name, target_name, bdev_name);

	if (vdev->lcore == -1) {
		/* All done. */
		return 0;
	}

	spdk_scsi_dev_allocate_io_channels(svdev->scsi_dev[scsi_tgt_num]);
		eventq_enqueue(svdev, scsi_tgt_num, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_RESCAN);

	if (spdk_vhost_dev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
		eventq_enqueue(svdev, scsi_tgt_num, VIRTIO_SCSI_T_TRANSPORT_RESET,
			       VIRTIO_SCSI_EVT_RESET_RESCAN);
	} else {
		SPDK_NOTICELOG("Device %s does not support hotplug. "
			       "Please restart the driver or perform a rescan.\n",
			       vdev->name);
	}

	SPDK_INFOLOG(SPDK_LOG_VHOST, "Controller %s: defined target '%s' using bdev '%s'\n",
		     vdev->name, target_name, bdev_name);
	return 0;
}