Unify core naming convention (core_obj -> core)

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2018-12-12 14:49:17 +01:00
parent db92083432
commit 69947bb44b
30 changed files with 118 additions and 118 deletions

View File

@@ -273,7 +273,7 @@ static void __init_eviction_policy(struct ocf_cache *cache,
static void __init_cores(struct ocf_cache *cache)
{
/* No core devices yet */
cache->conf_meta->core_obj_count = 0;
cache->conf_meta->core_count = 0;
ENV_BUG_ON(env_memset(cache->conf_meta->valid_object_bitmap,
sizeof(cache->conf_meta->valid_object_bitmap), 0));
}
@@ -359,22 +359,22 @@ static void _ocf_mngt_close_all_uninitialized_cores(
ocf_data_obj_t obj;
int j, i;
for (j = cache->conf_meta->core_obj_count, i = 0; j > 0; ++i) {
for (j = cache->conf_meta->core_count, i = 0; j > 0; ++i) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
continue;
obj = &(cache->core_obj[i].obj);
obj = &(cache->core[i].obj);
ocf_data_obj_close(obj);
--j;
env_free(cache->core_obj[i].counters);
cache->core_obj[i].counters = NULL;
env_free(cache->core[i].counters);
cache->core[i].counters = NULL;
env_bit_clear(i, cache->conf_meta->valid_object_bitmap);
}
cache->conf_meta->core_obj_count = 0;
cache->conf_meta->core_count = 0;
}
/**
@@ -407,17 +407,17 @@ static int _ocf_mngt_init_instance_add_cores(
}
/* Count value will be re-calculated on the basis of 'added' flag */
cache->conf_meta->core_obj_count = 0;
cache->conf_meta->core_count = 0;
/* Check in metadata which cores were added into cache */
for (i = 0; i < OCF_CORE_MAX; i++) {
ocf_data_obj_t tobj = NULL;
ocf_core_t core = &cache->core_obj[i];
ocf_core_t core = &cache->core[i];
if (!cache->core_conf_meta[i].added)
continue;
if (!cache->core_obj[i].obj.type)
if (!cache->core[i].obj.type)
goto _cache_mng_init_instance_add_cores_ERROR;
ret = snprintf(core_name, sizeof(core_name), "%d", i);
@@ -458,7 +458,7 @@ static int _ocf_mngt_init_instance_add_cores(
}
env_bit_set(i, cache->conf_meta->valid_object_bitmap);
cache->conf_meta->core_obj_count++;
cache->conf_meta->core_count++;
core->obj.cache = cache;
core->counters =
@@ -478,7 +478,7 @@ static int _ocf_mngt_init_instance_add_cores(
hd_lines = ocf_bytes_2_lines(cache,
ocf_data_obj_get_length(
&cache->core_obj[i].obj));
&cache->core[i].obj));
if (hd_lines) {
ocf_cache_log(cache, log_info,
@@ -1265,7 +1265,7 @@ static int _ocf_mngt_cache_add_cores_t_clean_pol(ocf_cache_t cache)
int result;
if (cleaning_policy_ops[clean_type].add_core) {
no = cache->conf_meta->core_obj_count;
no = cache->conf_meta->core_count;
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
continue;
@@ -1537,7 +1537,7 @@ static int _ocf_mngt_cache_unplug(ocf_cache_t cache, bool stop)
int result;
if (stop)
ENV_BUG_ON(cache->conf_meta->core_obj_count != 0);
ENV_BUG_ON(cache->conf_meta->core_count != 0);
ocf_stop_cleaner(cache);
@@ -1590,7 +1590,7 @@ static int _ocf_mngt_cache_stop(ocf_cache_t cache)
int i, j, no, result = 0;
ocf_ctx_t owner = cache->owner;
no = cache->conf_meta->core_obj_count;
no = cache->conf_meta->core_count;
env_bit_set(ocf_cache_state_stopping, &cache->cache_state);
env_bit_clear(ocf_cache_state_running, &cache->cache_state);
@@ -1607,7 +1607,7 @@ static int _ocf_mngt_cache_stop(ocf_cache_t cache)
cache_mng_core_close(cache, i);
j++;
}
ENV_BUG_ON(cache->conf_meta->core_obj_count != 0);
ENV_BUG_ON(cache->conf_meta->core_count != 0);
if (env_atomic_read(&cache->attached))
result = _ocf_mngt_cache_unplug(cache, true);
@@ -2062,7 +2062,7 @@ int ocf_mngt_cache_detach(ocf_cache_t cache)
int result;
ocf_cache_mode_t mode;
no = cache->conf_meta->core_obj_count;
no = cache->conf_meta->core_count;
result = ocf_mngt_cache_lock(cache);
if (result)

View File

@@ -19,11 +19,11 @@
/* Close if opened */
int cache_mng_core_close(ocf_cache_t cache, ocf_core_id_t core_id)
{
if (!cache->core_obj[core_id].opened)
if (!cache->core[core_id].opened)
return -OCF_ERR_CORE_IN_INACTIVE_STATE;
ocf_data_obj_close(&cache->core_obj[core_id].obj);
cache->core_obj[core_id].opened = false;
ocf_data_obj_close(&cache->core[core_id].obj);
cache->core[core_id].opened = false;
return 0;
}
@@ -37,7 +37,7 @@ void cache_mng_core_remove_from_cleaning_pol(struct ocf_cache *cache,
OCF_METADATA_LOCK_WR();
clean_pol_type = cache->conf_meta->cleaning_policy_type;
if (cache->core_obj[core_id].opened) {
if (cache->core[core_id].opened) {
if (cleaning_policy_ops[clean_pol_type].remove_core) {
cleaning_policy_ops[clean_pol_type].
remove_core(cache, core_id);
@@ -55,7 +55,7 @@ void cache_mng_core_deinit_attached_meta(struct ocf_cache *cache, int core_id)
ocf_cleaning_t clean_pol_type;
ocf_data_obj_t core;
core = &cache->core_obj[core_id].obj;
core = &cache->core[core_id].obj;
core_size = ocf_data_obj_get_length(core);
if (!core_size)
@@ -96,7 +96,7 @@ void cache_mng_core_remove_from_meta(struct ocf_cache *cache, int core_id)
cache->core_conf_meta[core_id].added = false;
/* Clear UUID of core */
ocf_uuid_core_clear(cache, &cache->core_obj[core_id]);
ocf_uuid_core_clear(cache, &cache->core[core_id]);
cache->core_conf_meta[core_id].seq_no = OCF_SEQ_NO_INVALID;
OCF_METADATA_UNLOCK_WR();
@@ -105,16 +105,16 @@ void cache_mng_core_remove_from_meta(struct ocf_cache *cache, int core_id)
/* Deinit in-memory structures related to this core */
void cache_mng_core_remove_from_cache(struct ocf_cache *cache, int core_id)
{
env_free(cache->core_obj[core_id].counters);
cache->core_obj[core_id].counters = NULL;
env_free(cache->core[core_id].counters);
cache->core[core_id].counters = NULL;
env_bit_clear(core_id, cache->conf_meta->valid_object_bitmap);
if (!cache->core_obj[core_id].opened &&
if (!cache->core[core_id].opened &&
--cache->ocf_core_inactive_count == 0) {
env_bit_clear(ocf_cache_state_incomplete, &cache->cache_state);
}
cache->conf_meta->core_obj_count--;
cache->conf_meta->core_count--;
}
/**

View File

@@ -24,11 +24,11 @@ static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
struct ocf_mngt_core_config *cfg)
{
int result = 0;
struct ocf_core *core_obj;
ocf_core_t tmp_core;
ocf_data_obj_t obj;
core_obj = &cache->core_obj[cfg->core_id];
obj = &core_obj->obj;
tmp_core = &cache->core[cfg->core_id];
obj = &tmp_core->obj;
if (ocf_ctx_get_data_obj_type_id(cache->owner, obj->type) !=
cfg->data_obj_type) {
@@ -45,12 +45,12 @@ static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
goto error_after_open;
}
cache->core_obj[cfg->core_id].opened = true;
tmp_core->opened = true;
if (!(--cache->ocf_core_inactive_count))
env_bit_clear(ocf_cache_state_incomplete, &cache->cache_state);
*core = core_obj;
*core = tmp_core;
return 0;
error_after_open:
@@ -64,19 +64,19 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
struct ocf_mngt_core_config *cfg)
{
int result = 0;
struct ocf_core *core_obj;
ocf_core_t tmp_core;
ocf_data_obj_t obj;
ocf_seq_no_t core_sequence_no;
ocf_cleaning_t clean_type;
uint64_t length;
core_obj = &cache->core_obj[cfg->core_id];
obj = &core_obj->obj;
tmp_core = &cache->core[cfg->core_id];
obj = &tmp_core->obj;
core_obj->obj.cache = cache;
tmp_core->obj.cache = cache;
/* Set uuid */
ocf_uuid_core_set(cache, core_obj, &cfg->uuid);
ocf_uuid_core_set(cache, tmp_core, &cfg->uuid);
obj->type = ocf_ctx_get_data_obj_type(cache->owner, cfg->data_obj_type);
if (!obj->type) {
@@ -85,7 +85,7 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
}
if (cfg->user_metadata.data && cfg->user_metadata.size > 0) {
result = ocf_core_set_user_metadata_raw(core_obj,
result = ocf_core_set_user_metadata_raw(tmp_core,
cfg->user_metadata.data,
cfg->user_metadata.size);
if (result)
@@ -113,14 +113,14 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
}
/* When adding new core to cache, allocate stat counters */
core_obj->counters =
env_zalloc(sizeof(*core_obj->counters), ENV_MEM_NORMAL);
if (!core_obj->counters) {
tmp_core->counters =
env_zalloc(sizeof(*tmp_core->counters), ENV_MEM_NORMAL);
if (!tmp_core->counters) {
result = -OCF_ERR_NO_MEM;
goto error_after_clean_pol;
}
/* When adding new core to cache, reset all core/cache statistics */
ocf_stats_init(core_obj);
ocf_stats_init(tmp_core);
env_atomic_set(&cache->core_runtime_meta[cfg->core_id].
cached_clines, 0);
env_atomic_set(&cache->core_runtime_meta[cfg->core_id].
@@ -131,7 +131,7 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
/* In metadata mark data this core was added into cache */
env_bit_set(cfg->core_id, cache->conf_meta->valid_object_bitmap);
cache->core_conf_meta[cfg->core_id].added = true;
cache->core_obj[cfg->core_id].opened = true;
tmp_core->opened = true;
/* Set default cache parameters for sequential */
cache->core_conf_meta[cfg->core_id].seq_cutoff_policy =
@@ -154,15 +154,15 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
}
/* Increase value of added cores */
cache->conf_meta->core_obj_count++;
cache->conf_meta->core_count++;
*core = core_obj;
*core = tmp_core;
return 0;
error_after_counters_allocation:
env_bit_clear(cfg->core_id, cache->conf_meta->valid_object_bitmap);
cache->core_conf_meta[cfg->core_id].added = false;
cache->core_obj[cfg->core_id].opened = false;
tmp_core->opened = false;
/* An error when flushing metadata, try restore for safety reason
* previous metadata sate on cache device.
@@ -173,8 +173,8 @@ error_after_counters_allocation:
*/
ocf_metadata_flush_superblock(cache);
env_free(core_obj->counters);
core_obj->counters = NULL;
env_free(tmp_core->counters);
tmp_core->counters = NULL;
error_after_clean_pol:
if (cleaning_policy_ops[clean_type].remove_core)
@@ -183,7 +183,7 @@ error_after_clean_pol:
error_after_open:
ocf_data_obj_close(obj);
error_out:
ocf_uuid_core_clear(cache, core_obj);
ocf_uuid_core_clear(cache, tmp_core);
*core = NULL;
return result;
}
@@ -228,12 +228,12 @@ static int __ocf_mngt_lookup_core_uuid(ocf_cache_t cache,
int i;
for (i = 0; i < OCF_CORE_MAX; i++) {
ocf_core_t core = &cache->core_obj[i];
ocf_core_t core = &cache->core[i];
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
continue;
if (cache->core_obj[i].opened)
if (cache->core[i].opened)
continue;
if (ocf_ctx_get_data_obj_type_id(cache->owner, core->obj.type)
@@ -291,7 +291,7 @@ static int __ocf_mngt_find_core_id(ocf_cache_t cache,
OCF_CORE_MAX);
/* no need to check if find_first_zero_bit failed and
* *core_id == MAX_CORE_OBJS_PER_CACHE, as above there is check
* for core_obj_count being greater or equal to
* for core_count being greater or equal to
* MAX_CORE_OBJS_PER_CACHE
*/
} else if (cfg->core_id < OCF_CORE_MAX) {
@@ -319,7 +319,7 @@ static int _ocf_mngt_find_core_id(ocf_cache_t cache,
int result;
ocf_core_id_t tmp_core_id;
if (cache->conf_meta->core_obj_count >= OCF_CORE_MAX)
if (cache->conf_meta->core_count >= OCF_CORE_MAX)
return -OCF_ERR_TOO_MANY_CORES;
tmp_core_id = __ocf_mngt_lookup_core_uuid(cache, cfg);
@@ -357,7 +357,7 @@ int ocf_mngt_cache_add_core_nolock(ocf_cache_t cache, ocf_core_t *core,
return result;
}
result = ocf_core_set_name(&cache->core_obj[cfg->core_id], core_name,
result = ocf_core_set_name(&cache->core[cfg->core_id], core_name,
sizeof(core_name));
if (result)
return result;

View File

@@ -102,13 +102,13 @@ static int _ocf_mngt_get_sectors(struct ocf_cache *cache, int core_id,
break;
}
ocf_core_log(&cache->core_obj[core_id], log_debug,
ocf_core_log(&cache->core[core_id], log_debug,
"%u dirty cache lines to clean\n", j);
if (dirty != j) {
ocf_cache_log(cache, log_debug, "Wrong number of dirty "
"blocks for flushing core %s (%u!=%u)\n",
cache->core_obj[core_id].name, j, dirty);
cache->core[core_id].name, j, dirty);
}
@@ -139,7 +139,7 @@ static int _ocf_mngt_get_flush_containers(ocf_cache_t cache,
* each core. Cores can be partitions of single device.
*/
num = cache->conf_meta->core_obj_count;
num = cache->conf_meta->core_count;
if (num == 0) {
*fcnum = 0;
return 0;
@@ -173,7 +173,7 @@ static int _ocf_mngt_get_flush_containers(ocf_cache_t cache,
sizeof(*fc[j].flush_data));
}
if (++j == cache->conf_meta->core_obj_count)
if (++j == cache->conf_meta->core_count)
break;
}
@@ -334,7 +334,7 @@ static int _ocf_mngt_flush_containers(ocf_cache_t cache,
if (!env_atomic_read(&fctbl[i].completed))
continue;
core = &cache->core_obj[fctbl[i].core_id];
core = &cache->core[fctbl[i].core_id];
env_atomic_set(&core->flushed, fctbl[i].iter);
env_atomic_set(&fctbl[i].completed, 0);
@@ -451,9 +451,9 @@ static int _ocf_mng_cache_flush_nolock(ocf_cache_t cache, bool interruption)
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
continue;
env_atomic_set(&cache->core_obj[i].flushed, 0);
env_atomic_set(&cache->core[i].flushed, 0);
if (++j == cache->conf_meta->core_obj_count)
if (++j == cache->conf_meta->core_count)
break;
}
@@ -598,7 +598,7 @@ int ocf_mngt_core_purge(ocf_cache_t cache, ocf_core_id_t core_id, bool interrupt
return -OCF_ERR_CORE_NOT_AVAIL;
}
core_size = ocf_data_obj_get_length(&cache->core_obj[core_id].obj);
core_size = ocf_data_obj_get_length(&cache->core[core_id].obj);
core_size = core_size ?: ~0ULL;
_ocf_mngt_begin_flush(cache);