ocf: adapt new asynchronous OCF API

Adapt to new async API which was changed recently
This is a neccessery step to be able to implement persistent metadata support

OCF submodule was updated to get new API

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

(cherry picked from commit f51d3b6dd7)
Change-Id: I6bf9941ab0557981235c5be27686594a1b8ac3a0
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457253
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-03-22 16:53:49 +00:00 committed by Darek Stojaczyk
parent 3f6c9a4e0f
commit 301d6e7c78
2 changed files with 53 additions and 33 deletions

View File

@ -181,6 +181,15 @@ close_core_bdev(struct vbdev_ocf *vbdev)
vbdev_ocf_mngt_continue(vbdev, 0);
}
static void
remove_core_cmpl(void *priv, int error)
{
struct vbdev_ocf *vbdev = priv;
ocf_mngt_cache_unlock(vbdev->ocf_cache);
vbdev_ocf_mngt_continue(vbdev, error);
}
/* Try to lock cache, then remove core */
static void
remove_core_poll(struct vbdev_ocf *vbdev)
@ -192,11 +201,8 @@ remove_core_poll(struct vbdev_ocf *vbdev)
return;
}
rc = ocf_mngt_cache_remove_core(vbdev->ocf_core);
ocf_mngt_cache_unlock(vbdev->ocf_cache);
vbdev_ocf_mngt_continue(vbdev, rc);
vbdev_ocf_mngt_poll(vbdev, NULL);
ocf_mngt_cache_remove_core(vbdev->ocf_core, remove_core_cmpl, vbdev);
}
/* Detach core base */
@ -232,12 +238,19 @@ detach_cache(struct vbdev_ocf *vbdev)
vbdev_ocf_mngt_continue(vbdev, 0);
}
static void
stop_vbdev_cmpl(ocf_cache_t cache, void *priv, int error)
{
struct vbdev_ocf *vbdev = priv;
ocf_mngt_cache_unlock(cache);
vbdev_ocf_mngt_continue(vbdev, error);
}
/* Try to lock cache, then stop it */
static void
stop_vbdev_poll(struct vbdev_ocf *vbdev)
{
int rc;
if (!ocf_cache_is_running(vbdev->ocf_cache)) {
vbdev_ocf_mngt_continue(vbdev, 0);
return;
@ -255,14 +268,8 @@ stop_vbdev_poll(struct vbdev_ocf *vbdev)
return;
}
rc = ocf_mngt_cache_stop(vbdev->ocf_cache);
if (rc) {
SPDK_ERRLOG("Could not stop cache for '%s'\n", vbdev->name);
}
ocf_mngt_cache_unlock(vbdev->ocf_cache);
vbdev_ocf_mngt_continue(vbdev, rc);
vbdev_ocf_mngt_poll(vbdev, NULL);
ocf_mngt_cache_stop(vbdev->ocf_cache, stop_vbdev_cmpl, vbdev);
}
/* Stop OCF cache object
@ -768,26 +775,33 @@ finish_register(struct vbdev_ocf *vbdev)
vbdev_ocf_mngt_continue(vbdev, result);
}
static void
add_core_cmpl(ocf_cache_t cache, ocf_core_t core, void *priv, int error)
{
struct vbdev_ocf *vbdev = priv;
ocf_mngt_cache_unlock(cache);
if (error) {
SPDK_ERRLOG("Failed to add core device to cache instance\n");
} else {
vbdev->ocf_core = core;
vbdev->core.id = ocf_core_get_id(core);
}
vbdev_ocf_mngt_continue(vbdev, error);
}
/* Try to lock cache, then add core */
static void
add_core_poll(struct vbdev_ocf *vbdev)
{
int rc;
if (ocf_mngt_cache_trylock(vbdev->ocf_cache)) {
return;
}
rc = ocf_mngt_cache_add_core(vbdev->ocf_cache, &vbdev->ocf_core, &vbdev->cfg.core);
if (rc) {
SPDK_ERRLOG("Failed to add core device to cache instance\n");
} else {
vbdev->core.id = ocf_core_get_id(vbdev->ocf_core);
}
ocf_mngt_cache_unlock(vbdev->ocf_cache);
vbdev_ocf_mngt_continue(vbdev, rc);
vbdev_ocf_mngt_poll(vbdev, NULL);
ocf_mngt_cache_add_core(vbdev->ocf_cache, &vbdev->cfg.core, add_core_cmpl, vbdev);
}
/* Add core for existing OCF cache instance */
@ -797,7 +811,16 @@ add_core(struct vbdev_ocf *vbdev)
vbdev_ocf_mngt_poll(vbdev, add_core_poll);
}
/* Start OCF cache, attach cache device */
static void
start_cache_cmpl(ocf_cache_t cache, void *priv, int error)
{
struct vbdev_ocf *vbdev = priv;
ocf_mngt_cache_unlock(cache);
vbdev_ocf_mngt_continue(vbdev, error);
}
/* Start OCF cache, attach caching device */
static void
start_cache(struct vbdev_ocf *vbdev)
{
@ -829,10 +852,7 @@ start_cache(struct vbdev_ocf *vbdev)
vbdev->cache.id = ocf_cache_get_id(vbdev->ocf_cache);
rc = ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device);
ocf_mngt_cache_unlock(vbdev->ocf_cache);
vbdev_ocf_mngt_continue(vbdev, rc);
ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
}
/* Procedures called during register operation */

2
ocf

@ -1 +1 @@
Subproject commit bd19b9c12f924b3bfd5d228c3dc4a16d807595d0
Subproject commit 56f4d34920ceeb650cdbc7362fc6a775f61a19a3