ocf: implement cache load path

Implement load path for OCF cache.
During load OCF will read metadata from cache disk and restore its state.

management_channel initialization is moved before cache load/attach part
  because ocf_mngt_cache_load() needs it to read metadata.

This patch is a preparation for persistant metadata support.
Load path is never used yet because loadq flag is always false.

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

(cherry picked from commit 2b1c1e7031)
Change-Id: Iff6c1c52eae7b9f52812a8bd3d5ae6d6facedd60
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457264
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Vitaliy Mysak 2019-05-22 20:45:39 +00:00 committed by Ben Walker
parent 8e0360cffa
commit 398e1b15ac

View File

@ -904,7 +904,6 @@ 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);
}
@ -988,7 +987,14 @@ start_cache(struct vbdev_ocf *vbdev)
return;
}
ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
vbdev->cache_ctx->management_channel = spdk_bdev_get_io_channel(vbdev->cache.desc);
vbdev->cache.management_channel = vbdev->cache_ctx->management_channel;
if (vbdev->cfg.loadq) {
ocf_mngt_cache_load(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
} else {
ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
}
}
/* Procedures called during register operation */
@ -1053,6 +1059,13 @@ init_vbdev_config(struct vbdev_ocf *vbdev)
cfg->device.volume_type = SPDK_OBJECT;
cfg->core.core_id = OCF_CORE_MAX;
if (vbdev->cfg.loadq) {
/* When doing cache_load(), we need to set try_add to true,
* otherwise OCF will interpret this core as new
* instead of the inactive one */
vbdev->cfg.core.try_add = true;
}
cfg->device.uuid.size = strlen(vbdev->cache.name) + 1;
cfg->device.uuid.data = vbdev->cache.name;
cfg->core.uuid.size = strlen(vbdev->core.name) + 1;