lib/bdev/ocf: error handling in register path

This patch introduces error handling in register path, in case of
error in the middle of chain we will call vbdev_ocf_mngt_stop with
appropriate rollback path.

Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com>
Change-Id: I78e5796b7eda2fe0848d5533cdea283b17397b61
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468472
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Marcin Dziegielewski 2019-10-16 15:50:26 +02:00 committed by Jim Harris
parent 790669cc46
commit 59a296465d

View File

@ -876,6 +876,12 @@ const struct ocf_queue_ops mngt_queue_ops = {
.stop = vbdev_ocf_ctx_mngt_queue_stop,
};
static void
clear_starting_indicator_vbdev(struct vbdev_ocf *vbdev)
{
vbdev->state.starting = false;
}
/* Create exported spdk object */
static void
finish_register(struct vbdev_ocf *vbdev)
@ -900,7 +906,11 @@ finish_register(struct vbdev_ocf *vbdev)
sizeof(struct vbdev_ocf_qcxt), vbdev->name);
result = spdk_bdev_register(&vbdev->exp_bdev);
if (result) {
SPDK_ERRLOG("Could not register exposed bdev\n");
SPDK_ERRLOG("Could not register exposed bdev %s\n",
vbdev->name);
clear_starting_indicator_vbdev(vbdev);
vbdev_ocf_mngt_stop(vbdev, unregister_path_dirty, result);
return;
} else {
vbdev->state.started = true;
}
@ -916,7 +926,11 @@ add_core_cmpl(ocf_cache_t cache, ocf_core_t core, void *priv, int error)
ocf_mngt_cache_unlock(cache);
if (error) {
SPDK_ERRLOG("Failed to add core device to cache instance\n");
SPDK_ERRLOG("Error %d, failed to add core device to cache instance %s,"
"starting rollback\n", error, vbdev->name);
clear_starting_indicator_vbdev(vbdev);
vbdev_ocf_mngt_stop(vbdev, unregister_path_dirty, error);
return;
} else {
vbdev->ocf_core = core;
vbdev->core.id = ocf_core_get_id(core);
@ -951,6 +965,14 @@ start_cache_cmpl(ocf_cache_t cache, void *priv, int error)
ocf_mngt_cache_unlock(cache);
if (error) {
SPDK_ERRLOG("Error %d during start cache %s, starting rollback\n",
error, vbdev->name);
clear_starting_indicator_vbdev(vbdev);
vbdev_ocf_mngt_stop(vbdev, unregister_path_dirty, error);
return;
}
vbdev_ocf_mngt_continue(vbdev, error);
}
@ -1004,7 +1026,8 @@ start_cache(struct vbdev_ocf *vbdev)
vbdev->cache_ctx = calloc(1, sizeof(struct vbdev_ocf_cache_ctx));
if (vbdev->cache_ctx == NULL) {
vbdev_ocf_mngt_stop(vbdev, NULL, -ENOMEM);
clear_starting_indicator_vbdev(vbdev);
vbdev_ocf_mngt_stop(vbdev, unregister_path_dirty, -ENOMEM);
return;
}
@ -1013,8 +1036,8 @@ start_cache(struct vbdev_ocf *vbdev)
rc = ocf_mngt_cache_start(vbdev_ocf_ctx, &vbdev->ocf_cache, &vbdev->cfg.cache);
if (rc) {
vbdev_ocf_cache_ctx_put(vbdev->cache_ctx);
vbdev_ocf_mngt_stop(vbdev, NULL, rc);
clear_starting_indicator_vbdev(vbdev);
vbdev_ocf_mngt_stop(vbdev, unregister_path_dirty, rc);
return;
}
@ -1024,8 +1047,8 @@ start_cache(struct vbdev_ocf *vbdev)
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_ocf_mngt_stop(vbdev, NULL, rc);
clear_starting_indicator_vbdev(vbdev);
vbdev_ocf_mngt_stop(vbdev, unregister_path_dirty, rc);
return;
}