Commit eb58ad53 authored by Vitaliy Mysak's avatar Vitaliy Mysak Committed by Jim Harris
Browse files

ocf: create management channel



Create new management channel and handle sharing between vbdevs.
This channel is going to be used for management operations
 that produce IOs (such as flush) and also for cleaner.

Change-Id: Ieeed8454a7ab7459c86ac06ec6c0ece038bc928e
Signed-off-by: default avatarVitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455272


Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 920bb2b3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#define VBDEV_OCF_CTX_H

#include <ocf/ocf.h>
#include "spdk/thread.h"

extern ocf_ctx_t vbdev_ocf_ctx;

@@ -45,6 +46,7 @@ extern ocf_ctx_t vbdev_ocf_ctx;
/* Context of cache instance */
struct vbdev_ocf_cache_ctx {
	ocf_queue_t                  mngt_queue;
	struct spdk_io_channel      *management_channel;
	pthread_mutex_t              lock;
	env_atomic                   refcnt;
};
+10 −0
Original line number Diff line number Diff line
@@ -163,6 +163,10 @@ remove_base_bdev(struct vbdev_ocf_base *base)
		spdk_bdev_module_release_bdev(base->bdev);
		spdk_bdev_close(base->desc);
		base->attached = false;

		if (base->management_channel && !base->is_cache) {
			spdk_put_io_channel(base->management_channel);
		}
	}
}

@@ -246,6 +250,7 @@ stop_vbdev_cmpl(ocf_cache_t cache, void *priv, int error)

	vbdev_ocf_queue_put(vbdev->cache_ctx->mngt_queue);
	ocf_mngt_cache_unlock(cache);
	spdk_put_io_channel(vbdev->cache.management_channel);

	vbdev_ocf_mngt_continue(vbdev, error);
}
@@ -796,6 +801,8 @@ finish_register(struct vbdev_ocf *vbdev)
{
	int result;

	vbdev->cache.management_channel = vbdev->cache_ctx->management_channel;

	/* Copy properties of the base bdev */
	vbdev->exp_bdev.blocklen = vbdev->core.bdev->blocklen;
	vbdev->exp_bdev.write_cache = vbdev->core.bdev->write_cache;
@@ -836,6 +843,7 @@ add_core_cmpl(ocf_cache_t cache, ocf_core_t core, void *priv, int error)
		vbdev->core.id  = ocf_core_get_id(core);
	}

	vbdev->core.management_channel = spdk_bdev_get_io_channel(vbdev->core.desc);
	vbdev_ocf_mngt_continue(vbdev, error);
}

@@ -864,6 +872,8 @@ start_cache_cmpl(ocf_cache_t cache, void *priv, int error)
	struct vbdev_ocf *vbdev = priv;

	ocf_mngt_cache_unlock(cache);
	vbdev->cache_ctx->management_channel = spdk_bdev_get_io_channel(vbdev->cache.desc);

	vbdev_ocf_mngt_continue(vbdev, error);
}

+3 −0
Original line number Diff line number Diff line
@@ -130,6 +130,9 @@ struct vbdev_ocf_base {
	/* True if SPDK bdev has been claimed and opened for writing */
	bool                         attached;

	/* Channel for cleaner operations */
	struct spdk_io_channel      *management_channel;

	/* Reference to main vbdev */
	struct vbdev_ocf            *parent;
};
+10 −0
Original line number Diff line number Diff line
@@ -212,6 +212,8 @@ prepare_submit(struct ocf_io *io)
	struct vbdev_ocf_qcxt *qctx;
	struct vbdev_ocf_base *base;
	ocf_queue_t q = io->io_queue;
	ocf_cache_t cache;
	struct vbdev_ocf_cache_ctx *cctx;
	int rc = 0;

	io_ctx->rq_cnt++;
@@ -232,6 +234,14 @@ prepare_submit(struct ocf_io *io)
		return 0;
	}

	cache = ocf_queue_get_cache(q);
	cctx = ocf_cache_get_priv(cache);

	if (q == cctx->mngt_queue) {
		io_ctx->ch = base->management_channel;
		return 0;
	}

	qctx = ocf_queue_get_priv(q);
	if (qctx == NULL) {
		return -EFAULT;