Core data object

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2019-01-04 08:33:34 +01:00
parent 1b0b2597d3
commit 4be6761a18
23 changed files with 769 additions and 543 deletions

View File

@@ -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);
/**
* @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
*
@@ -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)
{
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
*/
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
*
* @param[in] io IO to be submitted
* @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
*
* @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 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
*
* @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
*
* @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

View File

@@ -136,6 +136,9 @@ struct ocf_data_obj_properties {
struct ocf_data_obj_ops ops;
/*!< Data object operations */
struct ocf_io_ops io_ops;
/*!< IO operations */
};
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;
}
/**
* @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
*
@@ -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);
/**
* @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
*
* @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);
@@ -258,7 +188,148 @@ void ocf_data_obj_del_io(struct ocf_io* io);
* @brief Return io context data
*
* @param[in] io ocf io handle
*
* @return ocf_io private context data
*/
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__ */