Core data object
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
1b0b2597d3
commit
4be6761a18
@ -34,6 +34,15 @@ ocf_cache_t ocf_core_get_cache(ocf_core_t core);
|
|||||||
*/
|
*/
|
||||||
ocf_data_obj_t ocf_core_get_data_object(ocf_core_t core);
|
ocf_data_obj_t ocf_core_get_data_object(ocf_core_t core);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Obtain data object of the core
|
||||||
|
*
|
||||||
|
* @param[in] core Core object
|
||||||
|
*
|
||||||
|
* @retval Front data object
|
||||||
|
*/
|
||||||
|
ocf_data_obj_t ocf_core_get_front_data_object(ocf_core_t core);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get UUID of data object associated with core
|
* @brief Get UUID of data object associated with core
|
||||||
*
|
*
|
||||||
@ -43,7 +52,7 @@ ocf_data_obj_t ocf_core_get_data_object(ocf_core_t core);
|
|||||||
*/
|
*/
|
||||||
static inline const struct ocf_data_obj_uuid *ocf_core_get_uuid(ocf_core_t core)
|
static inline const struct ocf_data_obj_uuid *ocf_core_get_uuid(ocf_core_t core)
|
||||||
{
|
{
|
||||||
return ocf_data_obj_get_uuid(ocf_core_get_data_object(core));
|
return ocf_dobj_get_uuid(ocf_core_get_data_object(core));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,30 +165,29 @@ int ocf_core_get_user_metadata(ocf_core_t core, void *data, size_t size);
|
|||||||
*
|
*
|
||||||
* @retval ocf_io object
|
* @retval ocf_io object
|
||||||
*/
|
*/
|
||||||
struct ocf_io *ocf_new_io(ocf_core_t core);
|
static inline struct ocf_io *ocf_core_new_io(ocf_core_t core)
|
||||||
|
{
|
||||||
|
ocf_data_obj_t obj = ocf_core_get_front_data_object(core);
|
||||||
|
|
||||||
|
return ocf_dobj_new_io(obj);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submit ocf_io
|
* @brief Submit ocf_io
|
||||||
*
|
*
|
||||||
* @param[in] io IO to be submitted
|
* @param[in] io IO to be submitted
|
||||||
* @param[in] mode Cache mode to be enforced
|
* @param[in] mode Cache mode to be enforced
|
||||||
*
|
|
||||||
* @retval 0 Success
|
|
||||||
* @retval Non-zero Fail
|
|
||||||
*/
|
*/
|
||||||
int ocf_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode);
|
void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submit ocf_io
|
* @brief Submit ocf_io
|
||||||
*
|
*
|
||||||
* @param[in] io IO to be submitted
|
* @param[in] io IO to be submitted
|
||||||
*
|
|
||||||
* @retval 0 Success
|
|
||||||
* @retval Non-zero Fail
|
|
||||||
*/
|
*/
|
||||||
static inline int ocf_submit_io(struct ocf_io *io)
|
static inline void ocf_core_submit_io(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
return ocf_submit_io_mode(io, ocf_cache_mode_none);
|
ocf_dobj_submit_io(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,27 +199,27 @@ static inline int ocf_submit_io(struct ocf_io *io)
|
|||||||
* @retval 0 IO has been submitted successfully
|
* @retval 0 IO has been submitted successfully
|
||||||
* @retval Non-zero Fast submit failed. Try to submit IO with ocf_submit_io()
|
* @retval Non-zero Fast submit failed. Try to submit IO with ocf_submit_io()
|
||||||
*/
|
*/
|
||||||
int ocf_submit_io_fast(struct ocf_io *io);
|
int ocf_core_submit_io_fast(struct ocf_io *io);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submit ocf_io with flush command
|
* @brief Submit ocf_io with flush command
|
||||||
*
|
*
|
||||||
* @param[in] io IO to be submitted
|
* @param[in] io IO to be submitted
|
||||||
*
|
|
||||||
* @retval 0 Success
|
|
||||||
* @retval Non-zero Fail
|
|
||||||
*/
|
*/
|
||||||
int ocf_submit_flush(struct ocf_io *io);
|
static inline void ocf_core_submit_flush(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
ocf_dobj_submit_flush(io);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Submit ocf_io with discard command
|
* @brief Submit ocf_io with discard command
|
||||||
*
|
*
|
||||||
* @param[in] io IO to be submitted
|
* @param[in] io IO to be submitted
|
||||||
*
|
|
||||||
* @retval 0 Success
|
|
||||||
* @retval Non-zero Fail
|
|
||||||
*/
|
*/
|
||||||
int ocf_submit_discard(struct ocf_io *io);
|
static inline void ocf_core_submit_discard(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
ocf_dobj_submit_discard(io);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Core visitor function type which is called back when iterating over
|
* @brief Core visitor function type which is called back when iterating over
|
||||||
|
@ -136,6 +136,9 @@ struct ocf_data_obj_properties {
|
|||||||
|
|
||||||
struct ocf_data_obj_ops ops;
|
struct ocf_data_obj_ops ops;
|
||||||
/*!< Data object operations */
|
/*!< Data object operations */
|
||||||
|
|
||||||
|
struct ocf_io_ops io_ops;
|
||||||
|
/*!< IO operations */
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct ocf_data_obj_uuid ocf_str_to_uuid(char *str)
|
static inline struct ocf_data_obj_uuid ocf_str_to_uuid(char *str)
|
||||||
@ -148,15 +151,6 @@ static inline struct ocf_data_obj_uuid ocf_str_to_uuid(char *str)
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get data object type
|
|
||||||
*
|
|
||||||
* @param[in] obj Data object
|
|
||||||
*
|
|
||||||
* @return Data object type
|
|
||||||
*/
|
|
||||||
ocf_data_obj_type_t ocf_data_obj_get_type(ocf_data_obj_t obj);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get private context of data object
|
* @brief Get private context of data object
|
||||||
*
|
*
|
||||||
@ -174,76 +168,12 @@ void *ocf_data_obj_get_priv(ocf_data_obj_t obj);
|
|||||||
*/
|
*/
|
||||||
void ocf_data_obj_set_priv(ocf_data_obj_t obj, void *priv);
|
void ocf_data_obj_set_priv(ocf_data_obj_t obj, void *priv);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get data object UUID
|
|
||||||
*
|
|
||||||
* @param[in] obj Data object
|
|
||||||
*
|
|
||||||
* @return UUID of data object
|
|
||||||
*/
|
|
||||||
const struct ocf_data_obj_uuid *ocf_data_obj_get_uuid(ocf_data_obj_t obj);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get data object length
|
|
||||||
*
|
|
||||||
* @param[in] obj Data object
|
|
||||||
*
|
|
||||||
* @return Length of data object in bytes
|
|
||||||
*/
|
|
||||||
uint64_t ocf_data_obj_get_length(ocf_data_obj_t obj);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get cache handle for given data object
|
|
||||||
*
|
|
||||||
* @param obj data object handle
|
|
||||||
*
|
|
||||||
* @return Handle to cache for which data object belongs to
|
|
||||||
*/
|
|
||||||
ocf_cache_t ocf_data_obj_get_cache(ocf_data_obj_t obj);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize data object
|
|
||||||
*
|
|
||||||
* @param[in] obj data object handle
|
|
||||||
* @param[in] type cache/core object type
|
|
||||||
* @param[in] uuid OCF data object UUID
|
|
||||||
* @param[in] uuid_copy crate copy of uuid data
|
|
||||||
*
|
|
||||||
* @return Zero when success, othewise en error
|
|
||||||
*/
|
|
||||||
int ocf_data_obj_init(ocf_data_obj_t obj, ocf_data_obj_type_t type,
|
|
||||||
struct ocf_data_obj_uuid *uuid, bool uuid_copy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deinitialize data object
|
|
||||||
*
|
|
||||||
* @param[in] obj data object handle
|
|
||||||
*/
|
|
||||||
void ocf_data_obj_deinit(ocf_data_obj_t obj);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate and initialize data object
|
|
||||||
*
|
|
||||||
* @param[out] obj pointer to data object handle
|
|
||||||
* @param[in] type cache/core object type
|
|
||||||
* @param[in] uuid OCF data object UUID
|
|
||||||
*
|
|
||||||
* @return Zero when success, othewise en error
|
|
||||||
*/
|
|
||||||
int ocf_data_obj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
|
|
||||||
struct ocf_data_obj_uuid *uuid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deinitialize and free data object
|
|
||||||
*
|
|
||||||
* @param[in] obj data object handle
|
|
||||||
*/
|
|
||||||
void ocf_data_obj_destroy(ocf_data_obj_t obj);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate new io from data object allocator
|
* @brief Allocate new io from data object allocator
|
||||||
*
|
*
|
||||||
* @param[in] obj data object handle
|
* @param[in] obj data object handle
|
||||||
|
*
|
||||||
|
* @return ocf_io object on success, otherwise NULL
|
||||||
*/
|
*/
|
||||||
struct ocf_io *ocf_data_obj_new_io(ocf_data_obj_t obj);
|
struct ocf_io *ocf_data_obj_new_io(ocf_data_obj_t obj);
|
||||||
|
|
||||||
@ -258,7 +188,148 @@ void ocf_data_obj_del_io(struct ocf_io* io);
|
|||||||
* @brief Return io context data
|
* @brief Return io context data
|
||||||
*
|
*
|
||||||
* @param[in] io ocf io handle
|
* @param[in] io ocf io handle
|
||||||
|
*
|
||||||
|
* @return ocf_io private context data
|
||||||
*/
|
*/
|
||||||
void *ocf_data_obj_get_data_from_io(struct ocf_io* io);
|
void *ocf_data_obj_get_data_from_io(struct ocf_io* io);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize data object
|
||||||
|
*
|
||||||
|
* @param[in] obj data object handle
|
||||||
|
* @param[in] type cache/core object type
|
||||||
|
* @param[in] uuid OCF data object UUID
|
||||||
|
* @param[in] uuid_copy crate copy of uuid data
|
||||||
|
*
|
||||||
|
* @return Zero when success, othewise error
|
||||||
|
*/
|
||||||
|
int ocf_dobj_init(ocf_data_obj_t obj, ocf_data_obj_type_t type,
|
||||||
|
struct ocf_data_obj_uuid *uuid, bool uuid_copy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deinitialize data object
|
||||||
|
*
|
||||||
|
* @param[in] obj data object handle
|
||||||
|
*/
|
||||||
|
void ocf_dobj_deinit(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate and initialize data object
|
||||||
|
*
|
||||||
|
* @param[out] obj pointer to data object handle
|
||||||
|
* @param[in] type cache/core object type
|
||||||
|
* @param[in] uuid OCF data object UUID
|
||||||
|
*
|
||||||
|
* @return Zero when success, othewise en error
|
||||||
|
*/
|
||||||
|
int ocf_dobj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
|
||||||
|
struct ocf_data_obj_uuid *uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deinitialize and free data object
|
||||||
|
*
|
||||||
|
* @param[in] obj data object handle
|
||||||
|
*/
|
||||||
|
void ocf_data_obj_destroy(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get data object type
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*
|
||||||
|
* @return Data object type
|
||||||
|
*/
|
||||||
|
ocf_data_obj_type_t ocf_dobj_get_type(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get data object UUID
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*
|
||||||
|
* @return UUID of data object
|
||||||
|
*/
|
||||||
|
const struct ocf_data_obj_uuid *ocf_dobj_get_uuid(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get cache handle for given data object
|
||||||
|
*
|
||||||
|
* @param obj data object handle
|
||||||
|
*
|
||||||
|
* @return Handle to cache for which data object belongs to
|
||||||
|
*/
|
||||||
|
ocf_cache_t ocf_dobj_get_cache(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if data object supports atomic mode
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*
|
||||||
|
* @return Non-zero value if data object is atomic, otherwise zero
|
||||||
|
*/
|
||||||
|
int ocf_dobj_is_atomic(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate new io
|
||||||
|
*
|
||||||
|
* @param[in] io IO
|
||||||
|
*
|
||||||
|
* @return ocf_io on success atomic, otherwise NULL
|
||||||
|
*/
|
||||||
|
struct ocf_io *ocf_dobj_new_io(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Submit io to data object
|
||||||
|
*
|
||||||
|
* @param[in] io IO
|
||||||
|
*/
|
||||||
|
void ocf_dobj_submit_io(struct ocf_io *io);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Submit flush to data object
|
||||||
|
*
|
||||||
|
* @param[in] io IO
|
||||||
|
*/
|
||||||
|
void ocf_dobj_submit_flush(struct ocf_io *io);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Submit discard to data object
|
||||||
|
*
|
||||||
|
* @param[in] io IO
|
||||||
|
*/
|
||||||
|
void ocf_dobj_submit_discard(struct ocf_io *io);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Open data object
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*
|
||||||
|
* @return Zero when success, othewise en error
|
||||||
|
*/
|
||||||
|
int ocf_dobj_open(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get data object max io size
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*/
|
||||||
|
void ocf_dobj_close(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get data object max io size
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*
|
||||||
|
* @return Data object max io size in bytes
|
||||||
|
*/
|
||||||
|
unsigned int ocf_dobj_get_max_io_size(ocf_data_obj_t obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get data object length
|
||||||
|
*
|
||||||
|
* @param[in] obj Data object
|
||||||
|
*
|
||||||
|
* @return Length of data object in bytes
|
||||||
|
*/
|
||||||
|
uint64_t ocf_dobj_get_length(ocf_data_obj_t obj);
|
||||||
|
|
||||||
#endif /* __OCF_DATA_OBJ_H__ */
|
#endif /* __OCF_DATA_OBJ_H__ */
|
||||||
|
@ -50,7 +50,7 @@ static int _ocf_invalidate_do(struct ocf_request *req)
|
|||||||
|
|
||||||
env_atomic_inc(&req->req_remaining);
|
env_atomic_inc(&req->req_remaining);
|
||||||
|
|
||||||
if (ocf_data_obj_is_atomic(&cache->device->obj) &&
|
if (ocf_dobj_is_atomic(&cache->device->obj) &&
|
||||||
req->info.flush_metadata) {
|
req->info.flush_metadata) {
|
||||||
/* Metadata flush IO */
|
/* Metadata flush IO */
|
||||||
ocf_metadata_flush_do_asynch(cache, req, _ocf_invalidate_req);
|
ocf_metadata_flush_do_asynch(cache, req, _ocf_invalidate_req);
|
||||||
|
@ -410,7 +410,7 @@ uint32_t evp_lru_req_clines(struct ocf_cache *cache, uint32_t io_queue,
|
|||||||
|
|
||||||
ENV_BUG_ON(metadata_test_dirty(cache, curr_cline));
|
ENV_BUG_ON(metadata_test_dirty(cache, curr_cline));
|
||||||
|
|
||||||
if (ocf_data_obj_is_atomic(&cache->device->obj)) {
|
if (ocf_dobj_is_atomic(&cache->device->obj)) {
|
||||||
/* atomic cache, we have to trim cache lines before
|
/* atomic cache, we have to trim cache lines before
|
||||||
* eviction
|
* eviction
|
||||||
*/
|
*/
|
||||||
|
@ -577,7 +577,7 @@ static int ocf_metadata_hash_init_variable_size(struct ocf_cache *cache,
|
|||||||
if (cache->device->init_mode == ocf_init_mode_metadata_volatile) {
|
if (cache->device->init_mode == ocf_init_mode_metadata_volatile) {
|
||||||
raw->raw_type = metadata_raw_type_volatile;
|
raw->raw_type = metadata_raw_type_volatile;
|
||||||
} else if (i == metadata_segment_collision &&
|
} else if (i == metadata_segment_collision &&
|
||||||
ocf_data_obj_is_atomic(&cache->device->obj)) {
|
ocf_dobj_is_atomic(&cache->device->obj)) {
|
||||||
raw->raw_type = metadata_raw_type_atomic;
|
raw->raw_type = metadata_raw_type_atomic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -975,7 +975,7 @@ static int ocf_metadata_hash_load_superblock(struct ocf_cache *cache)
|
|||||||
uuid.size = muuid->size;
|
uuid.size = muuid->size;
|
||||||
|
|
||||||
/* Initialize core data object */
|
/* Initialize core data object */
|
||||||
ocf_data_obj_init(&cache->core[i].obj,
|
ocf_dobj_init(&cache->core[i].obj,
|
||||||
ocf_ctx_get_data_obj_type(cache->owner,
|
ocf_ctx_get_data_obj_type(cache->owner,
|
||||||
cache->core_conf_meta[i].type),
|
cache->core_conf_meta[i].type),
|
||||||
&uuid, false);
|
&uuid, false);
|
||||||
@ -1544,7 +1544,7 @@ static int ocf_metadata_hash_load_recovery(struct ocf_cache *cache)
|
|||||||
OCF_DEBUG_TRACE(cache);
|
OCF_DEBUG_TRACE(cache);
|
||||||
|
|
||||||
|
|
||||||
if (ocf_data_obj_is_atomic(&cache->device->obj)) {
|
if (ocf_dobj_is_atomic(&cache->device->obj)) {
|
||||||
result = _ocf_metadata_hash_load_recovery_atomic(cache);
|
result = _ocf_metadata_hash_load_recovery_atomic(cache);
|
||||||
rebuild_dirty_only = false;
|
rebuild_dirty_only = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,7 +46,7 @@ static struct ocf_io_if meta_restart_if = {
|
|||||||
*/
|
*/
|
||||||
static uint32_t metadata_io_max_page(struct ocf_cache *cache)
|
static uint32_t metadata_io_max_page(struct ocf_cache *cache)
|
||||||
{
|
{
|
||||||
return ocf_data_obj_get_max_io_size(&cache->device->obj) /
|
return ocf_dobj_get_max_io_size(&cache->device->obj) /
|
||||||
BYTES_TO_SECTORS(PAGE_SIZE);
|
BYTES_TO_SECTORS(PAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ static void metadata_io_read_i_atomic_end(struct ocf_io *io, int error)
|
|||||||
{
|
{
|
||||||
struct metadata_io_request_atomic *meta_atom_req = io->priv1;
|
struct metadata_io_request_atomic *meta_atom_req = io->priv1;
|
||||||
|
|
||||||
OCF_DEBUG_TRACE(ocf_data_obj_get_cache(io->obj));
|
OCF_DEBUG_TRACE(ocf_dobj_get_cache(io->obj));
|
||||||
|
|
||||||
meta_atom_req->error |= error;
|
meta_atom_req->error |= error;
|
||||||
env_completion_complete(&meta_atom_req->complete);
|
env_completion_complete(&meta_atom_req->complete);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "ocf/ocf.h"
|
#include "ocf/ocf.h"
|
||||||
#include "ocf_mngt_common.h"
|
#include "ocf_mngt_common.h"
|
||||||
|
#include "ocf_mngt_core_priv.h"
|
||||||
#include "../ocf_priv.h"
|
#include "../ocf_priv.h"
|
||||||
#include "../ocf_core_priv.h"
|
#include "../ocf_core_priv.h"
|
||||||
#include "../ocf_queue_priv.h"
|
#include "../ocf_queue_priv.h"
|
||||||
@ -364,7 +365,7 @@ static void _ocf_mngt_close_all_uninitialized_cores(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
obj = &(cache->core[i].obj);
|
obj = &(cache->core[i].obj);
|
||||||
ocf_data_obj_close(obj);
|
ocf_dobj_close(obj);
|
||||||
|
|
||||||
--j;
|
--j;
|
||||||
|
|
||||||
@ -418,15 +419,15 @@ static int _ocf_mngt_init_instance_add_cores(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!cache->core[i].obj.type)
|
if (!cache->core[i].obj.type)
|
||||||
goto _cache_mng_init_instance_add_cores_ERROR;
|
goto err;
|
||||||
|
|
||||||
ret = snprintf(core_name, sizeof(core_name), "core%d", i);
|
ret = snprintf(core_name, sizeof(core_name), "core%d", i);
|
||||||
if (ret < 0 || ret >= sizeof(core_name))
|
if (ret < 0 || ret >= sizeof(core_name))
|
||||||
goto _cache_mng_init_instance_add_cores_ERROR;
|
goto err;
|
||||||
|
|
||||||
ret = ocf_core_set_name(core, core_name, sizeof(core_name));
|
ret = ocf_core_set_name(core, core_name, sizeof(core_name));
|
||||||
if (ret)
|
if (ret)
|
||||||
goto _cache_mng_init_instance_add_cores_ERROR;
|
goto err;
|
||||||
|
|
||||||
tobj = ocf_mngt_core_pool_lookup(ocf_cache_get_ctx(cache),
|
tobj = ocf_mngt_core_pool_lookup(ocf_cache_get_ctx(cache),
|
||||||
&core->obj.uuid, core->obj.type);
|
&core->obj.uuid, core->obj.type);
|
||||||
@ -444,7 +445,7 @@ static int _ocf_mngt_init_instance_add_cores(
|
|||||||
ocf_cache_log(cache, log_info,
|
ocf_cache_log(cache, log_info,
|
||||||
"Attached core %u from pool\n", i);
|
"Attached core %u from pool\n", i);
|
||||||
} else {
|
} else {
|
||||||
ret = ocf_data_obj_open(&core->obj);
|
ret = ocf_dobj_open(&core->obj);
|
||||||
if (ret == -OCF_ERR_NOT_OPEN_EXC) {
|
if (ret == -OCF_ERR_NOT_OPEN_EXC) {
|
||||||
ocf_cache_log(cache, log_warn,
|
ocf_cache_log(cache, log_warn,
|
||||||
"Cannot open core %u. "
|
"Cannot open core %u. "
|
||||||
@ -461,10 +462,13 @@ static int _ocf_mngt_init_instance_add_cores(
|
|||||||
cache->conf_meta->core_count++;
|
cache->conf_meta->core_count++;
|
||||||
core->obj.cache = cache;
|
core->obj.cache = cache;
|
||||||
|
|
||||||
|
if (ocf_mngt_core_init_front_dobj(core))
|
||||||
|
goto err;
|
||||||
|
|
||||||
core->counters =
|
core->counters =
|
||||||
env_zalloc(sizeof(*core->counters), ENV_MEM_NORMAL);
|
env_zalloc(sizeof(*core->counters), ENV_MEM_NORMAL);
|
||||||
if (!core->counters)
|
if (!core->counters)
|
||||||
goto _cache_mng_init_instance_add_cores_ERROR;
|
goto err;
|
||||||
|
|
||||||
if (!core->opened) {
|
if (!core->opened) {
|
||||||
env_bit_set(ocf_cache_state_incomplete,
|
env_bit_set(ocf_cache_state_incomplete,
|
||||||
@ -477,7 +481,7 @@ static int _ocf_mngt_init_instance_add_cores(
|
|||||||
}
|
}
|
||||||
|
|
||||||
hd_lines = ocf_bytes_2_lines(cache,
|
hd_lines = ocf_bytes_2_lines(cache,
|
||||||
ocf_data_obj_get_length(
|
ocf_dobj_get_length(
|
||||||
&cache->core[i].obj));
|
&cache->core[i].obj));
|
||||||
|
|
||||||
if (hd_lines) {
|
if (hd_lines) {
|
||||||
@ -489,7 +493,7 @@ static int _ocf_mngt_init_instance_add_cores(
|
|||||||
attach_params->flags.cores_opened = true;
|
attach_params->flags.cores_opened = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_cache_mng_init_instance_add_cores_ERROR:
|
err:
|
||||||
_ocf_mngt_close_all_uninitialized_cores(cache);
|
_ocf_mngt_close_all_uninitialized_cores(cache);
|
||||||
|
|
||||||
return -OCF_ERR_START_CACHE_FAIL;
|
return -OCF_ERR_START_CACHE_FAIL;
|
||||||
@ -633,12 +637,12 @@ static int _ocf_mngt_attach_cache_device(struct ocf_cache *cache,
|
|||||||
attach_params->device_type);
|
attach_params->device_type);
|
||||||
if (!cache->device->obj.type) {
|
if (!cache->device->obj.type) {
|
||||||
ret = -OCF_ERR_INVAL_DATA_OBJ_TYPE;
|
ret = -OCF_ERR_INVAL_DATA_OBJ_TYPE;
|
||||||
goto _cache_mng_attach_cache_device_ERROR;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ocf_uuid_cache_set(cache, &attach_params->uuid)) {
|
if (ocf_uuid_cache_set(cache, &attach_params->uuid)) {
|
||||||
ret = -OCF_ERR_INVAL;
|
ret = -OCF_ERR_INVAL;
|
||||||
goto _cache_mng_attach_cache_device_ERROR;
|
goto err;
|
||||||
}
|
}
|
||||||
attach_params->flags.uuid_alloc = true;
|
attach_params->flags.uuid_alloc = true;
|
||||||
|
|
||||||
@ -646,21 +650,21 @@ static int _ocf_mngt_attach_cache_device(struct ocf_cache *cache,
|
|||||||
* Open cache device, It has to be done first because metadata service
|
* Open cache device, It has to be done first because metadata service
|
||||||
* need to know size of cache device.
|
* need to know size of cache device.
|
||||||
*/
|
*/
|
||||||
ret = ocf_data_obj_open(&cache->device->obj);
|
ret = ocf_dobj_open(&cache->device->obj);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ocf_cache_log(cache, log_err, "ERROR: Cache not available\n");
|
ocf_cache_log(cache, log_err, "ERROR: Cache not available\n");
|
||||||
goto _cache_mng_attach_cache_device_ERROR;
|
goto err;
|
||||||
}
|
}
|
||||||
attach_params->flags.device_opened = true;
|
attach_params->flags.device_opened = true;
|
||||||
|
|
||||||
attach_params->device_size = ocf_data_obj_get_length(&cache->device->obj);
|
attach_params->device_size = ocf_dobj_get_length(&cache->device->obj);
|
||||||
|
|
||||||
/* Check minimum size of cache device */
|
/* Check minimum size of cache device */
|
||||||
if (attach_params->device_size < OCF_CACHE_SIZE_MIN) {
|
if (attach_params->device_size < OCF_CACHE_SIZE_MIN) {
|
||||||
ocf_cache_log(cache, log_err, "ERROR: Cache cache size must "
|
ocf_cache_log(cache, log_err, "ERROR: Cache cache size must "
|
||||||
"be at least %llu [MiB]\n", OCF_CACHE_SIZE_MIN / MiB);
|
"be at least %llu [MiB]\n", OCF_CACHE_SIZE_MIN / MiB);
|
||||||
ret = -OCF_ERR_START_CACHE_FAIL;
|
ret = -OCF_ERR_START_CACHE_FAIL;
|
||||||
goto _cache_mng_attach_cache_device_ERROR;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache->metadata.is_volatile) {
|
if (cache->metadata.is_volatile) {
|
||||||
@ -672,7 +676,7 @@ static int _ocf_mngt_attach_cache_device(struct ocf_cache *cache,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_cache_mng_attach_cache_device_ERROR:
|
err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,7 +833,7 @@ static int _ocf_mngt_init_test_device(struct ocf_cache *cache)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ocf_data_obj_is_atomic(&cache->device->obj))
|
if (!ocf_dobj_is_atomic(&cache->device->obj))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1089,7 +1093,7 @@ static void _ocf_mngt_attach_handle_error(
|
|||||||
ocf_metadata_deinit_variable_size(cache);
|
ocf_metadata_deinit_variable_size(cache);
|
||||||
|
|
||||||
if (attach_params->flags.device_opened)
|
if (attach_params->flags.device_opened)
|
||||||
ocf_data_obj_close(&cache->device->obj);
|
ocf_dobj_close(&cache->device->obj);
|
||||||
|
|
||||||
if (attach_params->flags.concurrency_inited)
|
if (attach_params->flags.concurrency_inited)
|
||||||
ocf_concurrency_deinit(cache);
|
ocf_concurrency_deinit(cache);
|
||||||
@ -1105,11 +1109,11 @@ static int _ocf_mngt_cache_discard_after_metadata(struct ocf_cache *cache)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
uint64_t addr = cache->device->metadata_offset;
|
uint64_t addr = cache->device->metadata_offset;
|
||||||
uint64_t length = ocf_data_obj_get_length(
|
uint64_t length = ocf_dobj_get_length(
|
||||||
&cache->device->obj) - addr;
|
&cache->device->obj) - addr;
|
||||||
bool discard = cache->device->obj.features.discard_zeroes;
|
bool discard = cache->device->obj.features.discard_zeroes;
|
||||||
|
|
||||||
if (!discard && ocf_data_obj_is_atomic(&cache->device->obj)) {
|
if (!discard && ocf_dobj_is_atomic(&cache->device->obj)) {
|
||||||
/* discard does not zero data - need to explicitly write
|
/* discard does not zero data - need to explicitly write
|
||||||
zeroes */
|
zeroes */
|
||||||
result = ocf_submit_write_zeroes_wait(
|
result = ocf_submit_write_zeroes_wait(
|
||||||
@ -1129,7 +1133,7 @@ static int _ocf_mngt_cache_discard_after_metadata(struct ocf_cache *cache)
|
|||||||
discard ? "Discarding whole cache device" :
|
discard ? "Discarding whole cache device" :
|
||||||
"Overwriting cache with zeroes");
|
"Overwriting cache with zeroes");
|
||||||
|
|
||||||
if (ocf_data_obj_is_atomic(&cache->device->obj)) {
|
if (ocf_dobj_is_atomic(&cache->device->obj)) {
|
||||||
ocf_cache_log(cache, log_err, "This step is required"
|
ocf_cache_log(cache, log_err, "This step is required"
|
||||||
" for atomic mode!\n");
|
" for atomic mode!\n");
|
||||||
} else {
|
} else {
|
||||||
@ -1351,7 +1355,6 @@ static int _ocf_mngt_cache_attach(ocf_cache_t cache,
|
|||||||
break;
|
break;
|
||||||
case ocf_init_mode_load:
|
case ocf_init_mode_load:
|
||||||
result = _ocf_mngt_init_instance_load(&attach_params);
|
result = _ocf_mngt_init_instance_load(&attach_params);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = OCF_ERR_INVAL;
|
result = OCF_ERR_INVAL;
|
||||||
@ -1564,7 +1567,7 @@ static int _ocf_mngt_cache_unplug(ocf_cache_t cache, bool stop)
|
|||||||
result = ocf_metadata_flush_all(cache);
|
result = ocf_metadata_flush_all(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_data_obj_close(&cache->device->obj);
|
ocf_dobj_close(&cache->device->obj);
|
||||||
|
|
||||||
ocf_metadata_deinit_variable_size(cache);
|
ocf_metadata_deinit_variable_size(cache);
|
||||||
ocf_concurrency_deinit(cache);
|
ocf_concurrency_deinit(cache);
|
||||||
|
@ -22,7 +22,7 @@ int cache_mng_core_close(ocf_cache_t cache, ocf_core_id_t core_id)
|
|||||||
if (!cache->core[core_id].opened)
|
if (!cache->core[core_id].opened)
|
||||||
return -OCF_ERR_CORE_IN_INACTIVE_STATE;
|
return -OCF_ERR_CORE_IN_INACTIVE_STATE;
|
||||||
|
|
||||||
ocf_data_obj_close(&cache->core[core_id].obj);
|
ocf_dobj_close(&cache->core[core_id].obj);
|
||||||
cache->core[core_id].opened = false;
|
cache->core[core_id].opened = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -57,7 +57,7 @@ void cache_mng_core_deinit_attached_meta(struct ocf_cache *cache, int core_id)
|
|||||||
|
|
||||||
core = &cache->core[core_id].obj;
|
core = &cache->core[core_id].obj;
|
||||||
|
|
||||||
core_size = ocf_data_obj_get_length(core);
|
core_size = ocf_dobj_get_length(core);
|
||||||
if (!core_size)
|
if (!core_size)
|
||||||
core_size = ~0ULL;
|
core_size = ~0ULL;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "ocf/ocf.h"
|
#include "ocf/ocf.h"
|
||||||
#include "ocf_mngt_common.h"
|
#include "ocf_mngt_common.h"
|
||||||
|
#include "ocf_mngt_core_priv.h"
|
||||||
#include "../ocf_priv.h"
|
#include "../ocf_priv.h"
|
||||||
#include "../metadata/metadata.h"
|
#include "../metadata/metadata.h"
|
||||||
#include "../engine/cache_engine.h"
|
#include "../engine/cache_engine.h"
|
||||||
@ -36,11 +37,11 @@ static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
|
|||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ocf_data_obj_open(obj);
|
result = ocf_dobj_open(obj);
|
||||||
if (result)
|
if (result)
|
||||||
goto error_out;
|
goto error_out;
|
||||||
|
|
||||||
if (!ocf_data_obj_get_length(obj)) {
|
if (!ocf_dobj_get_length(obj)) {
|
||||||
result = -OCF_ERR_CORE_NOT_AVAIL;
|
result = -OCF_ERR_CORE_NOT_AVAIL;
|
||||||
goto error_after_open;
|
goto error_after_open;
|
||||||
}
|
}
|
||||||
@ -54,7 +55,7 @@ static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_after_open:
|
error_after_open:
|
||||||
ocf_data_obj_close(obj);
|
ocf_dobj_close(obj);
|
||||||
error_out:
|
error_out:
|
||||||
*core = NULL;
|
*core = NULL;
|
||||||
return result;
|
return result;
|
||||||
@ -92,11 +93,11 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
|
|||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ocf_data_obj_open(obj);
|
result = ocf_dobj_open(obj);
|
||||||
if (result)
|
if (result)
|
||||||
goto error_out;
|
goto error_out;
|
||||||
|
|
||||||
length = ocf_data_obj_get_length(obj);
|
length = ocf_dobj_get_length(obj);
|
||||||
if (!length) {
|
if (!length) {
|
||||||
result = -OCF_ERR_CORE_NOT_AVAIL;
|
result = -OCF_ERR_CORE_NOT_AVAIL;
|
||||||
goto error_after_open;
|
goto error_after_open;
|
||||||
@ -181,7 +182,7 @@ error_after_clean_pol:
|
|||||||
cleaning_policy_ops[clean_type].remove_core(cache, cfg->core_id);
|
cleaning_policy_ops[clean_type].remove_core(cache, cfg->core_id);
|
||||||
|
|
||||||
error_after_open:
|
error_after_open:
|
||||||
ocf_data_obj_close(obj);
|
ocf_dobj_close(obj);
|
||||||
error_out:
|
error_out:
|
||||||
ocf_uuid_core_clear(cache, tmp_core);
|
ocf_uuid_core_clear(cache, tmp_core);
|
||||||
*core = NULL;
|
*core = NULL;
|
||||||
@ -332,6 +333,22 @@ static int _ocf_mngt_find_core_id(ocf_cache_t cache,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ocf_mngt_core_init_front_dobj(ocf_core_t core)
|
||||||
|
{
|
||||||
|
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||||
|
ocf_data_obj_t front_obj;
|
||||||
|
|
||||||
|
front_obj = &core->front_obj;
|
||||||
|
front_obj->uuid.data = core;
|
||||||
|
front_obj->uuid.size = sizeof(core);
|
||||||
|
|
||||||
|
front_obj->type = ocf_ctx_get_data_obj_type(cache->owner, 0);
|
||||||
|
if (!front_obj->type)
|
||||||
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
|
return ocf_dobj_open(front_obj);
|
||||||
|
}
|
||||||
|
|
||||||
int ocf_mngt_cache_add_core_nolock(ocf_cache_t cache, ocf_core_t *core,
|
int ocf_mngt_cache_add_core_nolock(ocf_cache_t cache, ocf_core_t *core,
|
||||||
struct ocf_mngt_core_config *cfg)
|
struct ocf_mngt_core_config *cfg)
|
||||||
{
|
{
|
||||||
@ -369,6 +386,12 @@ int ocf_mngt_cache_add_core_nolock(ocf_cache_t cache, ocf_core_t *core,
|
|||||||
else
|
else
|
||||||
result = _ocf_mngt_cache_add_core(cache, core, cfg);
|
result = _ocf_mngt_cache_add_core(cache, core, cfg);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
result = ocf_mngt_core_init_front_dobj(*core);
|
||||||
|
|
||||||
|
out:
|
||||||
if (!result) {
|
if (!result) {
|
||||||
ocf_core_log(*core, log_info, "Successfully added\n");
|
ocf_core_log(*core, log_info, "Successfully added\n");
|
||||||
} else {
|
} else {
|
||||||
@ -417,6 +440,8 @@ static int _ocf_mngt_cache_remove_core(ocf_core_t core, bool detach)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ocf_dobj_close(&core->front_obj);
|
||||||
|
|
||||||
/* Deinit everything*/
|
/* Deinit everything*/
|
||||||
if (ocf_cache_is_device_attached(cache)) {
|
if (ocf_cache_is_device_attached(cache)) {
|
||||||
cache_mng_core_deinit_attached_meta(cache, core_id);
|
cache_mng_core_deinit_attached_meta(cache, core_id);
|
||||||
|
@ -38,9 +38,9 @@ int ocf_mngt_core_pool_add(ocf_ctx_t ctx, ocf_uuid_t uuid, uint8_t type)
|
|||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result = ocf_data_obj_open(obj);
|
result = ocf_dobj_open(obj);
|
||||||
if (result) {
|
if (result) {
|
||||||
ocf_data_obj_deinit(obj);
|
ocf_dobj_deinit(obj);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,14 +99,14 @@ void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_data_obj_t obj)
|
|||||||
ctx->core_pool.core_pool_count--;
|
ctx->core_pool.core_pool_count--;
|
||||||
list_del(&obj->core_pool_item);
|
list_del(&obj->core_pool_item);
|
||||||
env_mutex_unlock(&ctx->lock);
|
env_mutex_unlock(&ctx->lock);
|
||||||
ocf_data_obj_deinit(obj);
|
ocf_dobj_deinit(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_mngt_core_pool_close_and_remove(ocf_ctx_t ctx, ocf_data_obj_t obj)
|
void ocf_mngt_core_pool_close_and_remove(ocf_ctx_t ctx, ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(ctx);
|
OCF_CHECK_NULL(ctx);
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(obj);
|
||||||
ocf_data_obj_close(obj);
|
ocf_dobj_close(obj);
|
||||||
ocf_mngt_core_pool_remove(ctx, obj);
|
ocf_mngt_core_pool_remove(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/mngt/ocf_mngt_core_priv.h
Normal file
13
src/mngt/ocf_mngt_core_priv.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(c) 2012-2018 Intel Corporation
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __OCF_CORE_MNGT_PRIV_H__
|
||||||
|
#define __OCF_CORE_MNGT_PRIV_H__
|
||||||
|
|
||||||
|
#include "../ocf_core_priv.h"
|
||||||
|
|
||||||
|
int ocf_mngt_core_init_front_dobj(ocf_core_t core);
|
||||||
|
|
||||||
|
#endif /* __OCF_CORE_MNGT_PRIV_H__ */
|
@ -598,7 +598,7 @@ int ocf_mngt_core_purge(ocf_cache_t cache, ocf_core_id_t core_id, bool interrupt
|
|||||||
return -OCF_ERR_CORE_NOT_AVAIL;
|
return -OCF_ERR_CORE_NOT_AVAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_size = ocf_data_obj_get_length(&cache->core[core_id].obj);
|
core_size = ocf_dobj_get_length(&cache->core[core_id].obj);
|
||||||
core_size = core_size ?: ~0ULL;
|
core_size = core_size ?: ~0ULL;
|
||||||
|
|
||||||
_ocf_mngt_begin_flush(cache);
|
_ocf_mngt_begin_flush(cache);
|
||||||
|
@ -182,7 +182,7 @@ const struct ocf_data_obj_uuid *ocf_cache_get_uuid(ocf_cache_t cache)
|
|||||||
if (!ocf_cache_is_device_attached(cache))
|
if (!ocf_cache_is_device_attached(cache))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return ocf_data_obj_get_uuid(ocf_cache_get_data_object(cache));
|
return ocf_dobj_get_uuid(ocf_cache_get_data_object(cache));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ocf_cache_get_type_id(ocf_cache_t cache)
|
uint8_t ocf_cache_get_type_id(ocf_cache_t cache)
|
||||||
@ -191,7 +191,7 @@ uint8_t ocf_cache_get_type_id(ocf_cache_t cache)
|
|||||||
return 0xff;
|
return 0xff;
|
||||||
|
|
||||||
return ocf_ctx_get_data_obj_type_id(ocf_cache_get_ctx(cache),
|
return ocf_ctx_get_data_obj_type_id(ocf_cache_get_ctx(cache),
|
||||||
ocf_data_obj_get_type(ocf_cache_get_data_object(cache)));
|
ocf_dobj_get_type(ocf_cache_get_data_object(cache)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_cache_line_size_t ocf_cache_get_line_size(ocf_cache_t cache)
|
ocf_cache_line_size_t ocf_cache_get_line_size(ocf_cache_t cache)
|
||||||
|
461
src/ocf_core.c
461
src/ocf_core.c
@ -26,6 +26,12 @@ ocf_data_obj_t ocf_core_get_data_object(ocf_core_t core)
|
|||||||
return &core->obj;
|
return &core->obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ocf_data_obj_t ocf_core_get_front_data_object(ocf_core_t core)
|
||||||
|
{
|
||||||
|
OCF_CHECK_NULL(core);
|
||||||
|
return &core->front_obj;
|
||||||
|
}
|
||||||
|
|
||||||
ocf_core_id_t ocf_core_get_id(ocf_core_t core)
|
ocf_core_id_t ocf_core_get_id(ocf_core_t core)
|
||||||
{
|
{
|
||||||
struct ocf_cache *cache;
|
struct ocf_cache *cache;
|
||||||
@ -122,100 +128,6 @@ int ocf_core_set_uuid(ocf_core_t core, const struct ocf_data_obj_uuid *uuid)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void inc_dirty_req_counter(struct ocf_core_io *core_io,
|
|
||||||
ocf_cache_t cache)
|
|
||||||
{
|
|
||||||
core_io->dirty = 1;
|
|
||||||
env_atomic_inc(&cache->pending_dirty_requests);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dec_counter_if_req_was_dirty(struct ocf_core_io *core_io,
|
|
||||||
ocf_cache_t cache)
|
|
||||||
{
|
|
||||||
int pending_dirty_req_count;
|
|
||||||
|
|
||||||
if (!core_io->dirty)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pending_dirty_req_count =
|
|
||||||
env_atomic_dec_return(&cache->pending_dirty_requests);
|
|
||||||
|
|
||||||
ENV_BUG_ON(pending_dirty_req_count < 0);
|
|
||||||
|
|
||||||
core_io->dirty = 0;
|
|
||||||
|
|
||||||
if (!pending_dirty_req_count)
|
|
||||||
env_waitqueue_wake_up(&cache->pending_dirty_wq);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* *** CORE IO *** */
|
|
||||||
|
|
||||||
static inline struct ocf_core_io *ocf_io_to_core_io(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
return container_of(io, struct ocf_core_io, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ocf_core_io_get(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
struct ocf_core_io *core_io;
|
|
||||||
int value;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(io);
|
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
|
||||||
value = env_atomic_inc_return(&core_io->ref_counter);
|
|
||||||
|
|
||||||
ENV_BUG_ON(value < 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ocf_core_io_put(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
struct ocf_core_io *core_io;
|
|
||||||
ocf_cache_t cache;
|
|
||||||
int value;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(io);
|
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
|
||||||
value = env_atomic_dec_return(&core_io->ref_counter);
|
|
||||||
|
|
||||||
ENV_BUG_ON(value < 0);
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
cache = ocf_core_get_cache(core_io->core);
|
|
||||||
|
|
||||||
core_io->data = NULL;
|
|
||||||
env_allocator_del(cache->owner->resources.core_io_allocator, core_io);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ocf_core_io_set_data(struct ocf_io *io,
|
|
||||||
ctx_data_t *data, uint32_t offset)
|
|
||||||
{
|
|
||||||
struct ocf_core_io *core_io;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(io);
|
|
||||||
|
|
||||||
if (!data || offset)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
|
||||||
core_io->data = data;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ctx_data_t *ocf_core_io_get_data(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
struct ocf_core_io *core_io;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(io);
|
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
|
||||||
return core_io->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core)
|
uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core)
|
||||||
{
|
{
|
||||||
uint32_t core_id = ocf_core_get_id(core);
|
uint32_t core_id = ocf_core_get_id(core);
|
||||||
@ -232,13 +144,6 @@ ocf_seq_cutoff_policy ocf_core_get_seq_cutoff_policy(ocf_core_t core)
|
|||||||
return cache->core_conf_meta[core_id].seq_cutoff_policy;
|
return cache->core_conf_meta[core_id].seq_cutoff_policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct ocf_io_ops ocf_core_io_ops = {
|
|
||||||
.set_data = ocf_core_io_set_data,
|
|
||||||
.get_data = ocf_core_io_get_data,
|
|
||||||
.get = ocf_core_io_get,
|
|
||||||
.put = ocf_core_io_put,
|
|
||||||
};
|
|
||||||
|
|
||||||
int ocf_core_set_user_metadata_raw(ocf_core_t core, void *data, size_t size)
|
int ocf_core_set_user_metadata_raw(ocf_core_t core, void *data, size_t size)
|
||||||
{
|
{
|
||||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||||
@ -293,12 +198,74 @@ int ocf_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *** OCF API *** */
|
int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
|
||||||
|
bool only_opened)
|
||||||
static inline int ocf_validate_io(struct ocf_core_io *core_io)
|
|
||||||
{
|
{
|
||||||
ocf_cache_t cache = ocf_core_get_cache(core_io->core);
|
ocf_core_id_t id;
|
||||||
struct ocf_io *io = &core_io->base;
|
int result = 0;
|
||||||
|
|
||||||
|
OCF_CHECK_NULL(cache);
|
||||||
|
|
||||||
|
if (!visitor)
|
||||||
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
|
for (id = 0; id < OCF_CORE_MAX; id++) {
|
||||||
|
if (!env_bit_test(id, cache->conf_meta->valid_object_bitmap))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (only_opened && !cache->core[id].opened)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
result = visitor(&cache->core[id], cntx);
|
||||||
|
if (result)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *** HELPER FUNCTIONS *** */
|
||||||
|
|
||||||
|
static inline struct ocf_core_io *ocf_io_to_core_io(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
return ocf_data_obj_get_data_from_io(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline ocf_core_t ocf_data_obj_to_core(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
return ocf_data_obj_get_priv(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void inc_dirty_req_counter(struct ocf_core_io *core_io,
|
||||||
|
ocf_cache_t cache)
|
||||||
|
{
|
||||||
|
core_io->dirty = 1;
|
||||||
|
env_atomic_inc(&cache->pending_dirty_requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dec_counter_if_req_was_dirty(struct ocf_core_io *core_io,
|
||||||
|
ocf_cache_t cache)
|
||||||
|
{
|
||||||
|
int pending_dirty_req_count;
|
||||||
|
|
||||||
|
if (!core_io->dirty)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pending_dirty_req_count =
|
||||||
|
env_atomic_dec_return(&cache->pending_dirty_requests);
|
||||||
|
|
||||||
|
ENV_BUG_ON(pending_dirty_req_count < 0);
|
||||||
|
|
||||||
|
core_io->dirty = 0;
|
||||||
|
|
||||||
|
if (!pending_dirty_req_count)
|
||||||
|
env_waitqueue_wake_up(&cache->pending_dirty_wq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int ocf_core_validate_io(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
ocf_core_t core = ocf_data_obj_to_core(io->obj);
|
||||||
|
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||||
|
|
||||||
if (!io->obj)
|
if (!io->obj)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -306,10 +273,10 @@ static inline int ocf_validate_io(struct ocf_core_io *core_io)
|
|||||||
if (!io->ops)
|
if (!io->ops)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (io->addr >= ocf_data_obj_get_length(io->obj))
|
if (io->addr >= ocf_dobj_get_length(io->obj))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (io->addr + io->bytes > ocf_data_obj_get_length(io->obj))
|
if (io->addr + io->bytes > ocf_dobj_get_length(io->obj))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (io->class >= OCF_IO_CLASS_MAX)
|
if (io->class >= OCF_IO_CLASS_MAX)
|
||||||
@ -335,36 +302,11 @@ static void ocf_req_complete(struct ocf_request *req, int error)
|
|||||||
dec_counter_if_req_was_dirty(ocf_io_to_core_io(req->io), req->cache);
|
dec_counter_if_req_was_dirty(ocf_io_to_core_io(req->io), req->cache);
|
||||||
|
|
||||||
/* Invalidate OCF IO, it is not valid after completion */
|
/* Invalidate OCF IO, it is not valid after completion */
|
||||||
ocf_core_io_put(req->io);
|
ocf_io_put(req->io);
|
||||||
req->io = NULL;
|
req->io = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ocf_io *ocf_new_io(ocf_core_t core)
|
void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
||||||
{
|
|
||||||
ocf_cache_t cache;
|
|
||||||
struct ocf_core_io *core_io;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(core);
|
|
||||||
|
|
||||||
cache = ocf_core_get_cache(core);
|
|
||||||
if (!cache)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
core_io = env_allocator_new(
|
|
||||||
cache->owner->resources.core_io_allocator);
|
|
||||||
if (!core_io)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
core_io->base.obj = ocf_core_get_data_object(core);
|
|
||||||
core_io->base.ops = &ocf_core_io_ops;
|
|
||||||
core_io->core = core;
|
|
||||||
|
|
||||||
env_atomic_set(&core_io->ref_counter, 1);
|
|
||||||
|
|
||||||
return &core_io->base;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ocf_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
|
||||||
{
|
{
|
||||||
struct ocf_core_io *core_io;
|
struct ocf_core_io *core_io;
|
||||||
ocf_req_cache_mode_t req_cache_mode;
|
ocf_req_cache_mode_t req_cache_mode;
|
||||||
@ -372,22 +314,23 @@ int ocf_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
|||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!io)
|
OCF_CHECK_NULL(io);
|
||||||
return -EINVAL;
|
|
||||||
|
ret = ocf_core_validate_io(io);
|
||||||
|
if (ret < 0) {
|
||||||
|
io->end(io, -EINVAL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
|
||||||
ret = ocf_validate_io(core_io);
|
core = ocf_data_obj_to_core(io->obj);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
core = core_io->core;
|
|
||||||
cache = ocf_core_get_cache(core);
|
cache = ocf_core_get_cache(core);
|
||||||
|
|
||||||
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
||||||
&cache->cache_state))) {
|
&cache->cache_state))) {
|
||||||
ocf_io_end(io, -EIO);
|
ocf_io_end(io, -EIO);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: instead of casting ocf_cache_mode_t to ocf_req_cache_mode_t
|
/* TODO: instead of casting ocf_cache_mode_t to ocf_req_cache_mode_t
|
||||||
@ -415,7 +358,7 @@ int ocf_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
|||||||
if (!core_io->req) {
|
if (!core_io->req) {
|
||||||
dec_counter_if_req_was_dirty(core_io, cache);
|
dec_counter_if_req_was_dirty(core_io, cache);
|
||||||
io->end(io, -ENOMEM);
|
io->end(io, -ENOMEM);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core_io->req->d2c)
|
if (core_io->req->d2c)
|
||||||
@ -431,18 +374,16 @@ int ocf_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
|||||||
|
|
||||||
ocf_core_update_stats(core, io);
|
ocf_core_update_stats(core, io);
|
||||||
|
|
||||||
ocf_core_io_get(io);
|
ocf_io_get(io);
|
||||||
ret = ocf_engine_hndl_req(core_io->req, req_cache_mode);
|
ret = ocf_engine_hndl_req(core_io->req, req_cache_mode);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dec_counter_if_req_was_dirty(core_io, cache);
|
dec_counter_if_req_was_dirty(core_io, cache);
|
||||||
ocf_req_put(core_io->req);
|
ocf_req_put(core_io->req);
|
||||||
io->end(io, ret);
|
io->end(io, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_submit_io_fast(struct ocf_io *io)
|
int ocf_core_submit_io_fast(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct ocf_core_io *core_io;
|
struct ocf_core_io *core_io;
|
||||||
ocf_req_cache_mode_t req_cache_mode;
|
ocf_req_cache_mode_t req_cache_mode;
|
||||||
@ -452,16 +393,15 @@ int ocf_submit_io_fast(struct ocf_io *io)
|
|||||||
int fast;
|
int fast;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!io)
|
OCF_CHECK_NULL(io);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
ret = ocf_core_validate_io(io);
|
||||||
|
|
||||||
ret = ocf_validate_io(core_io);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
core = core_io->core;
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
|
||||||
|
core = ocf_data_obj_to_core(io->obj);
|
||||||
cache = ocf_core_get_cache(core);
|
cache = ocf_core_get_cache(core);
|
||||||
|
|
||||||
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
||||||
@ -523,7 +463,7 @@ int ocf_submit_io_fast(struct ocf_io *io)
|
|||||||
req->io = io;
|
req->io = io;
|
||||||
|
|
||||||
ocf_core_update_stats(core, io);
|
ocf_core_update_stats(core, io);
|
||||||
ocf_core_io_get(io);
|
ocf_io_get(io);
|
||||||
|
|
||||||
fast = ocf_engine_hndl_fast_req(req, req_cache_mode);
|
fast = ocf_engine_hndl_fast_req(req, req_cache_mode);
|
||||||
if (fast != OCF_FAST_PATH_NO) {
|
if (fast != OCF_FAST_PATH_NO) {
|
||||||
@ -533,41 +473,47 @@ int ocf_submit_io_fast(struct ocf_io *io)
|
|||||||
|
|
||||||
dec_counter_if_req_was_dirty(core_io, cache);
|
dec_counter_if_req_was_dirty(core_io, cache);
|
||||||
|
|
||||||
ocf_core_io_put(io);
|
ocf_io_put(io);
|
||||||
ocf_req_put(req);
|
ocf_req_put(req);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_submit_flush(struct ocf_io *io)
|
static void ocf_core_data_obj_submit_io(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
ocf_core_submit_io_mode(io, ocf_cache_mode_none);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ocf_core_data_obj_submit_flush(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct ocf_core_io *core_io;
|
struct ocf_core_io *core_io;
|
||||||
ocf_core_t core;
|
ocf_core_t core;
|
||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!io)
|
OCF_CHECK_NULL(io);
|
||||||
return -EINVAL;
|
|
||||||
|
ret = ocf_core_validate_io(io);
|
||||||
|
if (ret < 0) {
|
||||||
|
ocf_io_end(io, -EINVAL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
|
||||||
ret = ocf_validate_io(core_io);
|
core = ocf_data_obj_to_core(io->obj);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
core = core_io->core;
|
|
||||||
cache = ocf_core_get_cache(core);
|
cache = ocf_core_get_cache(core);
|
||||||
|
|
||||||
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
||||||
&cache->cache_state))) {
|
&cache->cache_state))) {
|
||||||
ocf_io_end(io, -EIO);
|
ocf_io_end(io, -EIO);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_io->req = ocf_req_new(cache, ocf_core_get_id(core),
|
core_io->req = ocf_req_new(cache, ocf_core_get_id(core),
|
||||||
io->addr, io->bytes, io->dir);
|
io->addr, io->bytes, io->dir);
|
||||||
if (!core_io->req) {
|
if (!core_io->req) {
|
||||||
ocf_io_end(io, -ENOMEM);
|
ocf_io_end(io, -ENOMEM);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_io->req->io_queue = io->io_queue;
|
core_io->req->io_queue = io->io_queue;
|
||||||
@ -575,42 +521,41 @@ int ocf_submit_flush(struct ocf_io *io)
|
|||||||
core_io->req->io = io;
|
core_io->req->io = io;
|
||||||
core_io->req->data = core_io->data;
|
core_io->req->data = core_io->data;
|
||||||
|
|
||||||
ocf_core_io_get(io);
|
ocf_io_get(io);
|
||||||
ocf_engine_hndl_ops_req(core_io->req);
|
ocf_engine_hndl_ops_req(core_io->req);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_submit_discard(struct ocf_io *io)
|
static void ocf_core_data_obj_submit_discard(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct ocf_core_io *core_io;
|
struct ocf_core_io *core_io;
|
||||||
ocf_core_t core;
|
ocf_core_t core;
|
||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!io)
|
OCF_CHECK_NULL(io);
|
||||||
return -EINVAL;
|
|
||||||
|
ret = ocf_core_validate_io(io);
|
||||||
|
if (ret < 0) {
|
||||||
|
ocf_io_end(io, -EINVAL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
core_io = ocf_io_to_core_io(io);
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
|
||||||
ret = ocf_validate_io(core_io);
|
core = ocf_data_obj_to_core(io->obj);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
core = core_io->core;
|
|
||||||
cache = ocf_core_get_cache(core);
|
cache = ocf_core_get_cache(core);
|
||||||
|
|
||||||
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
||||||
&cache->cache_state))) {
|
&cache->cache_state))) {
|
||||||
ocf_io_end(io, -EIO);
|
ocf_io_end(io, -EIO);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_io->req = ocf_req_new_discard(cache, ocf_core_get_id(core),
|
core_io->req = ocf_req_new_discard(cache, ocf_core_get_id(core),
|
||||||
io->addr, io->bytes, OCF_WRITE);
|
io->addr, io->bytes, OCF_WRITE);
|
||||||
if (!core_io->req) {
|
if (!core_io->req) {
|
||||||
ocf_io_end(io, -ENOMEM);
|
ocf_io_end(io, -ENOMEM);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_io->req->io_queue = io->io_queue;
|
core_io->req->io_queue = io->io_queue;
|
||||||
@ -618,35 +563,149 @@ int ocf_submit_discard(struct ocf_io *io)
|
|||||||
core_io->req->io = io;
|
core_io->req->io = io;
|
||||||
core_io->req->data = core_io->data;
|
core_io->req->data = core_io->data;
|
||||||
|
|
||||||
ocf_core_io_get(io);
|
ocf_io_get(io);
|
||||||
ocf_engine_hndl_discard_req(core_io->req);
|
ocf_engine_hndl_discard_req(core_io->req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *** DATA OBJECT OPS *** */
|
||||||
|
|
||||||
|
struct ocf_io *ocf_core_data_obj_new_io(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
struct ocf_core_io *core_io;
|
||||||
|
struct ocf_io *io;
|
||||||
|
|
||||||
|
io = ocf_data_obj_new_io(obj);
|
||||||
|
if (!io)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
core_io = ocf_data_obj_get_data_from_io(io);
|
||||||
|
|
||||||
|
env_atomic_set(&core_io->ref_counter, 1);
|
||||||
|
|
||||||
|
return io;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ocf_core_data_obj_open(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
const struct ocf_data_obj_uuid *uuid = ocf_dobj_get_uuid(obj);
|
||||||
|
ocf_core_t core = (ocf_core_t)uuid->data;
|
||||||
|
|
||||||
|
ocf_data_obj_set_priv(obj, core);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
|
static void ocf_core_data_obj_close(ocf_data_obj_t obj)
|
||||||
bool only_opened)
|
|
||||||
{
|
{
|
||||||
ocf_core_id_t id;
|
ocf_data_obj_set_priv(obj, NULL);
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(cache);
|
|
||||||
|
|
||||||
if (!visitor)
|
|
||||||
return -OCF_ERR_INVAL;
|
|
||||||
|
|
||||||
for (id = 0; id < OCF_CORE_MAX; id++) {
|
|
||||||
if (!env_bit_test(id, cache->conf_meta->valid_object_bitmap))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (only_opened && !cache->core[id].opened)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
result = visitor(&cache->core[id], cntx);
|
|
||||||
if (result)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
static unsigned int ocf_core_data_obj_get_max_io_size(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ocf_core_t core = ocf_data_obj_to_core(obj);
|
||||||
|
|
||||||
|
return ocf_dobj_get_max_io_size(&core->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint64_t ocf_core_data_obj_get_byte_length(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ocf_core_t core = ocf_data_obj_to_core(obj);
|
||||||
|
|
||||||
|
return ocf_dobj_get_length(&core->obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* *** IO OPS *** */
|
||||||
|
|
||||||
|
static int ocf_core_io_set_data(struct ocf_io *io,
|
||||||
|
ctx_data_t *data, uint32_t offset)
|
||||||
|
{
|
||||||
|
struct ocf_core_io *core_io;
|
||||||
|
|
||||||
|
OCF_CHECK_NULL(io);
|
||||||
|
|
||||||
|
if (!data || offset)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
core_io->data = data;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ctx_data_t *ocf_core_io_get_data(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
struct ocf_core_io *core_io;
|
||||||
|
|
||||||
|
OCF_CHECK_NULL(io);
|
||||||
|
|
||||||
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
return core_io->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ocf_core_io_get(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
struct ocf_core_io *core_io;
|
||||||
|
|
||||||
|
OCF_CHECK_NULL(io);
|
||||||
|
|
||||||
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
|
||||||
|
ENV_BUG_ON(env_atomic_inc_return(&core_io->ref_counter) < 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ocf_core_io_put(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
struct ocf_core_io *core_io;
|
||||||
|
int value;
|
||||||
|
|
||||||
|
OCF_CHECK_NULL(io);
|
||||||
|
|
||||||
|
core_io = ocf_io_to_core_io(io);
|
||||||
|
value = env_atomic_dec_return(&core_io->ref_counter);
|
||||||
|
|
||||||
|
ENV_BUG_ON(value < 0);
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ocf_data_obj_del_io(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct ocf_data_obj_properties ocf_core_data_obj_properties = {
|
||||||
|
.name = "OCF Core",
|
||||||
|
.io_context_size = sizeof(struct ocf_core_io),
|
||||||
|
.caps = {
|
||||||
|
.atomic_writes = 0,
|
||||||
|
},
|
||||||
|
.ops = {
|
||||||
|
.new_io = ocf_core_data_obj_new_io,
|
||||||
|
|
||||||
|
.submit_io = ocf_core_data_obj_submit_io,
|
||||||
|
.submit_flush = ocf_core_data_obj_submit_flush,
|
||||||
|
.submit_discard = ocf_core_data_obj_submit_discard,
|
||||||
|
.submit_metadata = NULL,
|
||||||
|
|
||||||
|
.open = ocf_core_data_obj_open,
|
||||||
|
.close = ocf_core_data_obj_close,
|
||||||
|
.get_max_io_size = ocf_core_data_obj_get_max_io_size,
|
||||||
|
.get_length = ocf_core_data_obj_get_byte_length,
|
||||||
|
},
|
||||||
|
.io_ops = {
|
||||||
|
.set_data = ocf_core_io_set_data,
|
||||||
|
.get_data = ocf_core_io_get_data,
|
||||||
|
.get = ocf_core_io_get,
|
||||||
|
.put = ocf_core_io_put,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
int ocf_core_data_obj_type_init(ocf_ctx_t ctx)
|
||||||
|
{
|
||||||
|
return ocf_ctx_register_data_obj_type(ctx, 0,
|
||||||
|
&ocf_core_data_obj_properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ocf_core_data_obj_type_deinit(ocf_ctx_t ctx)
|
||||||
|
{
|
||||||
|
ocf_ctx_unregister_data_obj_type(ctx, 0);
|
||||||
|
}
|
||||||
|
@ -8,12 +8,17 @@
|
|||||||
|
|
||||||
#include "ocf/ocf.h"
|
#include "ocf/ocf.h"
|
||||||
#include "ocf_env.h"
|
#include "ocf_env.h"
|
||||||
|
#include "ocf_ctx_priv.h"
|
||||||
#include "ocf_data_obj_priv.h"
|
#include "ocf_data_obj_priv.h"
|
||||||
|
|
||||||
struct ocf_core_io {
|
#define ocf_core_log_prefix(core, lvl, prefix, fmt, ...) \
|
||||||
struct ocf_io base;
|
ocf_cache_log_prefix(ocf_core_get_cache(core), lvl, ".%s" prefix, \
|
||||||
ocf_core_t core;
|
fmt, ocf_core_get_name(core), ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define ocf_core_log(core, lvl, fmt, ...) \
|
||||||
|
ocf_core_log_prefix(core, lvl, ": ", fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
struct ocf_core_io {
|
||||||
env_atomic ref_counter;
|
env_atomic ref_counter;
|
||||||
|
|
||||||
bool dirty;
|
bool dirty;
|
||||||
@ -26,6 +31,7 @@ struct ocf_core_io {
|
|||||||
struct ocf_core {
|
struct ocf_core {
|
||||||
char name[OCF_CORE_NAME_SIZE];
|
char name[OCF_CORE_NAME_SIZE];
|
||||||
|
|
||||||
|
struct ocf_data_obj front_obj;
|
||||||
struct ocf_data_obj obj;
|
struct ocf_data_obj obj;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -46,11 +52,8 @@ bool ocf_core_is_valid(ocf_cache_t cache, ocf_core_id_t id);
|
|||||||
|
|
||||||
int ocf_core_set_user_metadata_raw(ocf_core_t core, void *data, size_t size);
|
int ocf_core_set_user_metadata_raw(ocf_core_t core, void *data, size_t size);
|
||||||
|
|
||||||
#define ocf_core_log_prefix(core, lvl, prefix, fmt, ...) \
|
int ocf_core_data_obj_type_init(ocf_ctx_t ctx);
|
||||||
ocf_cache_log_prefix(ocf_core_get_cache(core), lvl, ".%s" prefix, \
|
|
||||||
fmt, ocf_core_get_name(core), ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#define ocf_core_log(core, lvl, fmt, ...) \
|
void ocf_core_data_obj_type_deinit(ocf_ctx_t ctx);
|
||||||
ocf_core_log_prefix(core, lvl, ": ", fmt, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#endif /* __OCF_CORE_PRIV_H__ */
|
#endif /* __OCF_CORE_PRIV_H__ */
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "ocf_data_obj_priv.h"
|
#include "ocf_data_obj_priv.h"
|
||||||
#include "ocf_utils.h"
|
#include "ocf_utils.h"
|
||||||
#include "ocf_logger_priv.h"
|
#include "ocf_logger_priv.h"
|
||||||
|
#include "ocf_core_priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -106,7 +107,7 @@ int ocf_ctx_data_obj_create(ocf_ctx_t ctx, ocf_data_obj_t *obj,
|
|||||||
if (type_id >= OCF_DATA_OBJ_TYPE_MAX)
|
if (type_id >= OCF_DATA_OBJ_TYPE_MAX)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return ocf_data_obj_create(obj, ctx->data_obj_type[type_id], uuid);
|
return ocf_dobj_create(obj, ctx->data_obj_type[type_id], uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -144,7 +145,7 @@ out:
|
|||||||
*/
|
*/
|
||||||
int ocf_ctx_init(ocf_ctx_t *ctx, const struct ocf_ctx_ops *ops)
|
int ocf_ctx_init(ocf_ctx_t *ctx, const struct ocf_ctx_ops *ops)
|
||||||
{
|
{
|
||||||
struct ocf_ctx *ocf_ctx;
|
ocf_ctx_t ocf_ctx;
|
||||||
|
|
||||||
OCF_CHECK_NULL(ctx);
|
OCF_CHECK_NULL(ctx);
|
||||||
OCF_CHECK_NULL(ops);
|
OCF_CHECK_NULL(ops);
|
||||||
@ -165,6 +166,12 @@ int ocf_ctx_init(ocf_ctx_t *ctx, const struct ocf_ctx_ops *ops)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ocf_core_data_obj_type_init(ocf_ctx)) {
|
||||||
|
ocf_utils_deinit(ocf_ctx);
|
||||||
|
env_free(ocf_ctx);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
*ctx = ocf_ctx;
|
*ctx = ocf_ctx;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -187,6 +194,8 @@ int ocf_ctx_exit(ocf_ctx_t ctx)
|
|||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
ocf_core_data_obj_type_deinit(ctx);
|
||||||
|
|
||||||
ocf_utils_deinit(ctx);
|
ocf_utils_deinit(ctx);
|
||||||
if (ctx->logger && ctx->logger->close)
|
if (ctx->logger && ctx->logger->close)
|
||||||
ctx->logger->close(ctx->logger);
|
ctx->logger->close(ctx->logger);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#define __OCF_CTX_PRIV_H__
|
#define __OCF_CTX_PRIV_H__
|
||||||
|
|
||||||
#include "ocf_env.h"
|
#include "ocf_env.h"
|
||||||
#include "ocf/ocf_logger.h"
|
#include "ocf/ocf_ctx.h"
|
||||||
#include "ocf_logger_priv.h"
|
#include "ocf_logger_priv.h"
|
||||||
|
|
||||||
#define OCF_DATA_OBJ_TYPE_MAX 8
|
#define OCF_DATA_OBJ_TYPE_MAX 8
|
||||||
@ -32,17 +32,34 @@ struct ocf_ctx {
|
|||||||
} resources;
|
} resources;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ocf_log_prefix(ctx, lvl, prefix, fmt, ...) \
|
#define ocf_log_prefix(ctx, lvl, prefix, fmt, ...) ({ \
|
||||||
ocf_log_raw(ctx->logger, lvl, prefix fmt, ##__VA_ARGS__)
|
int __ocf_log_return_value = 0; \
|
||||||
|
if (ctx->logger) { \
|
||||||
|
__ocf_log_return_value = ocf_log_raw(ctx->logger, \
|
||||||
|
lvl, prefix fmt, ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
__ocf_log_return_value; \
|
||||||
|
})
|
||||||
|
|
||||||
#define ocf_log(ctx, lvl, fmt, ...) \
|
#define ocf_log(ctx, lvl, fmt, ...) \
|
||||||
ocf_log_prefix(ctx, lvl, "", fmt, ##__VA_ARGS__)
|
ocf_log_prefix(ctx, lvl, "", fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define ocf_log_rl(ctx) \
|
#define ocf_log_rl(ctx) ({ \
|
||||||
ocf_log_raw_rl(ctx->logger, __func__)
|
int __ocf_log_return_value = 0; \
|
||||||
|
if (ctx->logger) { \
|
||||||
|
__ocf_log_return_value = ocf_log_raw_rl(ctx->logger, \
|
||||||
|
__func__); \
|
||||||
|
} \
|
||||||
|
__ocf_log_return_value; \
|
||||||
|
})
|
||||||
|
|
||||||
#define ocf_log_stack_trace(ctx) \
|
#define ocf_log_stack_trace(ctx) ({ \
|
||||||
ocf_log_stack_trace_raw(ctx->logger)
|
int __ocf_log_return_value = 0; \
|
||||||
|
if (ctx->logger) { \
|
||||||
|
__ocf_log_return_value = ocf_log_stack_trace_raw(ctx->logger); \
|
||||||
|
} \
|
||||||
|
__ocf_log_return_value; \
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Environment data buffer operations wrappers
|
* @name Environment data buffer operations wrappers
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include "ocf_io_priv.h"
|
#include "ocf_io_priv.h"
|
||||||
#include "ocf_env.h"
|
#include "ocf_env.h"
|
||||||
|
|
||||||
|
/* *** Bottom interface *** */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is io allocator dedicated for bottom devices.
|
* This is io allocator dedicated for bottom devices.
|
||||||
* Out IO structure looks like this:
|
* Out IO structure looks like this:
|
||||||
@ -104,16 +106,9 @@ void ocf_data_obj_type_deinit(struct ocf_data_obj_type *type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data object
|
* Data object backend API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ocf_data_obj_type_t ocf_data_obj_get_type(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
OCF_CHECK_NULL(obj);
|
|
||||||
|
|
||||||
return obj->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ocf_data_obj_get_priv(ocf_data_obj_t obj)
|
void *ocf_data_obj_get_priv(ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(obj);
|
||||||
@ -128,30 +123,39 @@ void ocf_data_obj_set_priv(ocf_data_obj_t obj, void *priv)
|
|||||||
obj->priv = priv;
|
obj->priv = priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct ocf_data_obj_uuid *ocf_data_obj_get_uuid(
|
struct ocf_io *ocf_data_obj_new_io(ocf_data_obj_t obj)
|
||||||
ocf_data_obj_t obj)
|
|
||||||
{
|
{
|
||||||
|
struct ocf_io *io;
|
||||||
|
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(obj);
|
||||||
|
|
||||||
return &obj->uuid;
|
io = ocf_io_allocator_new(obj->type->allocator);
|
||||||
|
if (!io)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
io->obj = obj;
|
||||||
|
io->ops = &obj->type->properties->io_ops;
|
||||||
|
|
||||||
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ocf_data_obj_get_length(ocf_data_obj_t obj)
|
void ocf_data_obj_del_io(struct ocf_io* io)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(io);
|
||||||
|
|
||||||
return obj->type->properties->ops.get_length(obj);
|
ocf_io_allocator_del(io->obj->type->allocator, io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *ocf_data_obj_get_data_from_io(struct ocf_io* io)
|
||||||
ocf_cache_t ocf_data_obj_get_cache(ocf_data_obj_t obj)
|
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(obj);
|
return (void *)io + sizeof(struct ocf_io);
|
||||||
|
|
||||||
return obj->cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_data_obj_init(ocf_data_obj_t obj, ocf_data_obj_type_t type,
|
/*
|
||||||
|
* Data object frontend API
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ocf_dobj_init(ocf_data_obj_t obj, ocf_data_obj_type_t type,
|
||||||
struct ocf_data_obj_uuid *uuid, bool uuid_copy)
|
struct ocf_data_obj_uuid *uuid, bool uuid_copy)
|
||||||
{
|
{
|
||||||
if (!obj || !type)
|
if (!obj || !type)
|
||||||
@ -179,7 +183,7 @@ int ocf_data_obj_init(ocf_data_obj_t obj, ocf_data_obj_type_t type,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_data_obj_deinit(ocf_data_obj_t obj)
|
void ocf_dobj_deinit(ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(obj);
|
||||||
|
|
||||||
@ -187,7 +191,7 @@ void ocf_data_obj_deinit(ocf_data_obj_t obj)
|
|||||||
env_free(obj->uuid.data);
|
env_free(obj->uuid.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_data_obj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
|
int ocf_dobj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
|
||||||
struct ocf_data_obj_uuid *uuid)
|
struct ocf_data_obj_uuid *uuid)
|
||||||
{
|
{
|
||||||
ocf_data_obj_t tmp_obj;
|
ocf_data_obj_t tmp_obj;
|
||||||
@ -199,7 +203,7 @@ int ocf_data_obj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
|
|||||||
if (!tmp_obj)
|
if (!tmp_obj)
|
||||||
return -OCF_ERR_NO_MEM;
|
return -OCF_ERR_NO_MEM;
|
||||||
|
|
||||||
ret = ocf_data_obj_init(tmp_obj, type, uuid, true);
|
ret = ocf_dobj_init(tmp_obj, type, uuid, true);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
env_free(tmp_obj);
|
env_free(tmp_obj);
|
||||||
return ret;
|
return ret;
|
||||||
@ -214,34 +218,97 @@ void ocf_data_obj_destroy(ocf_data_obj_t obj)
|
|||||||
{
|
{
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(obj);
|
||||||
|
|
||||||
ocf_data_obj_deinit(obj);
|
ocf_dobj_deinit(obj);
|
||||||
env_free(obj);
|
env_free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ocf_io *ocf_data_obj_new_io(ocf_data_obj_t obj)
|
ocf_data_obj_type_t ocf_dobj_get_type(ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
struct ocf_io *io;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(obj);
|
OCF_CHECK_NULL(obj);
|
||||||
|
|
||||||
io = ocf_io_allocator_new(obj->type->allocator);
|
return obj->type;
|
||||||
if (!io)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
io->obj = obj;
|
|
||||||
|
|
||||||
return io;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_data_obj_del_io(struct ocf_io* io)
|
const struct ocf_data_obj_uuid *ocf_dobj_get_uuid(
|
||||||
|
ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(io);
|
OCF_CHECK_NULL(obj);
|
||||||
|
|
||||||
ocf_io_allocator_del(io->obj->type->allocator, io);
|
return &obj->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ocf_data_obj_get_data_from_io(struct ocf_io* io)
|
ocf_cache_t ocf_dobj_get_cache(ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
return (void *)io + sizeof(struct ocf_io);
|
OCF_CHECK_NULL(obj);
|
||||||
|
|
||||||
|
return obj->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ocf_dobj_is_atomic(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
return obj->type->properties->caps.atomic_writes;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ocf_io *ocf_dobj_new_io(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!obj->type->properties->ops.new_io);
|
||||||
|
|
||||||
|
return obj->type->properties->ops.new_io(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ocf_dobj_submit_io(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!io->obj->type->properties->ops.submit_io);
|
||||||
|
|
||||||
|
io->obj->type->properties->ops.submit_io(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ocf_dobj_submit_flush(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!io->obj->type->properties->ops.submit_flush);
|
||||||
|
|
||||||
|
if (!io->obj->type->properties->ops.submit_flush) {
|
||||||
|
ocf_io_end(io, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
io->obj->type->properties->ops.submit_flush(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ocf_dobj_submit_discard(struct ocf_io *io)
|
||||||
|
{
|
||||||
|
if (!io->obj->type->properties->ops.submit_discard) {
|
||||||
|
ocf_io_end(io, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
io->obj->type->properties->ops.submit_discard(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ocf_dobj_open(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!obj->type->properties->ops.open);
|
||||||
|
|
||||||
|
return obj->type->properties->ops.open(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ocf_dobj_close(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!obj->type->properties->ops.close);
|
||||||
|
|
||||||
|
obj->type->properties->ops.close(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ocf_dobj_get_max_io_size(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!obj->type->properties->ops.get_max_io_size);
|
||||||
|
|
||||||
|
return obj->type->properties->ops.get_max_io_size(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ocf_dobj_get_length(ocf_data_obj_t obj)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!obj->type->properties->ops.get_length);
|
||||||
|
|
||||||
|
return obj->type->properties->ops.get_length(obj);
|
||||||
|
}
|
||||||
|
@ -32,46 +32,6 @@ int ocf_data_obj_type_init(struct ocf_data_obj_type **type,
|
|||||||
|
|
||||||
void ocf_data_obj_type_deinit(struct ocf_data_obj_type *type);
|
void ocf_data_obj_type_deinit(struct ocf_data_obj_type *type);
|
||||||
|
|
||||||
static inline struct ocf_io *ocf_dobj_new_io(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!obj->type->properties->ops.new_io);
|
|
||||||
|
|
||||||
return obj->type->properties->ops.new_io(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ocf_dobj_submit_io(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!io->obj->type->properties->ops.submit_io);
|
|
||||||
|
|
||||||
io->obj->type->properties->ops.submit_io(io);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ocf_dobj_submit_flush(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!io->obj->type->properties->ops.submit_flush);
|
|
||||||
/*
|
|
||||||
* TODO(rbaldyga): Maybe we should supply function for checking
|
|
||||||
* submit_flush availability and return -ENOTSUPP here?
|
|
||||||
*/
|
|
||||||
if (!io->obj->type->properties->ops.submit_flush)
|
|
||||||
ocf_io_end(io, 0);
|
|
||||||
else
|
|
||||||
io->obj->type->properties->ops.submit_flush(io);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ocf_dobj_submit_discard(struct ocf_io *io)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!io->obj->type->properties->ops.submit_discard);
|
|
||||||
/*
|
|
||||||
* TODO(rbaldyga): Maybe we should supply function for checking
|
|
||||||
* submit_discard availability and return -ENOTSUPP here?
|
|
||||||
*/
|
|
||||||
if (!io->obj->type->properties->ops.submit_discard)
|
|
||||||
ocf_io_end(io, 0);
|
|
||||||
else
|
|
||||||
io->obj->type->properties->ops.submit_discard(io);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ocf_dobj_submit_metadata(struct ocf_io *io)
|
static inline void ocf_dobj_submit_metadata(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
ENV_BUG_ON(!io->obj->type->properties->ops.submit_metadata);
|
ENV_BUG_ON(!io->obj->type->properties->ops.submit_metadata);
|
||||||
@ -86,30 +46,4 @@ static inline void ocf_dobj_submit_write_zeroes(struct ocf_io *io)
|
|||||||
io->obj->type->properties->ops.submit_write_zeroes(io);
|
io->obj->type->properties->ops.submit_write_zeroes(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int ocf_data_obj_open(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!obj->type->properties->ops.open);
|
|
||||||
|
|
||||||
return obj->type->properties->ops.open(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ocf_data_obj_close(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!obj->type->properties->ops.close);
|
|
||||||
|
|
||||||
obj->type->properties->ops.close(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned int ocf_data_obj_get_max_io_size(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
ENV_BUG_ON(!obj->type->properties->ops.get_max_io_size);
|
|
||||||
|
|
||||||
return obj->type->properties->ops.get_max_io_size(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int ocf_data_obj_is_atomic(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
return obj->type->properties->caps.atomic_writes;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /*__OCF_DATA_OBJ_PRIV_H__ */
|
#endif /*__OCF_DATA_OBJ_PRIV_H__ */
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#ifndef __OCF_LOGGER_PRIV_H__
|
#ifndef __OCF_LOGGER_PRIV_H__
|
||||||
#define __OCF_LOGGER_PRIV_H__
|
#define __OCF_LOGGER_PRIV_H__
|
||||||
|
|
||||||
|
#include "ocf/ocf_logger.h"
|
||||||
|
|
||||||
__attribute__((format(printf, 3, 4)))
|
__attribute__((format(printf, 3, 4)))
|
||||||
int ocf_log_raw(const struct ocf_logger *logger, ocf_logger_lvl_t lvl,
|
int ocf_log_raw(const struct ocf_logger *logger, ocf_logger_lvl_t lvl,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
|
@ -30,7 +30,7 @@ int ocf_metadata_get_atomic_entry(ocf_cache_t cache,
|
|||||||
OCF_CHECK_NULL(cache);
|
OCF_CHECK_NULL(cache);
|
||||||
OCF_CHECK_NULL(entry);
|
OCF_CHECK_NULL(entry);
|
||||||
|
|
||||||
if (addr > ocf_data_obj_get_length(&cache->device->obj))
|
if (addr > ocf_dobj_get_length(&cache->device->obj))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (addr < cache->device->metadata_offset) {
|
if (addr < cache->device->metadata_offset) {
|
||||||
|
@ -275,7 +275,7 @@ int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
|
|||||||
|
|
||||||
ENV_BUG_ON(env_memset(stats, sizeof(*stats), 0));
|
ENV_BUG_ON(env_memset(stats, sizeof(*stats), 0));
|
||||||
|
|
||||||
stats->core_size_bytes = ocf_data_obj_get_length(
|
stats->core_size_bytes = ocf_dobj_get_length(
|
||||||
&cache->core[core_id].obj);
|
&cache->core[core_id].obj);
|
||||||
stats->core_size = ocf_bytes_2_lines_round_up(cache,
|
stats->core_size = ocf_bytes_2_lines_round_up(cache,
|
||||||
stats->core_size_bytes);
|
stats->core_size_bytes);
|
||||||
|
@ -55,6 +55,7 @@ const char *__wrap_ocf_get_io_iface_name(ocf_cache_mode_t cache_mode)
|
|||||||
|
|
||||||
ocf_ctx_t __wrap_ocf_cache_get_ctx(ocf_cache_t cache)
|
ocf_ctx_t __wrap_ocf_cache_get_ctx(ocf_cache_t cache)
|
||||||
{
|
{
|
||||||
|
return cache->owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __wrap_ocf_log_raw(const struct ocf_logger *logger, ocf_logger_lvl_t lvl,
|
int __wrap_ocf_log_raw(const struct ocf_logger *logger, ocf_logger_lvl_t lvl,
|
||||||
@ -105,19 +106,23 @@ char *__wrap_ocf_cache_get_name(ocf_cache_t cache)
|
|||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test01(void **state)
|
static void _cache_mng_set_cache_mode_test01(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = -20;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_none;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 0;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
|
|
||||||
print_test_description("Invalid new mode produces appropirate error code");
|
print_test_description("Invalid new mode produces appropirate error code");
|
||||||
|
|
||||||
cache.conf_meta = test_malloc(sizeof(struct ocf_superblock_config));
|
|
||||||
mode_old = -20;
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
mode_new = ocf_cache_mode_none;
|
|
||||||
flush = 0;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 0);
|
will_return(__wrap_ocf_cache_mode_is_valid, 0);
|
||||||
|
|
||||||
@ -125,25 +130,27 @@ static void _cache_mng_set_cache_mode_test01(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, -OCF_ERR_INVAL);
|
assert_int_equal(result, -OCF_ERR_INVAL);
|
||||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||||
|
|
||||||
test_free(cache.conf_meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test02(void **state)
|
static void _cache_mng_set_cache_mode_test02(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = ocf_cache_mode_wt;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_wt;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 0;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
|
|
||||||
print_test_description("Attempt to set mode the same as previous");
|
print_test_description("Attempt to set mode the same as previous");
|
||||||
|
|
||||||
mode_old = mode_new = ocf_cache_mode_wt;
|
|
||||||
flush = 0;
|
|
||||||
|
|
||||||
cache.conf_meta = test_malloc(sizeof(struct ocf_superblock_config));
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||||
|
|
||||||
@ -154,25 +161,28 @@ static void _cache_mng_set_cache_mode_test02(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, 0);
|
assert_int_equal(result, 0);
|
||||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||||
|
|
||||||
test_free(cache.conf_meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test03(void **state)
|
static void _cache_mng_set_cache_mode_test03(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = ocf_cache_mode_wt;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_pt;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 1;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
|
|
||||||
print_test_description("Flush flag is set, but operation failed -"
|
print_test_description("Flush flag is set, but operation failed -"
|
||||||
" check if error code is correct");
|
" check if error code is correct");
|
||||||
|
|
||||||
mode_old = ocf_cache_mode_wt;
|
|
||||||
mode_new = ocf_cache_mode_pt;
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
flush = 1;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||||
|
|
||||||
@ -187,23 +197,26 @@ static void _cache_mng_set_cache_mode_test03(void **state)
|
|||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test04(void **state)
|
static void _cache_mng_set_cache_mode_test04(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = ocf_cache_mode_wb;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_wa;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 0;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
print_test_description("Flush flag is not set, "
|
print_test_description("Flush flag is not set, "
|
||||||
"old cache mode is write back. "
|
"old cache mode is write back. "
|
||||||
"Setting new cache mode is succesfull");
|
"Setting new cache mode is succesfull");
|
||||||
|
|
||||||
mode_old = ocf_cache_mode_wb;
|
|
||||||
mode_new = ocf_cache_mode_wa;
|
|
||||||
flush = 0;
|
|
||||||
|
|
||||||
cache.conf_meta = test_malloc(sizeof(struct ocf_superblock_config));
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||||
|
|
||||||
@ -226,28 +239,29 @@ static void _cache_mng_set_cache_mode_test04(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, 0);
|
assert_int_equal(result, 0);
|
||||||
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
||||||
|
|
||||||
test_free(cache.conf_meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test05(void **state)
|
static void _cache_mng_set_cache_mode_test05(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = ocf_cache_mode_wt;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_wa;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 0;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
print_test_description("Flush flag is not set, "
|
print_test_description("Flush flag is not set, "
|
||||||
"flushing metadata superblock fails");
|
"flushing metadata superblock fails");
|
||||||
|
|
||||||
mode_old = ocf_cache_mode_wt;
|
|
||||||
mode_new = ocf_cache_mode_wa;
|
|
||||||
flush = 0;
|
|
||||||
|
|
||||||
cache.conf_meta = test_malloc(sizeof(struct ocf_superblock_config));
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||||
|
|
||||||
@ -261,25 +275,27 @@ static void _cache_mng_set_cache_mode_test05(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, -OCF_ERR_WRITE_CACHE);
|
assert_int_equal(result, -OCF_ERR_WRITE_CACHE);
|
||||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||||
|
|
||||||
test_free(cache.conf_meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test06(void **state)
|
static void _cache_mng_set_cache_mode_test06(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = ocf_cache_mode_wt;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_wa;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 0;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
print_test_description("No flush, mode changed successfully");
|
print_test_description("No flush, mode changed successfully");
|
||||||
mode_old = ocf_cache_mode_wt;
|
|
||||||
mode_new = ocf_cache_mode_wa;
|
|
||||||
flush = 0;
|
|
||||||
|
|
||||||
cache.conf_meta = test_malloc(sizeof(struct ocf_superblock_config));
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||||
@ -294,25 +310,26 @@ static void _cache_mng_set_cache_mode_test06(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, 0);
|
assert_int_equal(result, 0);
|
||||||
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
||||||
|
|
||||||
test_free(cache.conf_meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cache_mng_set_cache_mode_test07(void **state)
|
static void _cache_mng_set_cache_mode_test07(void **state)
|
||||||
{
|
{
|
||||||
|
ocf_cache_mode_t mode_old = ocf_cache_mode_wt;
|
||||||
|
ocf_cache_mode_t mode_new = ocf_cache_mode_wa;
|
||||||
|
struct ocf_ctx ctx = {
|
||||||
|
.logger = 0x1, /* Just not NULL, we don't care. */
|
||||||
|
};
|
||||||
|
struct ocf_superblock_config sb_config = {
|
||||||
|
.cache_mode = mode_old,
|
||||||
|
};
|
||||||
|
struct ocf_cache cache = {
|
||||||
|
.owner = &ctx,
|
||||||
|
.conf_meta = &sb_config,
|
||||||
|
};
|
||||||
|
uint8_t flush = 1;
|
||||||
int result;
|
int result;
|
||||||
struct ocf_cache cache;
|
|
||||||
ocf_cache_mode_t mode_old, mode_new;
|
|
||||||
uint8_t flush;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
print_test_description("Flush performed, mode changed successfully");
|
print_test_description("Flush performed, mode changed successfully");
|
||||||
mode_old = ocf_cache_mode_wt;
|
|
||||||
mode_new = ocf_cache_mode_wa;
|
|
||||||
flush = 1;
|
|
||||||
|
|
||||||
cache.conf_meta = test_malloc(sizeof(struct ocf_superblock_config));
|
|
||||||
cache.conf_meta->cache_mode = mode_old;
|
|
||||||
|
|
||||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||||
@ -330,8 +347,6 @@ static void _cache_mng_set_cache_mode_test07(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, 0);
|
assert_int_equal(result, 0);
|
||||||
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
||||||
|
|
||||||
test_free(cache.conf_meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user