Remove calls to OCF_METADATA_(UN)LOCK_WR(RD)

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2019-08-01 16:54:26 -04:00
parent 2333d837fb
commit d2bd807e49
11 changed files with 48 additions and 72 deletions

View File

@@ -292,7 +292,6 @@ static ocf_error_t init_attached_data_structures(ocf_cache_t cache,
ocf_error_t result;
/* Lock to ensure consistency */
OCF_METADATA_LOCK_WR();
ocf_metadata_init_hash_table(cache);
ocf_metadata_init_collision(cache);
@@ -303,7 +302,6 @@ static ocf_error_t init_attached_data_structures(ocf_cache_t cache,
if (result) {
ocf_cache_log(cache, log_err,
"Cannot initialize cleaning policy\n");
OCF_METADATA_UNLOCK_WR();
return result;
}
@@ -313,24 +311,19 @@ static ocf_error_t init_attached_data_structures(ocf_cache_t cache,
ocf_cache_log(cache, log_err,
"Cannot initialize promotion policy\n");
__deinit_cleaning_policy(cache);
OCF_METADATA_UNLOCK_WR();
return result;
}
OCF_METADATA_UNLOCK_WR();
return 0;
}
static void init_attached_data_structures_recovery(ocf_cache_t cache)
{
OCF_METADATA_LOCK_WR();
ocf_metadata_init_hash_table(cache);
ocf_metadata_init_collision(cache);
__init_partitions_attached(cache);
__reset_stats(cache);
__init_metadata_version(cache);
OCF_METADATA_UNLOCK_WR();
}
/****************************************************************
@@ -2242,11 +2235,11 @@ int ocf_mngt_cache_promotion_set_policy(ocf_cache_t cache, ocf_promotion_t type)
{
int result;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
result = ocf_promotion_set_policy(cache->promotion_policy, type);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
return result;
}
@@ -2255,11 +2248,11 @@ ocf_promotion_t ocf_mngt_cache_promotion_get_policy(ocf_cache_t cache)
{
ocf_promotion_t result;
OCF_METADATA_LOCK_RD();
ocf_metadata_start_shared_access(&cache->metadata.lock);
result = cache->conf_meta->promotion_policy_type;
OCF_METADATA_UNLOCK_RD();
ocf_metadata_end_shared_access(&cache->metadata.lock);
return result;
}
@@ -2269,12 +2262,12 @@ int ocf_mngt_cache_promotion_get_param(ocf_cache_t cache, uint8_t param_id,
{
int result;
OCF_METADATA_LOCK_RD();
ocf_metadata_start_shared_access(&cache->metadata.lock);
result = ocf_promotion_get_param(cache->promotion_policy, param_id,
param_value);
OCF_METADATA_UNLOCK_RD();
ocf_metadata_end_shared_access(&cache->metadata.lock);
return result;
}
@@ -2284,12 +2277,12 @@ int ocf_mngt_cache_promotion_set_param(ocf_cache_t cache, uint8_t param_id,
{
int result;
OCF_METADATA_LOCK_RD();
ocf_metadata_start_shared_access(&cache->metadata.lock);
result = ocf_promotion_set_param(cache->promotion_policy, param_id,
param_value);
OCF_METADATA_UNLOCK_RD();
ocf_metadata_end_shared_access(&cache->metadata.lock);
return result;
}

View File

@@ -39,7 +39,7 @@ void cache_mngt_core_remove_from_cleaning_pol(ocf_core_t core)
ocf_core_id_t core_id = ocf_core_get_id(core);
ocf_cleaning_t clean_pol_type;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
clean_pol_type = cache->conf_meta->cleaning_policy_type;
if (cache->core[core_id].opened) {
@@ -49,7 +49,7 @@ void cache_mngt_core_remove_from_cleaning_pol(ocf_core_t core)
}
}
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
}
/* Deinitialize core metadata in attached metadata */
@@ -65,7 +65,7 @@ void cache_mngt_core_deinit_attached_meta(ocf_core_t core)
if (!core_size)
core_size = ~0ULL;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
clean_pol_type = cache->conf_meta->cleaning_policy_type;
while (retry) {
@@ -82,13 +82,14 @@ void cache_mngt_core_deinit_attached_meta(ocf_core_t core)
}
if (retry) {
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
env_msleep(100);
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(
&cache->metadata.lock);
}
}
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
}
/* Mark core as removed in metadata */
@@ -96,7 +97,7 @@ void cache_mngt_core_remove_from_meta(ocf_core_t core)
{
ocf_cache_t cache = ocf_core_get_cache(core);
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
/* In metadata mark data this core was removed from cache */
core->conf_meta->valid = false;
@@ -105,7 +106,7 @@ void cache_mngt_core_remove_from_meta(ocf_core_t core)
ocf_mngt_core_clear_uuid_metadata(core);
core->conf_meta->seq_no = OCF_SEQ_NO_INVALID;
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
}
/* Deinit in-memory structures related to this core */

