Cache standby mode API changes
Error for an invalid cache operation while in passive mode added Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com> Error name correction Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com> API changes for passive cache mode Moved the passive cache error return source to the api for flush and set_param Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com> Further API changes for passive cache mode Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com> Passive api - review changes Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com>
This commit is contained in:
@@ -1323,10 +1323,10 @@ static void _ocf_mngt_cache_set_valid(ocf_cache_t cache)
|
||||
env_bit_set(ocf_cache_state_running, &cache->cache_state);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_cache_set_passive(ocf_cache_t cache)
|
||||
static void _ocf_mngt_cache_set_standby(ocf_cache_t cache)
|
||||
{
|
||||
/*
|
||||
* Clear initialization state and set the passive bit.
|
||||
* Clear initialization state and set the standby bit.
|
||||
*/
|
||||
env_bit_clear(ocf_cache_state_initializing, &cache->cache_state);
|
||||
env_bit_set(ocf_cache_state_standby, &cache->cache_state);
|
||||
@@ -2386,7 +2386,7 @@ static void _ocf_mngt_cache_load(ocf_cache_t cache,
|
||||
}
|
||||
|
||||
struct ocf_pipeline_properties
|
||||
ocf_mngt_cache_stop_passive_pipeline_properties = {
|
||||
ocf_mngt_cache_stop_standby_pipeline_properties = {
|
||||
.priv_size = sizeof(struct ocf_mngt_cache_stop_context),
|
||||
.finish = ocf_mngt_cache_stop_finish,
|
||||
.steps = {
|
||||
@@ -2411,7 +2411,7 @@ static void _ocf_mngt_cache_standby(ocf_cache_t cache,
|
||||
OCF_CMPL_RET(cache, priv1, priv2, -OCF_ERR_NO_MEM);
|
||||
|
||||
result = ocf_pipeline_create(&cache->stop_pipeline, cache,
|
||||
&ocf_mngt_cache_stop_passive_pipeline_properties);
|
||||
&ocf_mngt_cache_stop_standby_pipeline_properties);
|
||||
if (result) {
|
||||
ocf_pipeline_destroy(pipeline);
|
||||
OCF_CMPL_RET(cache, priv1, priv2, -OCF_ERR_NO_MEM);
|
||||
@@ -2804,8 +2804,8 @@ static void _ocf_mngt_cache_standby_complete(ocf_cache_t cache, void *priv1,
|
||||
if (error)
|
||||
OCF_CMPL_RET(cache, priv2, error);
|
||||
|
||||
_ocf_mngt_cache_set_passive(cache);
|
||||
ocf_cache_log(cache, log_info, "Successfully binded\n");
|
||||
_ocf_mngt_cache_set_standby(cache);
|
||||
ocf_cache_log(cache, log_info, "Successfully bound\n");
|
||||
|
||||
OCF_CMPL_RET(cache, priv2, 0);
|
||||
}
|
||||
@@ -3053,6 +3053,9 @@ int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode)
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
if (!ocf_cache_mode_is_valid(mode)) {
|
||||
ocf_cache_log(cache, log_err, "Cache mode %u is invalid\n",
|
||||
mode);
|
||||
@@ -3075,6 +3078,9 @@ int ocf_mngt_cache_promotion_set_policy(ocf_cache_t cache, ocf_promotion_t type)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
result = ocf_promotion_set_policy(cache->promotion_policy, type);
|
||||
@@ -3084,17 +3090,20 @@ int ocf_mngt_cache_promotion_set_policy(ocf_cache_t cache, ocf_promotion_t type)
|
||||
return result;
|
||||
}
|
||||
|
||||
ocf_promotion_t ocf_mngt_cache_promotion_get_policy(ocf_cache_t cache)
|
||||
int ocf_mngt_cache_promotion_get_policy(ocf_cache_t cache, ocf_promotion_t *type)
|
||||
{
|
||||
ocf_promotion_t result;
|
||||
OCF_CHECK_NULL(type);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
ocf_metadata_start_shared_access(&cache->metadata.lock, 0);
|
||||
|
||||
result = cache->conf_meta->promotion_policy_type;
|
||||
*type = cache->conf_meta->promotion_policy_type;
|
||||
|
||||
ocf_metadata_end_shared_access(&cache->metadata.lock, 0);
|
||||
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ocf_mngt_cache_promotion_get_param(ocf_cache_t cache, ocf_promotion_t type,
|
||||
@@ -3102,6 +3111,9 @@ int ocf_mngt_cache_promotion_get_param(ocf_cache_t cache, ocf_promotion_t type,
|
||||
{
|
||||
int result;
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
ocf_metadata_start_shared_access(&cache->metadata.lock, 0);
|
||||
|
||||
result = ocf_promotion_get_param(cache, type, param_id, param_value);
|
||||
@@ -3116,6 +3128,9 @@ int ocf_mngt_cache_promotion_set_param(ocf_cache_t cache, ocf_promotion_t type,
|
||||
{
|
||||
int result;
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
result = ocf_promotion_set_param(cache, type, param_id, param_value);
|
||||
@@ -3129,6 +3144,9 @@ int ocf_mngt_cache_reset_fallback_pt_error_counter(ocf_cache_t cache)
|
||||
{
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
if (ocf_fallback_pt_is_on(cache)) {
|
||||
ocf_cache_log(cache, log_info,
|
||||
"Fallback Pass Through inactive\n");
|
||||
@@ -3146,6 +3164,9 @@ int ocf_mngt_cache_set_fallback_pt_error_threshold(ocf_cache_t cache,
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
if (new_threshold > OCF_CACHE_FALLBACK_PT_MAX_ERROR_THRESHOLD)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
@@ -3174,6 +3195,9 @@ int ocf_mngt_cache_get_fallback_pt_error_threshold(ocf_cache_t cache,
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(threshold);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
*threshold = cache->fallback_pt_error_threshold;
|
||||
|
||||
return 0;
|
||||
|
@@ -954,6 +954,9 @@ int ocf_mngt_core_set_seq_cutoff_threshold_all(ocf_cache_t cache,
|
||||
{
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
return ocf_core_visit(cache, _cache_mngt_set_core_seq_cutoff_threshold,
|
||||
&thresh, true);
|
||||
}
|
||||
@@ -1022,9 +1025,11 @@ int ocf_mngt_core_set_seq_cutoff_policy_all(ocf_cache_t cache,
|
||||
ocf_seq_cutoff_policy policy)
|
||||
{
|
||||
OCF_CHECK_NULL(cache);
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
return ocf_core_visit(cache, _cache_mngt_set_core_seq_cutoff_policy,
|
||||
&policy, true);
|
||||
&policy, true);
|
||||
}
|
||||
|
||||
int ocf_mngt_core_get_seq_cutoff_policy(ocf_core_t core,
|
||||
@@ -1081,9 +1086,11 @@ int ocf_mngt_core_set_seq_cutoff_promotion_count_all(ocf_cache_t cache,
|
||||
{
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
return ocf_core_visit(cache,
|
||||
_cache_mngt_set_core_seq_cutoff_promo_count,
|
||||
&count, true);
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
return ocf_core_visit(cache, _cache_mngt_set_core_seq_cutoff_promo_count,
|
||||
&count, true);
|
||||
}
|
||||
|
||||
int ocf_mngt_core_get_seq_cutoff_promotion_count(ocf_core_t core,
|
||||
|
@@ -655,6 +655,11 @@ void ocf_mngt_cache_flush(ocf_cache_t cache,
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (ocf_cache_is_standby(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush cache - cache is standby\n");
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_CACHE_STANDBY);
|
||||
}
|
||||
|
||||
if (!ocf_cache_is_device_attached(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush cache - "
|
||||
"cache device is detached\n");
|
||||
@@ -1006,6 +1011,9 @@ void ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache,
|
||||
if (new_policy < 0 || new_policy >= ocf_cleaning_max)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_INVAL);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_CACHE_STANDBY);
|
||||
|
||||
old_policy = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
if (new_policy == old_policy) {
|
||||
@@ -1036,6 +1044,9 @@ int ocf_mngt_cache_cleaning_get_policy(ocf_cache_t cache, ocf_cleaning_t *type)
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(type);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
*type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
return 0;
|
||||
@@ -1051,6 +1062,9 @@ int ocf_mngt_cache_cleaning_set_param(ocf_cache_t cache, ocf_cleaning_t type,
|
||||
if (type < 0 || type >= ocf_cleaning_max)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
ret = ocf_cleaning_set_param(cache, type, param_id, param_value);
|
||||
@@ -1069,5 +1083,8 @@ int ocf_mngt_cache_cleaning_get_param(ocf_cache_t cache, ocf_cleaning_t type,
|
||||
if (type < 0 || type >= ocf_cleaning_max)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
return ocf_cleaning_get_param(cache, type, param_id, param_value);
|
||||
}
|
||||
|
@@ -285,6 +285,9 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(cfg);
|
||||
|
||||
if (ocf_cache_is_standby(cache))
|
||||
return -OCF_ERR_CACHE_STANDBY;
|
||||
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
result = _ocf_mngt_io_class_validate_cfg(cache, &cfg->config[i]);
|
||||
if (result)
|
||||
|
Reference in New Issue
Block a user