Deinitialize volume types in ocf internally.

Adapter can provide ops for data type deinitialization, if any additional
operations are required on deinitialization procedure.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2019-08-02 07:33:16 -04:00
parent 9652fb73f1
commit 80f82cab2b
5 changed files with 19 additions and 8 deletions

View File

@ -141,6 +141,9 @@ struct ocf_volume_properties {
struct ocf_io_ops io_ops; struct ocf_io_ops io_ops;
/*!< IO operations */ /*!< IO operations */
void (*deinit)(void);
/*!< Deinitialize volume type */
}; };
/** /**

View File

@ -532,6 +532,7 @@ const struct ocf_volume_properties ocf_core_volume_properties = {
.set_data = ocf_core_io_set_data, .set_data = ocf_core_io_set_data,
.get_data = ocf_core_io_get_data, .get_data = ocf_core_io_get_data,
}, },
.deinit = NULL,
}; };
static int ocf_core_io_allocator_init(ocf_io_allocator_t allocator, 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_properties,
&ocf_core_volume_extended); &ocf_core_volume_extended);
} }
void ocf_core_volume_type_deinit(ocf_ctx_t ctx)
{
ocf_ctx_unregister_volume_type(ctx, 0);
}

View File

@ -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); 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__ */ #endif /* __OCF_CORE_PRIV_H__ */

View File

@ -206,6 +206,17 @@ void ocf_ctx_get(ocf_ctx_t ctx)
env_atomic_inc(&ctx->ref_count); 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); env_rmutex_unlock(&ctx->lock);
ocf_mngt_core_pool_deinit(ctx); ocf_mngt_core_pool_deinit(ctx);
ocf_core_volume_type_deinit(ctx); ocf_ctx_unregister_volume_types(ctx);
ocf_req_allocator_deinit(ctx); ocf_req_allocator_deinit(ctx);
ocf_logger_close(&ctx->logger); ocf_logger_close(&ctx->logger);
env_free(ctx); env_free(ctx);

View File

@ -59,6 +59,9 @@ err:
void ocf_volume_type_deinit(struct ocf_volume_type *type) void ocf_volume_type_deinit(struct ocf_volume_type *type)
{ {
if (type->properties->deinit)
type->properties->deinit();
ocf_io_allocator_deinit(&type->allocator); ocf_io_allocator_deinit(&type->allocator);
env_free(type); env_free(type);
} }