diff --git a/lib/bdev/ocf/vbdev_ocf.c b/lib/bdev/ocf/vbdev_ocf.c index 64edc1480..394c5ee57 100644 --- a/lib/bdev/ocf/vbdev_ocf.c +++ b/lib/bdev/ocf/vbdev_ocf.c @@ -1064,7 +1064,8 @@ static int init_vbdev(const char *vbdev_name, const char *cache_mode_name, const char *cache_name, - const char *core_name) + const char *core_name, + bool loadq) { struct vbdev_ocf *vbdev; int rc = 0; @@ -1113,6 +1114,7 @@ init_vbdev(const char *vbdev_name, goto error_mem; } + vbdev->cfg.loadq = loadq; init_vbdev_config(vbdev); TAILQ_INSERT_TAIL(&g_ocf_vbdev_head, vbdev, tailq); return rc; @@ -1180,7 +1182,7 @@ vbdev_ocf_init(void) continue; } - status = init_vbdev(vbdev_name, modename, cache_name, core_name); + status = init_vbdev(vbdev_name, modename, cache_name, core_name, false); if (status) { SPDK_ERRLOG("Config initialization failed with code: %d\n", status); } @@ -1304,6 +1306,7 @@ vbdev_ocf_construct(const char *vbdev_name, const char *cache_mode_name, const char *cache_name, const char *core_name, + bool loadq, void (*cb)(int, struct vbdev_ocf *, void *), void *cb_arg) { @@ -1312,7 +1315,7 @@ vbdev_ocf_construct(const char *vbdev_name, struct spdk_bdev *core_bdev = spdk_bdev_get_by_name(core_name); struct vbdev_ocf *vbdev; - rc = init_vbdev(vbdev_name, cache_mode_name, cache_name, core_name); + rc = init_vbdev(vbdev_name, cache_mode_name, cache_name, core_name, loadq); if (rc) { cb(rc, NULL, cb_arg); return; diff --git a/lib/bdev/ocf/vbdev_ocf.h b/lib/bdev/ocf/vbdev_ocf.h index e4dbf06b8..16ab26e92 100644 --- a/lib/bdev/ocf/vbdev_ocf.h +++ b/lib/bdev/ocf/vbdev_ocf.h @@ -81,6 +81,10 @@ struct vbdev_ocf_config { /* Core initial config */ struct ocf_mngt_core_config core; + + /* Load flag, if set to true, then we will try load cache instance from disk, + * otherwise we will create new cache on that disk */ + bool loadq; }; /* Types for management operations */ @@ -174,6 +178,7 @@ void vbdev_ocf_construct( const char *cache_mode_name, const char *cache_name, const char *core_name, + bool loadq, void (*cb)(int, struct vbdev_ocf *, void *), void *cb_arg); diff --git a/lib/bdev/ocf/vbdev_ocf_rpc.c b/lib/bdev/ocf/vbdev_ocf_rpc.c index 7430fbe8c..0667d9e37 100644 --- a/lib/bdev/ocf/vbdev_ocf_rpc.c +++ b/lib/bdev/ocf/vbdev_ocf_rpc.c @@ -98,7 +98,7 @@ spdk_rpc_construct_ocf_bdev(struct spdk_jsonrpc_request *request, return; } - vbdev_ocf_construct(req.name, req.mode, req.cache_bdev_name, req.core_bdev_name, + vbdev_ocf_construct(req.name, req.mode, req.cache_bdev_name, req.core_bdev_name, false, construct_cb, request); free_rpc_construct_ocf_bdev(&req); }