View File

@@ -385,9 +385,9 @@ static int _ofc_flush_container_step(struct ocf_request *req)
struct flush_container *fc = req->priv;
ocf_cache_t cache = fc->cache;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
_ocf_mngt_flush_portion(fc);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
return 0;
}
@@ -501,7 +501,7 @@ static void _ocf_mngt_flush_core(
return;
}
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
ret = _ocf_mngt_get_sectors(cache, core_id,
&fc->flush_data, &fc->count);
@@ -509,7 +509,7 @@ static void _ocf_mngt_flush_core(
ocf_core_log(core, log_err, "Flushing operation aborted, "
"no memory\n");
env_vfree(fc);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
complete(context, -OCF_ERR_NO_MEM);
return;
}
@@ -519,7 +519,7 @@ static void _ocf_mngt_flush_core(
_ocf_mngt_flush_containers(context, fc, 1, complete);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
}
static void _ocf_mngt_flush_all_cores(
@@ -538,21 +538,21 @@ static void _ocf_mngt_flush_all_cores(
env_atomic_set(&cache->flush_in_progress, 1);
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
/* Get all 'dirty' sectors for all cores */
ret = _ocf_mngt_get_flush_containers(cache, &fctbl, &fcnum);
if (ret) {
ocf_cache_log(cache, log_err, "Flushing operation aborted, "
"no memory\n");
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
complete(context, ret);
return;
}
_ocf_mngt_flush_containers(context, fctbl, fcnum, complete);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
}
static void _ocf_mngt_flush_all_cores_complete(
@@ -774,10 +774,10 @@ static void _ocf_mngt_cache_invalidate(ocf_pipeline_t pipeline, void *priv,
ocf_cache_t cache = context->cache;
int result;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
result = ocf_metadata_sparse_range(cache, context->purge.core_id, 0,
context->purge.end_byte);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
OCF_PL_NEXT_ON_SUCCESS_RET(context->pipeline, result);
}
@@ -907,7 +907,7 @@ int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
return 0;
}
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
if (cleaning_policy_ops[old_type].deinitialize)
cleaning_policy_ops[old_type].deinitialize(cache);
@@ -925,7 +925,7 @@ int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
cache->conf_meta->cleaning_policy_type = type;
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
ocf_cache_log(cache, log_info, "Changing cleaning policy from "
"%s to %s\n", cleaning_policy_ops[old_type].name,
@@ -957,12 +957,12 @@ int ocf_mngt_cache_cleaning_set_param(ocf_cache_t cache, ocf_cleaning_t type,
if (!cleaning_policy_ops[type].set_cleaning_param)
return -OCF_ERR_INVAL;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
ret = cleaning_policy_ops[type].set_cleaning_param(cache,
param_id, param_value);
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
return ret;
}

View File

@@ -275,7 +275,7 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
if (!old_config)
return -OCF_ERR_NO_MEM;
OCF_METADATA_LOCK_WR();
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
result = env_memcpy(old_config, sizeof(cache->user_parts),
cache->user_parts, sizeof(cache->user_parts));
@@ -300,7 +300,7 @@ out_edit:
}
out_cpy:
OCF_METADATA_UNLOCK_WR();
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
env_free(old_config);
return result;