Commit 4f95fd7b authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

lib/vhost_blk: get bdev io_channels via vhost_blk functions



This patch adds vhost_blk_[get/put]_io_channel() to be used
by virtio_blk transports.

Functions related to vhost_user sessions were modified to
use it.

dummy_io_channel reference is managed at the vhost_blk
layer and as such continues to use the spdk_[get/put]_io_channel()
APIs. The description is updated to reflect its not specific to
vhost_user transport.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I6644198da83bfa0210c167e203d3875e96f1e7ea
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11101


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 223f1f14
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -1006,7 +1006,7 @@ _no_bdev_vdev_vq_worker(struct spdk_vhost_virtqueue *vq)
	vhost_session_vq_used_signal(vq);

	if (vsession->task_cnt == 0 && bvsession->io_channel) {
		spdk_put_io_channel(bvsession->io_channel);
		vhost_blk_put_io_channel(bvsession->io_channel);
		bvsession->io_channel = NULL;
	}

@@ -1307,7 +1307,7 @@ vhost_blk_start_cb(struct spdk_vhost_dev *vdev,
	}

	if (bvdev->bdev) {
		bvsession->io_channel = spdk_bdev_get_io_channel(bvdev->bdev_desc);
		bvsession->io_channel = vhost_blk_get_io_channel(vdev);
		if (!bvsession->io_channel) {
			free_task_pool(bvsession);
			SPDK_ERRLOG("%s: I/O channel allocation failed\n", vsession->name);
@@ -1385,7 +1385,7 @@ destroy_session_poller_cb(void *arg)
		     vsession->name, spdk_env_get_current_core());

	if (bvsession->io_channel) {
		spdk_put_io_channel(bvsession->io_channel);
		vhost_blk_put_io_channel(bvsession->io_channel);
		bvsession->io_channel = NULL;
	}

@@ -1610,11 +1610,10 @@ spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_
	}

	/*
	 * When starting qemu with vhost-user-blk multiqueue, the vhost device will
	 * When starting qemu with multiqueue enable, the vhost device will
	 * be started/stopped many times, related to the queues num, as the
	 * vhost-user backend doesn't know the exact number of queues used for this
	 * device. The target have to stop and start the device once got a valid
	 * IO queue.
	 * 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 stoping 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
@@ -1669,5 +1668,19 @@ vhost_blk_destroy(struct spdk_vhost_dev *vdev)
	return 0;
}

struct spdk_io_channel *
vhost_blk_get_io_channel(struct spdk_vhost_dev *vdev)
{
	struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev);

	return spdk_bdev_get_io_channel(bvdev->bdev_desc);
}

void
vhost_blk_put_io_channel(struct spdk_io_channel *ch)
{
	spdk_put_io_channel(ch);
}

SPDK_LOG_REGISTER_COMPONENT(vhost_blk)
SPDK_LOG_REGISTER_COMPONENT(vhost_blk_data)
+3 −0
Original line number Diff line number Diff line
@@ -509,6 +509,9 @@ int vhost_get_negotiated_features(int vid, uint64_t *negotiated_features);

int remove_vhost_controller(struct spdk_vhost_dev *vdev);

struct spdk_io_channel *vhost_blk_get_io_channel(struct spdk_vhost_dev *vdev);
void vhost_blk_put_io_channel(struct spdk_io_channel *ch);

/* Function calls from vhost.c to rte_vhost_user.c,
 * shall removed once virtio transport abstraction is complete. */
int vhost_user_session_set_coalescing(struct spdk_vhost_dev *dev,