Merge pull request #228 from mmichal10/ctx-destory-callback

Additional volume type ops: deinit.
This commit is contained in:
Robert Bałdyga 2019-08-05 13:10:08 +02:00 committed by GitHub
commit dddb44574c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 8 deletions

View File

@ -141,6 +141,9 @@ struct ocf_volume_properties {
struct ocf_io_ops io_ops;
/*!< 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,
.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);
}

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);
void ocf_core_volume_type_deinit(ocf_ctx_t ctx);
#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);
}
/*
*
*/
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);

View File

@ -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);
}

View File

@ -66,6 +66,7 @@ class VolumeProperties(Structure):
("_caps", VolumeCaps),
("_ops", VolumeOps),
("_io_ops", IoOps),
("_deinit", c_char_p),
]
@ -125,6 +126,7 @@ class Volume(Structure):
_io_ops=IoOps(
_set_data=cls._io_set_data, _get_data=cls._io_get_data
),
_deinit=0,
)
return cls.props