ocf: implement mngt_queue for asynchronous management
Implement management queue for asynchronous management that is provided in new OCF API. This is a neccessery step to be able to implement metadata support. OCF submodule was updated to get management queue functionality It has to be done in this patch because OCF module will not work otherwise. Change-Id: Id19c2e5bd6a5d26fee41752b62720e408dc082e8 Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448619 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
244d6e3daa
commit
54eeeac6e0
@ -44,6 +44,7 @@ extern ocf_ctx_t vbdev_ocf_ctx;
|
||||
|
||||
/* Context of cache instance */
|
||||
struct vbdev_ocf_cache_ctx {
|
||||
ocf_queue_t mngt_queue;
|
||||
pthread_mutex_t lock;
|
||||
env_atomic refcnt;
|
||||
};
|
||||
|
@ -244,7 +244,9 @@ stop_vbdev_cmpl(ocf_cache_t cache, void *priv, int error)
|
||||
{
|
||||
struct vbdev_ocf *vbdev = priv;
|
||||
|
||||
vbdev_ocf_queue_put(vbdev->cache_ctx->mngt_queue);
|
||||
ocf_mngt_cache_unlock(cache);
|
||||
|
||||
vbdev_ocf_mngt_continue(vbdev, error);
|
||||
}
|
||||
|
||||
@ -653,7 +655,8 @@ static struct spdk_bdev_fn_table cache_dev_fn_table = {
|
||||
|
||||
/* Poller function for the OCF queue
|
||||
* We execute OCF requests here synchronously */
|
||||
static int queue_poll(void *opaque)
|
||||
static int
|
||||
queue_poll(void *opaque)
|
||||
{
|
||||
struct vbdev_ocf_qcxt *qctx = opaque;
|
||||
uint32_t iono = ocf_queue_pending_io(qctx->queue);
|
||||
@ -745,6 +748,49 @@ io_device_destroy_cb(void *io_device, void *ctx_buf)
|
||||
vbdev_ocf_queue_put(qctx->queue);
|
||||
}
|
||||
|
||||
/* OCF management queue deinitialization */
|
||||
static void
|
||||
vbdev_ocf_ctx_mngt_queue_stop(ocf_queue_t q)
|
||||
{
|
||||
struct spdk_poller *poller = ocf_queue_get_priv(q);
|
||||
|
||||
if (poller) {
|
||||
spdk_poller_unregister(&poller);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
mngt_queue_poll(void *opaque)
|
||||
{
|
||||
ocf_queue_t q = opaque;
|
||||
uint32_t iono = ocf_queue_pending_io(q);
|
||||
int i, max = spdk_min(32, iono);
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
ocf_queue_run_single(q);
|
||||
}
|
||||
|
||||
if (iono > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
vbdev_ocf_ctx_mngt_queue_kick(ocf_queue_t q)
|
||||
{
|
||||
}
|
||||
|
||||
/* Queue ops is an interface for running queue thread
|
||||
* stop() operation in called just before queue gets destroyed */
|
||||
const struct ocf_queue_ops mngt_queue_ops = {
|
||||
.kick_sync = NULL,
|
||||
.kick = vbdev_ocf_ctx_mngt_queue_kick,
|
||||
.stop = vbdev_ocf_ctx_mngt_queue_stop,
|
||||
};
|
||||
|
||||
/* Create exported spdk object */
|
||||
static void
|
||||
finish_register(struct vbdev_ocf *vbdev)
|
||||
{
|
||||
@ -821,6 +867,30 @@ start_cache_cmpl(ocf_cache_t cache, void *priv, int error)
|
||||
vbdev_ocf_mngt_continue(vbdev, error);
|
||||
}
|
||||
|
||||
static int
|
||||
create_management_queue(struct vbdev_ocf *vbdev)
|
||||
{
|
||||
struct spdk_poller *mngt_poller;
|
||||
int rc;
|
||||
|
||||
rc = vbdev_ocf_queue_create(vbdev->ocf_cache, &vbdev->cache_ctx->mngt_queue, &mngt_queue_ops);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Unable to create mngt_queue: %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
mngt_poller = spdk_poller_register(mngt_queue_poll, vbdev->cache_ctx->mngt_queue, 100);
|
||||
if (mngt_poller == NULL) {
|
||||
SPDK_ERRLOG("Unable to initiate mngt request: %s", spdk_strerror(ENOMEM));
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ocf_queue_set_priv(vbdev->cache_ctx->mngt_queue, mngt_poller);
|
||||
ocf_mngt_cache_set_mngt_queue(vbdev->ocf_cache, vbdev->cache_ctx->mngt_queue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Start OCF cache, attach caching device */
|
||||
static void
|
||||
start_cache(struct vbdev_ocf *vbdev)
|
||||
@ -867,6 +937,15 @@ start_cache(struct vbdev_ocf *vbdev)
|
||||
vbdev->cache.id = ocf_cache_get_id(vbdev->ocf_cache);
|
||||
ocf_cache_set_priv(vbdev->ocf_cache, vbdev->cache_ctx);
|
||||
|
||||
rc = create_management_queue(vbdev);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Unable to create mngt_queue: %d\n", rc);
|
||||
vbdev_ocf_cache_ctx_put(vbdev->cache_ctx);
|
||||
vbdev->mngt_ctx.status = rc;
|
||||
vbdev_ocf_mngt_stop(vbdev);
|
||||
return;
|
||||
}
|
||||
|
||||
ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
|
||||
}
|
||||
|
||||
|
2
ocf
2
ocf
@ -1 +1 @@
|
||||
Subproject commit 56f4d34920ceeb650cdbc7362fc6a775f61a19a3
|
||||
Subproject commit 08a5b9d2a4dcc894abb88d90117858237c3a39a1
|
Loading…
Reference in New Issue
Block a user