Commit 82b8dd90 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/compress: A few cleanups for create/delete I/O channel callback



In comp_bdev_ch_create_cb(), list head comp_bdev->pending_comp_ios and
comp_bdev->queued_comp_ops should be initialized only when
comp_bdev->ch_count is 0. Besides, extra brackets for if condition
can be removed.

In _comp_bdev_ch_destroy_cb(), comp_bdev->ch_count is not necessary
to check if it is 0 again.

Fix these.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I71786423a77819c41419c51a4cfcad71b85a0b39
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1444


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 6a98b18f
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -1393,22 +1393,22 @@ comp_bdev_ch_create_cb(void *io_device, void *ctx_buf)
	struct vbdev_compress *comp_bdev = io_device;
	struct comp_device_qp *device_qp;

	/* Now set the reduce channel if it's not already set. */
	pthread_mutex_lock(&comp_bdev->reduce_lock);
	if (comp_bdev->ch_count == 0) {
		/* We use this queue to track outstanding IO in our layer. */
		TAILQ_INIT(&comp_bdev->pending_comp_ios);

		/* We use this to queue up compression operations as needed. */
		TAILQ_INIT(&comp_bdev->queued_comp_ops);

	/* Now set the reduce channel if it's not already set. */
	pthread_mutex_lock(&comp_bdev->reduce_lock);
	if (comp_bdev->ch_count == 0) {
		comp_bdev->base_ch = spdk_bdev_get_io_channel(comp_bdev->base_desc);
		comp_bdev->reduce_thread = spdk_get_thread();
		comp_bdev->poller = spdk_poller_register(comp_dev_poller, comp_bdev, 0);
		/* Now assign a q pair */
		pthread_mutex_lock(&g_comp_device_qp_lock);
		TAILQ_FOREACH(device_qp, &g_comp_device_qp, link) {
			if ((strcmp(device_qp->device->cdev_info.driver_name, comp_bdev->drv_name) == 0)) {
			if (strcmp(device_qp->device->cdev_info.driver_name, comp_bdev->drv_name) == 0) {
				if (device_qp->thread == spdk_get_thread()) {
					comp_bdev->device_qp = device_qp;
					break;
@@ -1453,9 +1453,7 @@ _comp_bdev_ch_destroy_cb(void *arg)
	struct vbdev_compress *comp_bdev = arg;

	pthread_mutex_lock(&comp_bdev->reduce_lock);
	if (comp_bdev->ch_count == 0) {
	_channel_cleanup(comp_bdev);
	}
	pthread_mutex_unlock(&comp_bdev->reduce_lock);
}