Cache lock cleanup and API improvements
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
159
inc/ocf_mngt.h
159
inc/ocf_mngt.h
@@ -333,17 +333,6 @@ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
*/
|
||||
int ocf_mngt_cache_stop(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief Stop cache instance without acquiring cache lock - caller is
|
||||
* required to hold cache write lock when calling this
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
*
|
||||
* @retval 0 Cache successfully stopped
|
||||
* @retval Non-zero Error occurred during stopping cache
|
||||
*/
|
||||
int ocf_mngt_cache_stop_nolock(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief Attach caching device to cache instance
|
||||
*
|
||||
@@ -356,19 +345,6 @@ int ocf_mngt_cache_stop_nolock(ocf_cache_t cache);
|
||||
int ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *device_cfg);
|
||||
|
||||
/**
|
||||
* @brief Attach caching device to cache instance without acquiring cache lock
|
||||
* - caller is required to hold cache write lock when calling this
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
int ocf_mngt_cache_attach_nolock(ocf_cache_t cache,
|
||||
struct ocf_mngt_cache_device_config *device_cfg);
|
||||
|
||||
/**
|
||||
* @brief Detach caching cache
|
||||
*
|
||||
@@ -382,7 +358,8 @@ int ocf_mngt_cache_detach(ocf_cache_t cache);
|
||||
/**
|
||||
* @brief Load cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] ctx OCF context
|
||||
* @param[out] cache Cache handle
|
||||
* @param[in] cfg Cache configuration
|
||||
* @param[in] device_cfg Caching device configuration
|
||||
*
|
||||
@@ -399,7 +376,7 @@ int ocf_mngt_cache_load(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
* @brief Add core to cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core Core object handle
|
||||
* @param[out] core Core object handle
|
||||
* @param[in] cfg Core configuration
|
||||
*
|
||||
* @retval 0 Core successfully added core to cache
|
||||
@@ -408,46 +385,25 @@ int ocf_mngt_cache_load(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||
int ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
|
||||
struct ocf_mngt_core_config *cfg);
|
||||
|
||||
/**
|
||||
* @brief Add core to cache instance without acquiring cache lock - caller is
|
||||
required to hold cache write lock when calling this
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] 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
|
||||
*/
|
||||
int ocf_mngt_cache_add_core_nolock(ocf_cache_t cache, ocf_core_t *core,
|
||||
struct ocf_mngt_core_config *cfg);
|
||||
|
||||
/**
|
||||
* @brief Remove core from cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core_id Core ID
|
||||
* @param[in] detach only detach core without removing it from cache metadata
|
||||
* @param[in] cache Core handle
|
||||
*
|
||||
* @retval 0 Core successfully removed core from cache
|
||||
* @retval Non-zero Error occurred and removing core failed
|
||||
* @retval 0 Core successfully removed from cache
|
||||
* @retval Non-zero Error occurred and removing core failed
|
||||
*/
|
||||
int ocf_mngt_cache_remove_core(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
bool detach);
|
||||
int ocf_mngt_cache_remove_core(ocf_core_t core);
|
||||
|
||||
/**
|
||||
* @brief Remove core from cache instance without acquiring cache lock - caller
|
||||
* is required to hold cache write lock when calling this
|
||||
* @brief Detach core from cache instance
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core_id Core ID
|
||||
* @param[in] detach only detach core without removing it from cache metadata
|
||||
* @param[in] core Core handle
|
||||
*
|
||||
* @retval 0 Core successfully removed core from cache
|
||||
* @retval Non-zero Error occurred and removing core failed
|
||||
* @retval 0 Core successfully detached from cache
|
||||
* @retval Non-zero Error occurred and detaching core failed
|
||||
*/
|
||||
int ocf_mngt_cache_remove_core_nolock(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
bool detach);
|
||||
int ocf_mngt_cache_detach_core(ocf_core_t core);
|
||||
|
||||
/* Flush operations */
|
||||
|
||||
@@ -462,45 +418,19 @@ int ocf_mngt_cache_remove_core_nolock(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
*/
|
||||
int ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption);
|
||||
|
||||
/**
|
||||
* @brief Flush data from given cache without acquiring cache lock - caller is
|
||||
* required to hold cache write OR read lock when calling this
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
int ocf_mngt_cache_flush_nolock(ocf_cache_t cache, bool interruption);
|
||||
|
||||
/**
|
||||
* @brief Flush data to given core
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] id Core ID
|
||||
* @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
|
||||
*/
|
||||
int ocf_mngt_core_flush(ocf_cache_t cache, ocf_core_id_t id, bool interruption);
|
||||
int ocf_mngt_core_flush(ocf_core_t core, bool interruption);
|
||||
|
||||
/**
|
||||
* @brief Flush data to given core without acquiring cache lock - caller is
|
||||
* required to hold cache write OR read lock when calling this
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] id Core ID
|
||||
* @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
|
||||
*/
|
||||
int ocf_mngt_core_flush_nolock(ocf_cache_t cache, ocf_core_id_t id,
|
||||
bool interruption);
|
||||
/**
|
||||
* @brief Interrupt existing flushing of cache or cache
|
||||
* @brief Interrupt existing flushing of cache or core
|
||||
*
|
||||
* @param[in] cache Cache instance
|
||||
*
|
||||
@@ -512,14 +442,13 @@ int ocf_mngt_cache_flush_interrupt(ocf_cache_t cache);
|
||||
/**
|
||||
* @brief Purge data to given core
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] id Core ID
|
||||
* @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
|
||||
*/
|
||||
int ocf_mngt_core_purge(ocf_cache_t cache, ocf_core_id_t id, bool interruption);
|
||||
int ocf_mngt_core_purge(ocf_core_t core, bool interruption);
|
||||
/**
|
||||
* @brief Purge data from given cache
|
||||
*
|
||||
@@ -629,53 +558,71 @@ int ocf_mngt_io_class_configure(ocf_cache_t cache,
|
||||
/**
|
||||
* @brief Set core sequential cutoff threshold
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core_id Core ID
|
||||
* @param[in] core Core handle
|
||||
* @param[in] thresh threshold in bytes for sequential cutoff
|
||||
*
|
||||
* @retval 0 Sequential cutoff threshold has been set successfully
|
||||
* @retval Non-zero Error occured and threshold hasn't been updated
|
||||
*/
|
||||
int ocf_mngt_set_seq_cutoff_threshold(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
uint32_t thresh);
|
||||
int ocf_mngt_core_set_seq_cutoff_threshold(ocf_core_t core, uint32_t thresh);
|
||||
|
||||
/**
|
||||
* @brief Set core sequential cutoff policy
|
||||
* @brief Set sequential cutoff threshold for all cores in cache
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core_id Core ID
|
||||
* @param[in] policy sequential cutoff policy
|
||||
* @param[in] thresh threshold in bytes for sequential cutoff
|
||||
*
|
||||
* @retval 0 Sequential cutoff policy has been set successfully
|
||||
* @retval Non-zero Error occured and policy hasn't been updated
|
||||
* @retval 0 Sequential cutoff threshold has been set successfully
|
||||
* @retval Non-zero Error occured and threshold hasn't been updated
|
||||
*/
|
||||
int ocf_mngt_set_seq_cutoff_policy(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
ocf_seq_cutoff_policy policy);
|
||||
int ocf_mngt_core_set_seq_cutoff_threshold_all(ocf_cache_t cache,
|
||||
uint32_t thresh);
|
||||
|
||||
/**
|
||||
* @brief Get core sequential cutoff threshold
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core_id Core ID
|
||||
* @param[in] core Core handle
|
||||
* @param[in] thresh threshold in bytes for sequential cutoff
|
||||
*
|
||||
* @retval 0 Sequential cutoff threshold has been get successfully
|
||||
* @retval Non-zero Error occured
|
||||
*/
|
||||
int ocf_mngt_get_seq_cutoff_threshold(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
uint32_t *thresh);
|
||||
int ocf_mngt_core_get_seq_cutoff_threshold(ocf_core_t core, uint32_t *thresh);
|
||||
|
||||
/**
|
||||
* @brief Set core sequential cutoff policy
|
||||
*
|
||||
* @param[in] core Core handle
|
||||
* @param[in] policy sequential cutoff policy
|
||||
*
|
||||
* @retval 0 Sequential cutoff policy has been set successfully
|
||||
* @retval Non-zero Error occured and policy hasn't been updated
|
||||
*/
|
||||
int ocf_mngt_core_set_seq_cutoff_policy(ocf_core_t core,
|
||||
ocf_seq_cutoff_policy policy);
|
||||
|
||||
/**
|
||||
* @brief Set sequential cutoff policy for all cores in cache
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] policy sequential cutoff policy
|
||||
*
|
||||
* @retval 0 Sequential cutoff policy has been set successfully
|
||||
* @retval Non-zero Error occured and policy hasn't been updated
|
||||
*/
|
||||
int ocf_mngt_core_set_seq_cutoff_policy_all(ocf_cache_t cache,
|
||||
ocf_seq_cutoff_policy policy);
|
||||
|
||||
/**
|
||||
* @brief Get core sequential cutoff policy
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
* @param[in] core_id Core ID
|
||||
* @param[in] core Core handle
|
||||
* @param[in] policy sequential cutoff policy
|
||||
*
|
||||
* @retval 0 Sequential cutoff policy has been get successfully
|
||||
* @retval Non-zero Error occured
|
||||
*/
|
||||
int ocf_mngt_get_seq_cutoff_policy(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
int ocf_mngt_core_get_seq_cutoff_policy(ocf_core_t core,
|
||||
ocf_seq_cutoff_policy *policy);
|
||||
|
||||
/**
|
||||
|
||||
@@ -155,14 +155,22 @@ struct ocf_stats_core {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize or reset statistics.
|
||||
* @brief Initialize or reset core statistics
|
||||
*
|
||||
* Initialize or reset counters used for statistics.
|
||||
*
|
||||
* @param[in] cache OCF cache device handle
|
||||
* @param[in] core_id Id of core for which statistics should be initialized.
|
||||
* @param[in] core Core handle
|
||||
*/
|
||||
int ocf_stats_initialize(ocf_cache_t cache, ocf_core_id_t core_id);
|
||||
void ocf_core_stats_initialize(ocf_core_t core);
|
||||
|
||||
/**
|
||||
* @brief Initialize or reset statistics of all cores in cache
|
||||
*
|
||||
* Initialize or reset counters used for statistics.
|
||||
*
|
||||
* @param[in] cache Cache handle
|
||||
*/
|
||||
void ocf_core_stats_initialize_all(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief ocf_io_class_get_stats retrieve cache statistics
|
||||
|
||||
Reference in New Issue
Block a user