Commit 87138323 authored by Changpeng Liu's avatar Changpeng Liu Committed by Tomasz Zawadzki
Browse files

lib/vhost-blk: remove the dummy bdev channel



After commit 23baa676, we don't start/stop the vhost
device based on number of queues, so this workaround
to use a dummy channel as a reference of bdev creation
could be removed.

Fix issue #3060.

Change-Id: I0a137fc61f20dc4a0476c4f47b32a6f52de07eab
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19300


Reviewed-by: default avatarJim Harris <jim.harris@gmail.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 9be487cf
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -57,8 +57,6 @@ struct spdk_vhost_blk_dev {
	struct spdk_bdev_desc *bdev_desc;
	const struct spdk_virtio_blk_transport_ops *ops;

	/* dummy_io_channel is used to hold a bdev reference */
	struct spdk_io_channel *dummy_io_channel;
	bool readonly;
};

@@ -1158,7 +1156,6 @@ bdev_event_cpl_cb(struct spdk_vhost_dev *vdev, void *ctx)
		/* All sessions have been notified, time to close the bdev */
		bvdev = to_blk_dev(vdev);
		assert(bvdev != NULL);
		spdk_put_io_channel(bvdev->dummy_io_channel);
		spdk_bdev_close(bvdev->bdev_desc);
		bvdev->bdev_desc = NULL;
		bvdev->bdev = NULL;
@@ -1660,24 +1657,11 @@ spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_
		vdev->virtio_features |= (1ULL << VIRTIO_BLK_F_FLUSH);
	}

	/*
	 * When starting qemu with multiqueue enable, the vhost device will
	 * be started/stopped many times, related to the queues num, as the
	 * exact number of queues used for this device is not known at the time.
	 * The target has to stop and start the device once got a valid IO queue.
	 * When stopping and starting the vhost device, the backend bdev io device
	 * will be deleted and created repeatedly.
	 * Hold a bdev reference so that in the struct spdk_vhost_blk_dev, so that
	 * the io device will not be deleted.
	 */
	bvdev->dummy_io_channel = spdk_bdev_get_io_channel(bvdev->bdev_desc);

	bvdev->bdev = bdev;
	bvdev->readonly = false;
	ret = vhost_dev_register(vdev, name, cpumask, params, &vhost_blk_device_backend,
				 &vhost_blk_user_device_backend);
	if (ret != 0) {
		spdk_put_io_channel(bvdev->dummy_io_channel);
		spdk_bdev_close(bvdev->bdev_desc);
		goto out;
	}
@@ -1713,11 +1697,6 @@ vhost_blk_destroy(struct spdk_vhost_dev *vdev)
		return rc;
	}

	/* if the bdev is removed, don't need call spdk_put_io_channel. */
	if (bvdev->bdev) {
		spdk_put_io_channel(bvdev->dummy_io_channel);
	}

	if (bvdev->bdev_desc) {
		spdk_bdev_close(bvdev->bdev_desc);
		bvdev->bdev_desc = NULL;