Merge pull request #71 from robertbaldyga/asynchronous-api
Make management API asynchronous
This commit is contained in:
commit
56f4d34920
@ -55,17 +55,6 @@ static inline const struct ocf_volume_uuid *ocf_core_get_uuid(ocf_core_t core)
|
||||
return ocf_volume_get_uuid(ocf_core_get_volume(core));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Asociate new UUID value with given core
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[in] uuid new core uuid
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Fail
|
||||
*/
|
||||
int ocf_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid);
|
||||
|
||||
/**
|
||||
* @brief Get sequential cutoff threshold of given core object
|
||||
*
|
||||
@ -135,30 +124,6 @@ ocf_core_state_t ocf_core_get_state(ocf_core_t core);
|
||||
*/
|
||||
int ocf_core_get(ocf_cache_t cache, ocf_core_id_t id, ocf_core_t *core);
|
||||
|
||||
/**
|
||||
* @brief Set persistent user metadata for given core
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[in] data User data buffer
|
||||
* @param[in] size Size of user data buffer
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Core getting failed
|
||||
*/
|
||||
int ocf_core_set_user_metadata(ocf_core_t core, void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Get persistent user metadata from given core
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[out] data User data buffer
|
||||
* @param[in] size Size of user data buffer
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Core getting failed
|
||||
*/
|
||||
int ocf_core_get_user_metadata(ocf_core_t core, void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Allocate new ocf_io
|
||||
*
|
||||
|
337
inc/ocf_mngt.h
337
inc/ocf_mngt.h
@ -356,144 +356,285 @@ struct ocf_mngt_cache_device_config {
|
||||
int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
struct ocf_mngt_cache_config *cfg);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of cache stop operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_stop_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Stop cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
*
|
||||
* @retval 0 Cache successfully stopped
|
||||
* @retval Non-zero Error occurred during stopping cache
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_stop(ocf_cache_t cache);
|
||||
void ocf_mngt_cache_stop(ocf_cache_t cache,
|
||||
ocf_mngt_cache_stop_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of cache attach operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_attach_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Attach caching device to cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] device_cfg Caching device configuration
|
||||
*
|
||||
* @retval 0 Cache cache successfully attached
|
||||
* @retval Non-zero Error occurred during attaching cache
|
||||
* @param[in] cfg Caching device configuration
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *device_cfg);
|
||||
void ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *cfg,
|
||||
ocf_mngt_cache_attach_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of cache detach operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_detach_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Detach caching cache
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
*
|
||||
* @retval 0 Cache cache successfully detached
|
||||
* @retval Non-zero Error occurred during stopping cache
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_detach(ocf_cache_t cache);
|
||||
void ocf_mngt_cache_detach(ocf_cache_t cache,
|
||||
ocf_mngt_cache_detach_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of cache load operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_load_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Load cache instance
|
||||
*
|
||||
* @param[in] ctx OCF context
|
||||
* @param[out] cache Cache handle
|
||||
* @param[in] device_cfg Caching device configuration
|
||||
*
|
||||
* @retval 0 Cache successfully loaded
|
||||
* @retval Non-zero Error occurred during loading cache
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] cfg Caching device configuration
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_load(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
struct ocf_mngt_cache_device_config *device_cfg);
|
||||
void ocf_mngt_cache_load(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *cfg,
|
||||
ocf_mngt_cache_load_end_t cmpl, void *priv);
|
||||
|
||||
/* Adding and removing cores */
|
||||
|
||||
/**
|
||||
* @brief Completion callback of add core operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core Core handle on success or NULL on failure
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_add_core_end_t)(ocf_cache_t cache,
|
||||
ocf_core_t core, void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Add core to cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[out] core Core object handle
|
||||
* @param[in] cfg Core configuration
|
||||
*
|
||||
* @retval 0 Core successfully added core to cache
|
||||
* @retval Non-zero Error occurred and adding core failed
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
|
||||
struct ocf_mngt_core_config *cfg);
|
||||
void ocf_mngt_cache_add_core(ocf_cache_t cache,
|
||||
struct ocf_mngt_core_config *cfg,
|
||||
ocf_mngt_cache_add_core_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of remove core operation
|
||||
*
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_remove_core_end_t)(void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Remove core from cache instance
|
||||
*
|
||||
* @param[in] cache Core handle
|
||||
*
|
||||
* @retval 0 Core successfully removed from cache
|
||||
* @retval Non-zero Error occurred and removing core failed
|
||||
* @param[in] core Core handle
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_remove_core(ocf_core_t core);
|
||||
void ocf_mngt_cache_remove_core(ocf_core_t core,
|
||||
ocf_mngt_cache_remove_core_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of detach core operation
|
||||
*
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_detach_core_end_t)(void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Detach core from cache instance
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
*
|
||||
* @retval 0 Core successfully detached from cache
|
||||
* @retval Non-zero Error occurred and detaching core failed
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_detach_core(ocf_core_t core);
|
||||
void ocf_mngt_cache_detach_core(ocf_core_t core,
|
||||
ocf_mngt_cache_detach_core_end_t cmpl, void *priv);
|
||||
|
||||
/* Flush operations */
|
||||
|
||||
/**
|
||||
* @brief Completion callback of cache flush operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_cache_flush_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Flush data from given cache
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] interruption Allow for interruption
|
||||
*
|
||||
* @retval 0 Successfully flushed given cache
|
||||
* @retval Non-zero Error occurred and flushing cache failed
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption);
|
||||
void ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption,
|
||||
ocf_mngt_cache_flush_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of core flush operation
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_core_flush_end_t)(ocf_core_t core,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Flush data to given core
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] interruption Allow for interruption
|
||||
*
|
||||
* @retval 0 Successfully flushed data to given core
|
||||
* @retval Non-zero Error occurred and flushing data to core failed
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_core_flush(ocf_core_t core, bool interruption);
|
||||
void ocf_mngt_core_flush(ocf_core_t core, bool interruption,
|
||||
ocf_mngt_core_flush_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Interrupt existing flushing of cache or core
|
||||
* @brief Completion callback of cache purge operation
|
||||
*
|
||||
* @param[in] cache Cache instance
|
||||
*
|
||||
* @retval 0 Operation success
|
||||
* @retval Non-zero Operation failure
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
int ocf_mngt_cache_flush_interrupt(ocf_cache_t cache);
|
||||
typedef void (*ocf_mngt_cache_purge_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Purge data from given cache
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
void ocf_mngt_cache_purge(ocf_cache_t cache,
|
||||
ocf_mngt_cache_purge_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of core purge operation
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
typedef void (*ocf_mngt_core_purge_end_t)(ocf_core_t core,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Purge data to given core
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] interruption Allow for interruption
|
||||
*
|
||||
* @retval 0 Successfully purged data to given core
|
||||
* @retval Non-zero Error occurred and purging data to core failed
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
int ocf_mngt_core_purge(ocf_core_t core, bool interruption);
|
||||
void ocf_mngt_core_purge(ocf_core_t core,
|
||||
ocf_mngt_core_purge_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Purge data from given cache
|
||||
* @brief Interrupt existing flushing of cache or core
|
||||
*
|
||||
* @param[in] cache Cache instance
|
||||
*/
|
||||
void ocf_mngt_cache_flush_interrupt(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief Completion callback of save operation
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] interruption Allow for interruption
|
||||
*
|
||||
* @retval 0 Successfully purged given cache
|
||||
* @retval Non-zero Error occurred and purging cache failed
|
||||
* @param[in] priv Callback context
|
||||
* @param[in] error Error code (zero on success)
|
||||
*/
|
||||
int ocf_mngt_cache_purge(ocf_cache_t cache, bool interruption);
|
||||
typedef void (*ocf_mngt_cache_save_end_t)(ocf_cache_t cache,
|
||||
void *priv, int error);
|
||||
|
||||
/**
|
||||
* @brief Save cache configuration data on cache volume
|
||||
*
|
||||
* This function should be called after changing cache or core parameters
|
||||
* in order to make changes persistent.
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] cmpl Completion callback
|
||||
* @param[in] priv Completion callback context
|
||||
*/
|
||||
void ocf_mngt_cache_save(ocf_cache_t cache,
|
||||
ocf_mngt_cache_save_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Set cache mode in given cache
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] mode Cache mode to set
|
||||
*
|
||||
* @retval 0 Cache mode have been set successfully
|
||||
* @retval Non-zero Error occurred and cache mode not been set
|
||||
*/
|
||||
int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Set cleaning policy in given cache
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] type Cleainig policy type
|
||||
*
|
||||
@ -516,6 +657,9 @@ int ocf_mngt_cache_cleaning_get_policy(ocf_cache_t cache, ocf_cleaning_t *type);
|
||||
/**
|
||||
* @brief Set cleaning parameter in given cache
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] param_id Cleaning policy parameter id
|
||||
* @param[in] param_value Cleaning policy parameter value
|
||||
@ -581,6 +725,9 @@ struct ocf_mngt_io_classes_config {
|
||||
/**
|
||||
* @brief Configure IO classes in given cache
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] cfg IO class configuration
|
||||
*
|
||||
@ -590,9 +737,53 @@ struct ocf_mngt_io_classes_config {
|
||||
int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
|
||||
const struct ocf_mngt_io_classes_config *cfg);
|
||||
|
||||
/**
|
||||
* @brief Asociate new UUID value with given core
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[in] uuid new core uuid
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Fail
|
||||
*/
|
||||
int ocf_mngt_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid);
|
||||
|
||||
/**
|
||||
* @brief Set persistent user metadata for given core
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[in] data User data buffer
|
||||
* @param[in] size Size of user data buffer
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Core getting failed
|
||||
*/
|
||||
int ocf_mngt_core_set_user_metadata(ocf_core_t core, void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Get persistent user metadata from given core
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[out] data User data buffer
|
||||
* @param[in] size Size of user data buffer
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Core getting failed
|
||||
*/
|
||||
int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Set core sequential cutoff threshold
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] thresh threshold in bytes for sequential cutoff
|
||||
*
|
||||
@ -604,6 +795,9 @@ int ocf_mngt_core_set_seq_cutoff_threshold(ocf_core_t core, uint32_t thresh);
|
||||
/**
|
||||
* @brief Set sequential cutoff threshold for all cores in cache
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] thresh threshold in bytes for sequential cutoff
|
||||
*
|
||||
@ -627,6 +821,9 @@ int ocf_mngt_core_get_seq_cutoff_threshold(ocf_core_t core, uint32_t *thresh);
|
||||
/**
|
||||
* @brief Set core sequential cutoff policy
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] policy sequential cutoff policy
|
||||
*
|
||||
@ -639,6 +836,9 @@ int ocf_mngt_core_set_seq_cutoff_policy(ocf_core_t core,
|
||||
/**
|
||||
* @brief Set sequential cutoff policy for all cores in cache
|
||||
*
|
||||
* @attention This changes only runtime state. To make changes persistent
|
||||
* use function ocf_mngt_cache_save().
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] policy sequential cutoff policy
|
||||
*
|
||||
@ -660,19 +860,6 @@ int ocf_mngt_core_set_seq_cutoff_policy_all(ocf_cache_t cache,
|
||||
int ocf_mngt_core_get_seq_cutoff_policy(ocf_core_t core,
|
||||
ocf_seq_cutoff_policy *policy);
|
||||
|
||||
/**
|
||||
* @brief Set cache mode in given cache
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] mode Cache mode to set
|
||||
* @param[in] flush Perform flushing before switch cache mode
|
||||
*
|
||||
* @retval 0 Cache mode have been set successfully
|
||||
* @retval Non-zero Error occurred and cache mode not been set
|
||||
*/
|
||||
int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode,
|
||||
uint8_t flush);
|
||||
|
||||
/**
|
||||
* @brief Set cache fallback Pass Through error threshold
|
||||
*
|
||||
|
@ -1476,19 +1476,22 @@ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
return result;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *device_cfg)
|
||||
void ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *cfg,
|
||||
ocf_mngt_cache_attach_end_t cmpl, void *priv)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!cache || !device_cfg)
|
||||
return -OCF_ERR_INVAL;
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(cfg);
|
||||
|
||||
result = _ocf_mngt_cache_validate_device_cfg(device_cfg);
|
||||
if (result)
|
||||
return result;
|
||||
result = _ocf_mngt_cache_validate_device_cfg(cfg);
|
||||
if (result) {
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
|
||||
result = _ocf_mngt_cache_attach(cache, device_cfg, false);
|
||||
result = _ocf_mngt_cache_attach(cache, cfg, false);
|
||||
if (!result) {
|
||||
ocf_cache_log(cache, log_info, "Successfully attached\n");
|
||||
} else {
|
||||
@ -1496,7 +1499,7 @@ int ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
"failed\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
cmpl(cache, priv, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1636,32 +1639,36 @@ static void _ocf_mngt_cache_load_log(ocf_cache_t cache)
|
||||
cache, false);
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_load(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
struct ocf_mngt_cache_device_config *device_cfg)
|
||||
void ocf_mngt_cache_load(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *cfg,
|
||||
ocf_mngt_cache_load_end_t cmpl, void *priv)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!ctx || !cache || !device_cfg)
|
||||
return -OCF_ERR_INVAL;
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(cfg);
|
||||
|
||||
result = _ocf_mngt_cache_validate_device_cfg(device_cfg);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
result = _ocf_mngt_cache_attach(*cache, device_cfg, true);
|
||||
result = _ocf_mngt_cache_validate_device_cfg(cfg);
|
||||
if (result) {
|
||||
_ocf_mngt_init_handle_error(*cache, ctx, NULL);
|
||||
return result;
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
|
||||
_ocf_mng_cache_set_valid(*cache);
|
||||
|
||||
_ocf_mngt_cache_load_log(*cache);
|
||||
|
||||
return 0;
|
||||
result = _ocf_mngt_cache_attach(cache, cfg, true);
|
||||
if (result) {
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_stop(ocf_cache_t cache)
|
||||
_ocf_mng_cache_set_valid(cache);
|
||||
|
||||
_ocf_mngt_cache_load_log(cache);
|
||||
|
||||
cmpl(cache, priv, 0);
|
||||
}
|
||||
|
||||
void ocf_mngt_cache_stop(ocf_cache_t cache,
|
||||
ocf_mngt_cache_stop_end_t cmpl, void *priv)
|
||||
{
|
||||
int result;
|
||||
char cache_name[OCF_CACHE_NAME_SIZE];
|
||||
@ -1671,8 +1678,10 @@ int ocf_mngt_cache_stop(ocf_cache_t cache)
|
||||
|
||||
result = env_strncpy(cache_name, sizeof(cache_name),
|
||||
ocf_cache_get_name(cache), sizeof(cache_name));
|
||||
if (result)
|
||||
return result;
|
||||
if (result) {
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = ocf_cache_get_ctx(cache);
|
||||
|
||||
@ -1691,38 +1700,41 @@ int ocf_mngt_cache_stop(ocf_cache_t cache)
|
||||
cache_name);
|
||||
}
|
||||
|
||||
return result;
|
||||
cmpl(cache, priv, result);
|
||||
}
|
||||
|
||||
static int _cache_mng_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode,
|
||||
uint8_t flush)
|
||||
void ocf_mngt_cache_save(ocf_cache_t cache,
|
||||
ocf_mngt_cache_save_end_t cmpl, void *priv)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = ocf_metadata_flush_superblock(cache);
|
||||
if (result) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Failed to flush superblock! Changes "
|
||||
"in cache config are not persistent!\n");
|
||||
}
|
||||
|
||||
cmpl(cache, priv, result ? -OCF_ERR_WRITE_CACHE : 0);
|
||||
}
|
||||
|
||||
static int _cache_mng_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode)
|
||||
{
|
||||
ocf_cache_mode_t mode_new = mode;
|
||||
ocf_cache_mode_t mode_old = cache->conf_meta->cache_mode;
|
||||
int result = 0;
|
||||
|
||||
/* Check if IO interface type is valid */
|
||||
if (!ocf_cache_mode_is_valid(mode))
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (mode_new == mode_old) {
|
||||
if (mode == mode_old) {
|
||||
ocf_cache_log(cache, log_info, "Cache mode '%s' is already set\n",
|
||||
ocf_get_io_iface_name(mode_new));
|
||||
ocf_get_io_iface_name(mode));
|
||||
return 0;
|
||||
}
|
||||
|
||||
cache->conf_meta->cache_mode = mode_new;
|
||||
cache->conf_meta->cache_mode = mode;
|
||||
|
||||
if (flush) {
|
||||
/* Flush required, do it, do it, do it... */
|
||||
result = ocf_mngt_cache_flush(cache, true);
|
||||
|
||||
if (result) {
|
||||
cache->conf_meta->cache_mode = mode_old;
|
||||
return result;
|
||||
}
|
||||
|
||||
} else if (ocf_cache_mode_wb == mode_old) {
|
||||
if (ocf_cache_mode_wb == mode_old) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i != OCF_CORE_MAX; ++i) {
|
||||
@ -1735,33 +1747,26 @@ static int _cache_mng_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode,
|
||||
}
|
||||
}
|
||||
|
||||
if (ocf_metadata_flush_superblock(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Failed to store cache mode "
|
||||
"change. Reverting\n");
|
||||
cache->conf_meta->cache_mode = mode_old;
|
||||
return -OCF_ERR_WRITE_CACHE;
|
||||
}
|
||||
|
||||
ocf_cache_log(cache, log_info, "Changing cache mode from '%s' to '%s' "
|
||||
"successful\n", ocf_get_io_iface_name(mode_old),
|
||||
ocf_get_io_iface_name(mode_new));
|
||||
ocf_get_io_iface_name(mode));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode,
|
||||
uint8_t flush)
|
||||
int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode)
|
||||
{
|
||||
int result;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (!ocf_cache_mode_is_valid(mode)) {
|
||||
ocf_cache_log(cache, log_err, "Cache mode %u is invalid\n", mode);
|
||||
ocf_cache_log(cache, log_err, "Cache mode %u is invalid\n",
|
||||
mode);
|
||||
return -OCF_ERR_INVAL;
|
||||
}
|
||||
|
||||
result = _cache_mng_set_cache_mode(cache, mode, flush);
|
||||
result = _cache_mng_set_cache_mode(cache, mode);
|
||||
|
||||
if (result) {
|
||||
const char *name = ocf_get_io_iface_name(mode);
|
||||
@ -1827,32 +1832,36 @@ int ocf_mngt_cache_get_fallback_pt_error_threshold(ocf_cache_t cache,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_detach(ocf_cache_t cache)
|
||||
struct ocf_mngt_cache_detach_context {
|
||||
ocf_mngt_cache_detach_end_t cmpl;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
static void ocf_mngt_cache_detach_flush_cmpl(ocf_cache_t cache,
|
||||
void *priv, int error)
|
||||
{
|
||||
struct ocf_mngt_cache_detach_context *context = priv;
|
||||
int i, j, no;
|
||||
int result;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
no = cache->conf_meta->core_count;
|
||||
|
||||
if (!env_atomic_read(&cache->attached))
|
||||
return -EINVAL;
|
||||
|
||||
/* prevent dirty io */
|
||||
env_atomic_inc(&cache->flush_started);
|
||||
|
||||
result = ocf_mngt_cache_flush(cache, true);
|
||||
if (result)
|
||||
return result;
|
||||
if (error) {
|
||||
ENV_BUG_ON(env_atomic_dec_return(&cache->flush_started) < 0);
|
||||
context->cmpl(cache, context->priv, error);
|
||||
env_vfree(context);
|
||||
return;
|
||||
}
|
||||
|
||||
/* wait for all requests referencing cacheline metadata to finish */
|
||||
env_atomic_set(&cache->attached, 0);
|
||||
|
||||
/* FIXME: This should be asynchronous! */
|
||||
env_waitqueue_wait(cache->pending_cache_wq,
|
||||
!env_atomic_read(&cache->pending_cache_requests));
|
||||
|
||||
ENV_BUG_ON(env_atomic_dec_return(&cache->flush_started) < 0);
|
||||
|
||||
no = cache->conf_meta->core_count;
|
||||
|
||||
/* remove cacheline metadata and cleaning policy meta for all cores */
|
||||
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
|
||||
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
|
||||
@ -1878,5 +1887,33 @@ int ocf_mngt_cache_detach(ocf_cache_t cache)
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
context->cmpl(cache, context->priv, result);
|
||||
env_vfree(context);
|
||||
}
|
||||
|
||||
void ocf_mngt_cache_detach(ocf_cache_t cache,
|
||||
ocf_mngt_cache_detach_end_t cmpl, void *priv)
|
||||
{
|
||||
struct ocf_mngt_cache_detach_context *context;
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (!env_atomic_read(&cache->attached)) {
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
context = env_vmalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(cache, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
|
||||
context->cmpl = cmpl;
|
||||
context->priv = priv;
|
||||
|
||||
/* prevent dirty io */
|
||||
env_atomic_inc(&cache->flush_started);
|
||||
|
||||
ocf_mngt_cache_flush(cache, true, ocf_mngt_cache_detach_flush_cmpl,
|
||||
context);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
|
||||
goto error_out;
|
||||
|
||||
if (cfg->user_metadata.data && cfg->user_metadata.size > 0) {
|
||||
result = ocf_core_set_user_metadata_raw(tmp_core,
|
||||
result = ocf_mngt_core_set_user_metadata(tmp_core,
|
||||
cfg->user_metadata.data,
|
||||
cfg->user_metadata.size);
|
||||
if (result)
|
||||
@ -362,51 +362,60 @@ int ocf_mngt_core_init_front_volume(ocf_core_t core)
|
||||
return ocf_volume_open(&core->front_volume);
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
|
||||
struct ocf_mngt_core_config *cfg)
|
||||
void ocf_mngt_cache_add_core(ocf_cache_t cache,
|
||||
struct ocf_mngt_core_config *cfg,
|
||||
ocf_mngt_cache_add_core_end_t cmpl, void *priv)
|
||||
{
|
||||
int result;
|
||||
char core_name[OCF_CORE_NAME_SIZE];
|
||||
ocf_core_t core = NULL;
|
||||
int result;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(core);
|
||||
|
||||
result = _ocf_mngt_find_core_id(cache, cfg);
|
||||
if (result)
|
||||
return result;
|
||||
if (result) {
|
||||
cmpl(cache, NULL, priv, result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cfg->name) {
|
||||
result = env_strncpy(core_name, sizeof(core_name), cfg->name,
|
||||
sizeof(core_name));
|
||||
if (result)
|
||||
return result;
|
||||
if (result) {
|
||||
cmpl(cache, NULL, priv, result);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
result = snprintf(core_name, sizeof(core_name), "core%hu",
|
||||
cfg->core_id);
|
||||
if (result < 0)
|
||||
return result;
|
||||
if (result < 0) {
|
||||
cmpl(cache, NULL, priv, result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result = ocf_core_set_name(&cache->core[cfg->core_id], core_name,
|
||||
sizeof(core_name));
|
||||
if (result)
|
||||
return result;
|
||||
if (result) {
|
||||
cmpl(cache, NULL, priv, result);
|
||||
return;
|
||||
}
|
||||
|
||||
ocf_cache_log(cache, log_debug, "Inserting core %s\n", core_name);
|
||||
|
||||
if (cfg->try_add)
|
||||
result = _ocf_mngt_cache_try_add_core(cache, core, cfg);
|
||||
result = _ocf_mngt_cache_try_add_core(cache, &core, cfg);
|
||||
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_volume(*core);
|
||||
result = ocf_mngt_core_init_front_volume(core);
|
||||
|
||||
out:
|
||||
if (!result) {
|
||||
ocf_core_log(*core, log_info, "Successfully added\n");
|
||||
ocf_core_log(core, log_info, "Successfully added\n");
|
||||
} else {
|
||||
if (result == -OCF_ERR_CORE_NOT_AVAIL) {
|
||||
ocf_cache_log(cache, log_err, "Core %s is zero size\n",
|
||||
@ -416,24 +425,13 @@ out:
|
||||
core_name);
|
||||
}
|
||||
|
||||
return result;
|
||||
cmpl(cache, core, priv, result);
|
||||
}
|
||||
|
||||
static int _ocf_mngt_cache_remove_core(ocf_core_t core, bool detach)
|
||||
static int _ocf_mngt_cache_remove_core(ocf_core_t core)
|
||||
{
|
||||
struct ocf_cache *cache = core->volume.cache;
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
int status;
|
||||
|
||||
if (detach) {
|
||||
status = cache_mng_core_close(cache, core_id);
|
||||
if (!status) {
|
||||
cache->ocf_core_inactive_count++;
|
||||
env_bit_set(ocf_cache_state_incomplete,
|
||||
&cache->cache_state);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
ocf_volume_close(&core->front_volume);
|
||||
|
||||
@ -452,7 +450,8 @@ static int _ocf_mngt_cache_remove_core(ocf_core_t core, bool detach)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_remove_core(ocf_core_t core)
|
||||
void ocf_mngt_cache_remove_core(ocf_core_t core,
|
||||
ocf_mngt_cache_remove_core_end_t cmpl, void *priv)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
const char *core_name = ocf_core_get_name(core);
|
||||
@ -462,7 +461,7 @@ int ocf_mngt_cache_remove_core(ocf_core_t core)
|
||||
|
||||
core_name = ocf_core_get_name(core);
|
||||
|
||||
result = _ocf_mngt_cache_remove_core(core, false);
|
||||
result = _ocf_mngt_cache_remove_core(core);
|
||||
if (!result) {
|
||||
ocf_cache_log(cache, log_info, "Core %s successfully removed\n",
|
||||
core_name);
|
||||
@ -471,10 +470,27 @@ int ocf_mngt_cache_remove_core(ocf_core_t core)
|
||||
core_name);
|
||||
}
|
||||
|
||||
return result;
|
||||
cmpl(priv, result);
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_detach_core(ocf_core_t core)
|
||||
static int _ocf_mngt_cache_detach_core(ocf_core_t core)
|
||||
{
|
||||
struct ocf_cache *cache = core->volume.cache;
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
int status;
|
||||
|
||||
status = cache_mng_core_close(cache, core_id);
|
||||
if (!status) {
|
||||
cache->ocf_core_inactive_count++;
|
||||
env_bit_set(ocf_cache_state_incomplete,
|
||||
&cache->cache_state);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void ocf_mngt_cache_detach_core(ocf_core_t core,
|
||||
ocf_mngt_cache_detach_core_end_t cmpl, void *priv)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
const char *core_name = ocf_core_get_name(core);
|
||||
@ -482,7 +498,7 @@ int ocf_mngt_cache_detach_core(ocf_core_t core)
|
||||
|
||||
ocf_core_log(core, log_debug, "Detaching core\n");
|
||||
|
||||
result = _ocf_mngt_cache_remove_core(core, true);
|
||||
result = _ocf_mngt_cache_detach_core(core);
|
||||
if (!result) {
|
||||
ocf_cache_log(cache, log_info, "Core %s successfully detached\n",
|
||||
core_name);
|
||||
@ -491,7 +507,77 @@ int ocf_mngt_cache_detach_core(ocf_core_t core)
|
||||
core_name);
|
||||
}
|
||||
|
||||
cmpl(priv, result);
|
||||
}
|
||||
|
||||
int ocf_mngt_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid)
|
||||
{
|
||||
struct ocf_volume_uuid *current_uuid;
|
||||
int result;
|
||||
int diff;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
OCF_CHECK_NULL(uuid);
|
||||
OCF_CHECK_NULL(uuid->data);
|
||||
|
||||
current_uuid = &ocf_core_get_volume(core)->uuid;
|
||||
|
||||
result = env_memcmp(current_uuid->data, current_uuid->size,
|
||||
uuid->data, uuid->size, &diff);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (!diff) {
|
||||
/* UUIDs are identical */
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = ocf_metadata_set_core_uuid(core, uuid, NULL);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
ocf_volume_set_uuid(&core->volume, uuid);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int ocf_mngt_core_set_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
uint32_t core_id;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
OCF_CHECK_NULL(data);
|
||||
|
||||
cache = ocf_core_get_cache(core);
|
||||
core_id = ocf_core_get_id(core);
|
||||
|
||||
if (size > OCF_CORE_USER_DATA_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
env_memcpy(cache->core_conf_meta[core_id].user_data,
|
||||
OCF_CORE_USER_DATA_SIZE, data, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||
{
|
||||
uint32_t core_id;
|
||||
ocf_cache_t cache;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
|
||||
core_id = ocf_core_get_id(core);
|
||||
cache = ocf_core_get_cache(core);
|
||||
|
||||
if (size > sizeof(cache->core_conf_meta[core_id].user_data))
|
||||
return -EINVAL;
|
||||
|
||||
env_memcpy(data, size, cache->core_conf_meta[core_id].user_data,
|
||||
OCF_CORE_USER_DATA_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _cache_mng_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
|
||||
@ -510,14 +596,6 @@ static int _cache_mng_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
|
||||
}
|
||||
cache->core_conf_meta[core_id].seq_cutoff_threshold = threshold;
|
||||
|
||||
if (ocf_metadata_flush_superblock(cache)) {
|
||||
ocf_core_log(core, log_err, "Failed to store sequential "
|
||||
"cutoff threshold change. Reverting\n");
|
||||
cache->core_conf_meta[core_id].seq_cutoff_threshold =
|
||||
threshold_old;
|
||||
return -OCF_ERR_WRITE_CACHE;
|
||||
}
|
||||
|
||||
ocf_core_log(core, log_info, "Changing sequential cutoff "
|
||||
"threshold from %u to %u bytes successful\n",
|
||||
threshold_old, threshold);
|
||||
@ -582,13 +660,6 @@ static int _cache_mng_set_core_seq_cutoff_policy(ocf_core_t core, void *cntx)
|
||||
|
||||
cache->core_conf_meta[core_id].seq_cutoff_policy = policy;
|
||||
|
||||
if (ocf_metadata_flush_superblock(cache)) {
|
||||
ocf_core_log(core, log_err, "Failed to store sequential "
|
||||
"cutoff policy change. Reverting\n");
|
||||
cache->core_conf_meta[core_id].seq_cutoff_policy = policy_old;
|
||||
return -OCF_ERR_WRITE_CACHE;
|
||||
}
|
||||
|
||||
ocf_core_log(core, log_info,
|
||||
"Changing sequential cutoff policy from %s to %s\n",
|
||||
_cache_mng_seq_cutoff_policy_get_name(policy_old),
|
||||
|
@ -461,7 +461,8 @@ static int _ocf_mng_cache_flush(ocf_cache_t cache, bool interruption)
|
||||
return result;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption)
|
||||
void ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption,
|
||||
ocf_mngt_cache_flush_end_t cmpl, void *priv)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
@ -470,19 +471,22 @@ int ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption)
|
||||
if (!ocf_cache_is_device_attached(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush cache - "
|
||||
"cache device is detached\n");
|
||||
return -OCF_ERR_INVAL;
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ocf_cache_is_incomplete(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush cache - "
|
||||
"cache is in incomplete state\n");
|
||||
return -OCF_ERR_CACHE_IN_INCOMPLETE_STATE;
|
||||
cmpl(cache, priv, -OCF_ERR_CACHE_IN_INCOMPLETE_STATE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cache->flush_queue) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Cannot flush cache - no flush queue set\n");
|
||||
return -OCF_ERR_INVAL;
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
ocf_cache_log(cache, log_info, "Flushing cache\n");
|
||||
@ -496,7 +500,7 @@ int ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption)
|
||||
if (!result)
|
||||
ocf_cache_log(cache, log_info, "Flushing cache completed\n");
|
||||
|
||||
return result;
|
||||
cmpl(cache, priv, result);
|
||||
}
|
||||
|
||||
static int _ocf_mng_core_flush(ocf_core_t core, bool interruption)
|
||||
@ -521,7 +525,8 @@ static int _ocf_mng_core_flush(ocf_core_t core, bool interruption)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ocf_mngt_core_flush(ocf_core_t core, bool interruption)
|
||||
void ocf_mngt_core_flush(ocf_core_t core, bool interruption,
|
||||
ocf_mngt_core_flush_end_t cmpl, void *priv)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
int ret = 0;
|
||||
@ -533,19 +538,22 @@ int ocf_mngt_core_flush(ocf_core_t core, bool interruption)
|
||||
if (!ocf_cache_is_device_attached(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush core - "
|
||||
"cache device is detached\n");
|
||||
return -OCF_ERR_INVAL;
|
||||
cmpl(core, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!core->opened) {
|
||||
ocf_core_log(core, log_err, "Cannot flush - core is in "
|
||||
"inactive state\n");
|
||||
return -OCF_ERR_CORE_IN_INACTIVE_STATE;
|
||||
cmpl(core, priv, -OCF_ERR_CORE_IN_INACTIVE_STATE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cache->flush_queue) {
|
||||
ocf_core_log(core, log_err,
|
||||
"Cannot flush core - no flush queue set\n");
|
||||
return -OCF_ERR_INVAL;
|
||||
cmpl(core, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
ocf_core_log(core, log_info, "Flushing\n");
|
||||
@ -559,10 +567,46 @@ int ocf_mngt_core_flush(ocf_core_t core, bool interruption)
|
||||
if (!ret)
|
||||
ocf_cache_log(cache, log_info, "Flushing completed\n");
|
||||
|
||||
return ret;
|
||||
cmpl(core, priv, ret);
|
||||
}
|
||||
|
||||
int ocf_mngt_core_purge(ocf_core_t core, bool interruption)
|
||||
void ocf_mngt_cache_purge(ocf_cache_t cache,
|
||||
ocf_mngt_cache_purge_end_t cmpl, void *priv)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (!cache->flush_queue) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Cannot purge cache - no flush queue set\n");
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
_ocf_mngt_begin_flush(cache);
|
||||
|
||||
ocf_cache_log(cache, log_info, "Purging\n");
|
||||
|
||||
result = _ocf_mng_cache_flush(cache, true);
|
||||
|
||||
if (result)
|
||||
goto out;
|
||||
|
||||
OCF_METADATA_LOCK_WR();
|
||||
result = ocf_metadata_sparse_range(cache, OCF_CORE_ID_INVALID, 0,
|
||||
~0ULL);
|
||||
OCF_METADATA_UNLOCK_WR();
|
||||
|
||||
out:
|
||||
_ocf_mngt_end_flush(cache);
|
||||
|
||||
cmpl(cache, priv, result);
|
||||
}
|
||||
|
||||
|
||||
void ocf_mngt_core_purge(ocf_core_t core,
|
||||
ocf_mngt_core_purge_end_t cmpl, void *priv)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
ocf_core_id_t core_id;
|
||||
@ -577,7 +621,8 @@ int ocf_mngt_core_purge(ocf_core_t core, bool interruption)
|
||||
if (!cache->flush_queue) {
|
||||
ocf_core_log(core, log_err,
|
||||
"Cannot purge core - no flush queue set\n");
|
||||
return -OCF_ERR_INVAL;
|
||||
cmpl(core, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
core_size = ocf_volume_get_length(&cache->core[core_id].volume);
|
||||
@ -587,7 +632,7 @@ int ocf_mngt_core_purge(ocf_core_t core, bool interruption)
|
||||
|
||||
ocf_core_log(core, log_info, "Purging\n");
|
||||
|
||||
result = _ocf_mng_core_flush(core, interruption);
|
||||
result = _ocf_mng_core_flush(core, true);
|
||||
|
||||
if (result)
|
||||
goto out;
|
||||
@ -600,48 +645,15 @@ int ocf_mngt_core_purge(ocf_core_t core, bool interruption)
|
||||
out:
|
||||
_ocf_mngt_end_flush(cache);
|
||||
|
||||
return result;
|
||||
cmpl(core, priv, result);
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_purge(ocf_cache_t cache, bool interruption)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (!cache->flush_queue) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Cannot purge cache - no flush queue set\n");
|
||||
return -OCF_ERR_INVAL;
|
||||
}
|
||||
|
||||
_ocf_mngt_begin_flush(cache);
|
||||
|
||||
ocf_cache_log(cache, log_info, "Purging\n");
|
||||
|
||||
result = _ocf_mng_cache_flush(cache, interruption);
|
||||
|
||||
if (result)
|
||||
goto out;
|
||||
|
||||
OCF_METADATA_LOCK_WR();
|
||||
result = ocf_metadata_sparse_range(cache, OCF_CORE_ID_INVALID, 0,
|
||||
~0ULL);
|
||||
OCF_METADATA_UNLOCK_WR();
|
||||
|
||||
out:
|
||||
_ocf_mngt_end_flush(cache);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_flush_interrupt(ocf_cache_t cache)
|
||||
void ocf_mngt_cache_flush_interrupt(ocf_cache_t cache)
|
||||
{
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
ocf_cache_log(cache, log_alert, "Flushing interrupt\n");
|
||||
cache->flushing_interrupted = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
|
||||
@ -681,24 +693,12 @@ int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
|
||||
|
||||
cache->conf_meta->cleaning_policy_type = type;
|
||||
|
||||
if (type != old_type) {
|
||||
/*
|
||||
* If operation was successfull or cleaning policy changed,
|
||||
* we need to flush superblock.
|
||||
*/
|
||||
if (ocf_metadata_flush_superblock(cache)) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Failed to flush superblock! Changes "
|
||||
"in cache config are not persistent!\n");
|
||||
}
|
||||
}
|
||||
ocf_metadata_unlock(cache, OCF_METADATA_WR);
|
||||
|
||||
ocf_cache_log(cache, log_info, "Changing cleaning policy from "
|
||||
"%s to %s\n", cleaning_policy_ops[old_type].name,
|
||||
cleaning_policy_ops[type].name);
|
||||
|
||||
ocf_metadata_unlock(cache, OCF_METADATA_WR);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -730,18 +730,6 @@ int ocf_mngt_cache_cleaning_set_param(ocf_cache_t cache, ocf_cleaning_t type,
|
||||
ret = cleaning_policy_ops[type].set_cleaning_param(cache,
|
||||
param_id, param_value);
|
||||
|
||||
if (ret == 0) {
|
||||
/*
|
||||
* If operation was successfull or cleaning policy changed,
|
||||
* we need to flush superblock.
|
||||
*/
|
||||
if (ocf_metadata_flush_superblock(cache)) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Failed to flush superblock! Changes "
|
||||
"in cache config are not persistent!\n");
|
||||
}
|
||||
}
|
||||
|
||||
ocf_metadata_unlock(cache, OCF_METADATA_WR);
|
||||
|
||||
return ret;
|
||||
|
@ -283,36 +283,29 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
|
||||
|
||||
result = env_memcpy(old_config, sizeof(&cache->user_parts),
|
||||
cache->user_parts, sizeof(&cache->user_parts));
|
||||
if (result) {
|
||||
env_free(old_config);
|
||||
return result;
|
||||
}
|
||||
if (result)
|
||||
goto out_cpy;
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
result = _ocf_mngt_io_class_edit(cache, &cfg->config[i]);
|
||||
if (result && result != -OCF_ERR_IO_CLASS_NOT_EXIST) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Failed to set new io class config\n");
|
||||
goto err;
|
||||
goto out_edit;
|
||||
}
|
||||
|
||||
result = 0;
|
||||
}
|
||||
|
||||
ocf_part_sort(cache);
|
||||
|
||||
if (ocf_metadata_flush_superblock(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Failed to store new io class config\n");
|
||||
result = -OCF_ERR_WRITE_CACHE;
|
||||
}
|
||||
|
||||
err:
|
||||
out_edit:
|
||||
if (result) {
|
||||
ENV_BUG_ON(env_memcpy(cache->user_parts, sizeof(&cache->user_parts),
|
||||
old_config, sizeof(&cache->user_parts)));
|
||||
}
|
||||
|
||||
out_cpy:
|
||||
OCF_METADATA_UNLOCK_WR();
|
||||
env_free(old_config);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -97,44 +97,6 @@ int ocf_core_get(ocf_cache_t cache, ocf_core_id_t id, ocf_core_t *core)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid)
|
||||
{
|
||||
struct ocf_cache *cache;
|
||||
struct ocf_volume_uuid *current_uuid;
|
||||
int result;
|
||||
int diff;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
OCF_CHECK_NULL(uuid);
|
||||
OCF_CHECK_NULL(uuid->data);
|
||||
|
||||
cache = core->volume.cache;
|
||||
current_uuid = &ocf_core_get_volume(core)->uuid;
|
||||
|
||||
result = env_memcmp(current_uuid->data, current_uuid->size,
|
||||
uuid->data, uuid->size, &diff);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (!diff) {
|
||||
/* UUIDs are identical */
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = ocf_metadata_set_core_uuid(core, uuid, NULL);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
ocf_volume_set_uuid(&core->volume, uuid);
|
||||
|
||||
result = ocf_metadata_flush_superblock(cache);
|
||||
if (result) {
|
||||
result = -OCF_ERR_WRITE_CACHE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core)
|
||||
{
|
||||
uint32_t core_id = ocf_core_get_id(core);
|
||||
@ -151,60 +113,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;
|
||||
}
|
||||
|
||||
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);
|
||||
uint32_t core_id = ocf_core_get_id(core);
|
||||
|
||||
if (size > OCF_CORE_USER_DATA_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
env_memcpy(cache->core_conf_meta[core_id].user_data,
|
||||
OCF_CORE_USER_DATA_SIZE, data, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_core_set_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
int ret;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
OCF_CHECK_NULL(data);
|
||||
|
||||
cache = ocf_core_get_cache(core);
|
||||
|
||||
ret = ocf_core_set_user_metadata_raw(core, data, size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ocf_metadata_flush_superblock(cache);
|
||||
if (ret)
|
||||
return -OCF_ERR_WRITE_CACHE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||
{
|
||||
uint32_t core_id;
|
||||
ocf_cache_t cache;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
|
||||
core_id = ocf_core_get_id(core);
|
||||
cache = ocf_core_get_cache(core);
|
||||
|
||||
if (size > sizeof(cache->core_conf_meta[core_id].user_data))
|
||||
return -EINVAL;
|
||||
|
||||
env_memcpy(data, size, cache->core_conf_meta[core_id].user_data,
|
||||
OCF_CORE_USER_DATA_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
|
||||
bool only_opened)
|
||||
{
|
||||
|
@ -54,8 +54,6 @@ struct ocf_core {
|
||||
|
||||
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_volume_type_init(ocf_ctx_t ctx);
|
||||
|
||||
void ocf_core_volume_type_deinit(ocf_ctx_t ctx);
|
||||
|
@ -73,8 +73,6 @@ int __wrap_ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption)
|
||||
|
||||
int __wrap_ocf_metadata_flush_superblock(struct ocf_cache *cache)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
}
|
||||
|
||||
bool __wrap_env_bit_test(int nr, const volatile unsigned long *addr)
|
||||
@ -118,7 +116,6 @@ static void _cache_mng_set_cache_mode_test01(void **state)
|
||||
.owner = &ctx,
|
||||
.conf_meta = &sb_config,
|
||||
};
|
||||
uint8_t flush = 0;
|
||||
int result;
|
||||
|
||||
print_test_description("Invalid new mode produces appropirate error code");
|
||||
@ -126,7 +123,7 @@ static void _cache_mng_set_cache_mode_test01(void **state)
|
||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||
will_return(__wrap_ocf_cache_mode_is_valid, 0);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new);
|
||||
|
||||
assert_int_equal(result, -OCF_ERR_INVAL);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||
@ -157,45 +154,13 @@ static void _cache_mng_set_cache_mode_test02(void **state)
|
||||
expect_function_call(__wrap_ocf_log_raw);
|
||||
will_return(__wrap_ocf_log_raw, 0);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
print_test_description("Flush flag is set, but operation failed -"
|
||||
" check if error code is correct");
|
||||
|
||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||
|
||||
expect_function_call(__wrap_ocf_mngt_cache_flush);
|
||||
will_return(__wrap_ocf_mngt_cache_flush, -OCF_ERR_NO_MEM);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
|
||||
assert_int_equal(result, -OCF_ERR_NO_MEM);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||
}
|
||||
|
||||
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;
|
||||
@ -209,12 +174,10 @@ static void _cache_mng_set_cache_mode_test04(void **state)
|
||||
.owner = &ctx,
|
||||
.conf_meta = &sb_config,
|
||||
};
|
||||
uint8_t flush = 0;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
print_test_description("Flush flag is not set, "
|
||||
"old cache mode is write back. "
|
||||
print_test_description("Old cache mode is write back. "
|
||||
"Setting new cache mode is succesfull");
|
||||
|
||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||
@ -229,19 +192,16 @@ static void _cache_mng_set_cache_mode_test04(void **state)
|
||||
expect_function_call(__wrap_env_atomic_set);
|
||||
}
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_flush_superblock);
|
||||
will_return(__wrap_ocf_metadata_flush_superblock, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_log_raw);
|
||||
will_return(__wrap_ocf_log_raw, 0);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
||||
}
|
||||
|
||||
static void _cache_mng_set_cache_mode_test05(void **state)
|
||||
static void _cache_mng_set_cache_mode_test04(void **state)
|
||||
{
|
||||
ocf_cache_mode_t mode_old = ocf_cache_mode_wt;
|
||||
ocf_cache_mode_t mode_new = ocf_cache_mode_wa;
|
||||
@ -255,95 +215,18 @@ static void _cache_mng_set_cache_mode_test05(void **state)
|
||||
.owner = &ctx,
|
||||
.conf_meta = &sb_config,
|
||||
};
|
||||
uint8_t flush = 0;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
print_test_description("Flush flag is not set, "
|
||||
"flushing metadata superblock fails");
|
||||
print_test_description("Mode changed successfully");
|
||||
|
||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_flush_superblock);
|
||||
will_return(__wrap_ocf_metadata_flush_superblock, 1);
|
||||
|
||||
expect_function_call(__wrap_ocf_log_raw);
|
||||
will_return(__wrap_ocf_log_raw, 0);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
|
||||
assert_int_equal(result, -OCF_ERR_WRITE_CACHE);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_old);
|
||||
}
|
||||
|
||||
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 i;
|
||||
|
||||
print_test_description("No flush, mode changed successfully");
|
||||
|
||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_flush_superblock);
|
||||
will_return(__wrap_ocf_metadata_flush_superblock, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_log_raw);
|
||||
will_return(__wrap_ocf_log_raw, 0);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
print_test_description("Flush performed, mode changed successfully");
|
||||
|
||||
expect_function_call(__wrap_ocf_cache_mode_is_valid);
|
||||
will_return(__wrap_ocf_cache_mode_is_valid, 1);
|
||||
|
||||
expect_function_call(__wrap_ocf_mngt_cache_flush);
|
||||
will_return(__wrap_ocf_mngt_cache_flush, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_flush_superblock);
|
||||
will_return(__wrap_ocf_metadata_flush_superblock, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_log_raw);
|
||||
will_return(__wrap_ocf_log_raw, 0);
|
||||
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new, flush);
|
||||
result = _cache_mng_set_cache_mode(&cache, mode_new);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
assert_int_equal(cache.conf_meta->cache_mode, mode_new);
|
||||
@ -359,9 +242,6 @@ int main(void)
|
||||
cmocka_unit_test(_cache_mng_set_cache_mode_test02),
|
||||
cmocka_unit_test(_cache_mng_set_cache_mode_test03),
|
||||
cmocka_unit_test(_cache_mng_set_cache_mode_test04),
|
||||
cmocka_unit_test(_cache_mng_set_cache_mode_test05),
|
||||
cmocka_unit_test(_cache_mng_set_cache_mode_test06),
|
||||
cmocka_unit_test(_cache_mng_set_cache_mode_test07)
|
||||
};
|
||||
|
||||
print_message("Unit test of _cache_mng_set_cache_mode\n");
|
||||
|
@ -115,8 +115,6 @@ void __wrap_ocf_part_sort(struct ocf_cache *cache)
|
||||
|
||||
int __wrap_ocf_metadata_flush_superblock(struct ocf_cache *cache)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
}
|
||||
|
||||
/* Helper function for test prepration */
|
||||
@ -169,9 +167,6 @@ static void ocf_mngt_io_classes_configure_test03(void **state)
|
||||
|
||||
expect_function_call(__wrap_ocf_part_sort);
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_flush_superblock);
|
||||
will_return(__wrap_ocf_metadata_flush_superblock, 0);
|
||||
|
||||
result = ocf_mngt_cache_io_classes_configure(&cache, &cfg);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
@ -231,9 +226,6 @@ static void ocf_mngt_io_classes_configure_test02(void **state)
|
||||
|
||||
expect_function_call(__wrap_ocf_part_sort);
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_flush_superblock);
|
||||
will_return(__wrap_ocf_metadata_flush_superblock, 0);
|
||||
|
||||
result = ocf_mngt_cache_io_classes_configure(&cache, &cfg);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user