diff --git a/inc/ocf_volume.h b/inc/ocf_volume.h index 3ed36b7..bcc703f 100644 --- a/inc/ocf_volume.h +++ b/inc/ocf_volume.h @@ -141,6 +141,9 @@ struct ocf_volume_properties { struct ocf_io_ops io_ops; /*!< IO operations */ + + void (*deinit)(void); + /*!< Deinitialize volume type */ }; /** diff --git a/src/ocf_core.c b/src/ocf_core.c index f337b69..c346aee 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -532,6 +532,7 @@ const struct ocf_volume_properties ocf_core_volume_properties = { .set_data = ocf_core_io_set_data, .get_data = ocf_core_io_get_data, }, + .deinit = NULL, }; static int ocf_core_io_allocator_init(ocf_io_allocator_t allocator, @@ -584,8 +585,3 @@ int ocf_core_volume_type_init(ocf_ctx_t ctx) &ocf_core_volume_properties, &ocf_core_volume_extended); } - -void ocf_core_volume_type_deinit(ocf_ctx_t ctx) -{ - ocf_ctx_unregister_volume_type(ctx, 0); -} diff --git a/src/ocf_core_priv.h b/src/ocf_core_priv.h index 6378ce2..c158cd7 100644 --- a/src/ocf_core_priv.h +++ b/src/ocf_core_priv.h @@ -95,6 +95,4 @@ bool ocf_core_is_valid(ocf_cache_t cache, ocf_core_id_t id); int ocf_core_volume_type_init(ocf_ctx_t ctx); -void ocf_core_volume_type_deinit(ocf_ctx_t ctx); - #endif /* __OCF_CORE_PRIV_H__ */ diff --git a/src/ocf_ctx.c b/src/ocf_ctx.c index 08914e7..16c123c 100644 --- a/src/ocf_ctx.c +++ b/src/ocf_ctx.c @@ -206,6 +206,17 @@ void ocf_ctx_get(ocf_ctx_t ctx) env_atomic_inc(&ctx->ref_count); } +/* + * + */ +static void ocf_ctx_unregister_volume_types(ocf_ctx_t ctx) +{ + int id; + + for (id = 0; id < OCF_VOLUME_TYPE_MAX; id++) + ocf_ctx_unregister_volume_type(ctx, id); +} + /* * */ @@ -221,7 +232,7 @@ void ocf_ctx_put(ocf_ctx_t ctx) env_rmutex_unlock(&ctx->lock); ocf_mngt_core_pool_deinit(ctx); - ocf_core_volume_type_deinit(ctx); + ocf_ctx_unregister_volume_types(ctx); ocf_req_allocator_deinit(ctx); ocf_logger_close(&ctx->logger); env_free(ctx); diff --git a/src/ocf_volume.c b/src/ocf_volume.c index 404b8c1..7793b33 100644 --- a/src/ocf_volume.c +++ b/src/ocf_volume.c @@ -59,6 +59,9 @@ err: void ocf_volume_type_deinit(struct ocf_volume_type *type) { + if (type->properties->deinit) + type->properties->deinit(); + ocf_io_allocator_deinit(&type->allocator); env_free(type); }