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.

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455272 (master)

(cherry picked from commit eb58ad5379)
Change-Id: Ieeed8454a7ab7459c86ac06ec6c0ece038bc928e
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457257
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Vitaliy Mysak 2019-05-21 21:50:29 +00:00 committed by Darek Stojaczyk
parent f3ff9870d8
commit 6450c84d9a
4 changed files with 25 additions and 0 deletions

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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;