Associate core metadata with core object
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -282,21 +282,19 @@ static void __init_metadata_version(ocf_cache_t cache)
|
||||
|
||||
static void __reset_stats(ocf_cache_t cache)
|
||||
{
|
||||
int core_id;
|
||||
ocf_core_t core;
|
||||
ocf_core_id_t core_id;
|
||||
ocf_part_id_t i;
|
||||
|
||||
for (core_id = 0; core_id < OCF_CORE_MAX; core_id++) {
|
||||
env_atomic_set(&cache->core_runtime_meta[core_id].
|
||||
cached_clines, 0);
|
||||
env_atomic_set(&cache->core_runtime_meta[core_id].
|
||||
dirty_clines, 0);
|
||||
env_atomic64_set(&cache->core_runtime_meta[core_id].
|
||||
dirty_since, 0);
|
||||
for_each_core_all(cache, core, core_id) {
|
||||
env_atomic_set(&core->runtime_meta->cached_clines, 0);
|
||||
env_atomic_set(&core->runtime_meta->dirty_clines, 0);
|
||||
env_atomic64_set(&core->runtime_meta->dirty_since, 0);
|
||||
|
||||
for (i = 0; i != OCF_IO_CLASS_MAX; i++) {
|
||||
env_atomic_set(&cache->core_runtime_meta[core_id].
|
||||
env_atomic_set(&core->runtime_meta->
|
||||
part_counters[i].cached_clines, 0);
|
||||
env_atomic_set(&cache->core_runtime_meta[core_id].
|
||||
env_atomic_set(&core->runtime_meta->
|
||||
part_counters[i].dirty_clines, 0);
|
||||
}
|
||||
}
|
||||
@@ -365,7 +363,9 @@ static int _ocf_mngt_init_instance_add_cores(
|
||||
ocf_cache_t cache = context->cache;
|
||||
/* FIXME: This is temporary hack. Remove after storing name it meta. */
|
||||
char core_name[OCF_CORE_NAME_SIZE];
|
||||
int ret = -1, i;
|
||||
ocf_core_t core;
|
||||
ocf_core_id_t core_id;
|
||||
int ret = -1;
|
||||
uint64_t hd_lines = 0;
|
||||
|
||||
OCF_ASSERT_PLUGGED(cache);
|
||||
@@ -381,17 +381,13 @@ static int _ocf_mngt_init_instance_add_cores(
|
||||
cache->conf_meta->core_count = 0;
|
||||
|
||||
/* Check in metadata which cores were added into cache */
|
||||
for (i = 0; i < OCF_CORE_MAX; i++) {
|
||||
for_each_core(cache, core, core_id) {
|
||||
ocf_volume_t tvolume = NULL;
|
||||
ocf_core_t core = &cache->core[i];
|
||||
|
||||
if (!cache->core_conf_meta[i].added)
|
||||
continue;
|
||||
|
||||
if (!cache->core[i].volume.type)
|
||||
if (!core->volume.type)
|
||||
goto err;
|
||||
|
||||
ret = snprintf(core_name, sizeof(core_name), "core%d", i);
|
||||
ret = snprintf(core_name, sizeof(core_name), "core%d", core_id);
|
||||
if (ret < 0 || ret >= sizeof(core_name))
|
||||
goto err;
|
||||
|
||||
@@ -411,22 +407,23 @@ static int _ocf_mngt_init_instance_add_cores(
|
||||
|
||||
core->opened = true;
|
||||
ocf_cache_log(cache, log_info,
|
||||
"Attached core %u from pool\n", i);
|
||||
"Attached core %u from pool\n",
|
||||
core_id);
|
||||
} else if (context->cfg.open_cores) {
|
||||
ret = ocf_volume_open(&core->volume, NULL);
|
||||
if (ret == -OCF_ERR_NOT_OPEN_EXC) {
|
||||
ocf_cache_log(cache, log_warn,
|
||||
"Cannot open core %u. "
|
||||
"Cache is busy", i);
|
||||
"Cache is busy", core_id);
|
||||
} else if (ret) {
|
||||
ocf_cache_log(cache, log_warn,
|
||||
"Cannot open core %u", i);
|
||||
"Cannot open core %u", core_id);
|
||||
} else {
|
||||
core->opened = true;
|
||||
}
|
||||
}
|
||||
|
||||
env_bit_set(i, cache->conf_meta->valid_core_bitmap);
|
||||
env_bit_set(core_id, cache->conf_meta->valid_core_bitmap);
|
||||
cache->conf_meta->core_count++;
|
||||
core->volume.cache = cache;
|
||||
|
||||
@@ -444,13 +441,12 @@ static int _ocf_mngt_init_instance_add_cores(
|
||||
cache->ocf_core_inactive_count++;
|
||||
ocf_cache_log(cache, log_warn,
|
||||
"Cannot find core %u in pool"
|
||||
", core added as inactive\n", i);
|
||||
", core added as inactive\n", core_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
hd_lines = ocf_bytes_2_lines(cache,
|
||||
ocf_volume_get_length(
|
||||
&cache->core[i].volume));
|
||||
ocf_volume_get_length(&core->volume));
|
||||
|
||||
if (hd_lines) {
|
||||
ocf_cache_log(cache, log_info,
|
||||
@@ -1884,19 +1880,18 @@ static void ocf_mngt_cache_stop_remove_cores(ocf_pipeline_t pipeline,
|
||||
{
|
||||
struct ocf_mngt_cache_stop_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
int i, j, no;
|
||||
|
||||
no = cache->conf_meta->core_count;
|
||||
ocf_core_t core;
|
||||
ocf_core_id_t core_id;
|
||||
int no = cache->conf_meta->core_count;
|
||||
|
||||
/* All exported objects removed, cleaning up rest. */
|
||||
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
|
||||
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
|
||||
continue;
|
||||
cache_mng_core_remove_from_cache(cache, i);
|
||||
for_each_core(cache, core, core_id) {
|
||||
cache_mng_core_remove_from_cache(core);
|
||||
if (context->cache_attached)
|
||||
cache_mng_core_remove_from_cleaning_pol(cache, i);
|
||||
cache_mng_core_close(cache, i);
|
||||
j++;
|
||||
cache_mng_core_remove_from_cleaning_pol(core);
|
||||
cache_mng_core_close(core);
|
||||
if (--no == 0)
|
||||
break;
|
||||
}
|
||||
ENV_BUG_ON(cache->conf_meta->core_count != 0);
|
||||
|
||||
@@ -2114,6 +2109,19 @@ void ocf_mngt_cache_save(ocf_cache_t cache,
|
||||
ocf_mngt_cache_save_flush_sb_complete, context);
|
||||
}
|
||||
|
||||
static void _cache_mng_update_initial_dirty_clines(ocf_cache_t cache)
|
||||
{
|
||||
ocf_core_t core;
|
||||
ocf_core_id_t core_id;
|
||||
|
||||
for_each_core(cache, core, core_id) {
|
||||
env_atomic_set(&core->runtime_meta->initial_dirty_clines,
|
||||
env_atomic_read(&core->runtime_meta->
|
||||
dirty_clines));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int _cache_mng_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode)
|
||||
{
|
||||
ocf_cache_mode_t mode_old = cache->conf_meta->cache_mode;
|
||||
@@ -2130,18 +2138,8 @@ static int _cache_mng_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode)
|
||||
|
||||
cache->conf_meta->cache_mode = mode;
|
||||
|
||||
if (ocf_cache_mode_wb == mode_old) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i != OCF_CORE_MAX; ++i) {
|
||||
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
|
||||
continue;
|
||||
env_atomic_set(&cache->core_runtime_meta[i].
|
||||
initial_dirty_clines,
|
||||
env_atomic_read(&cache->
|
||||
core_runtime_meta[i].dirty_clines));
|
||||
}
|
||||
}
|
||||
if (mode_old == ocf_cache_mode_wb)
|
||||
_cache_mng_update_initial_dirty_clines(cache);
|
||||
|
||||
ocf_cache_log(cache, log_info, "Changing cache mode from '%s' to '%s' "
|
||||
"successful\n", ocf_get_io_iface_name(mode_old),
|
||||
@@ -2300,17 +2298,16 @@ static void ocf_mngt_cache_detach_update_metadata(ocf_pipeline_t pipeline,
|
||||
{
|
||||
struct ocf_mngt_cache_detach_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
int i, j, no;
|
||||
|
||||
no = cache->conf_meta->core_count;
|
||||
ocf_core_t core;
|
||||
ocf_core_id_t core_id;
|
||||
int 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))
|
||||
continue;
|
||||
cache_mng_core_deinit_attached_meta(cache, i);
|
||||
cache_mng_core_remove_from_cleaning_pol(cache, i);
|
||||
j++;
|
||||
for_each_core(cache, core, core_id) {
|
||||
cache_mng_core_deinit_attached_meta(core);
|
||||
cache_mng_core_remove_from_cleaning_pol(core);
|
||||
if (--no == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
|
@@ -17,21 +17,22 @@
|
||||
#include "../engine/engine_common.h"
|
||||
|
||||
/* Close if opened */
|
||||
int cache_mng_core_close(ocf_cache_t cache, ocf_core_id_t core_id)
|
||||
int cache_mng_core_close(ocf_core_t core)
|
||||
{
|
||||
if (!cache->core[core_id].opened)
|
||||
if (!core->opened)
|
||||
return -OCF_ERR_CORE_IN_INACTIVE_STATE;
|
||||
|
||||
ocf_volume_close(&cache->core[core_id].volume);
|
||||
cache->core[core_id].opened = false;
|
||||
ocf_volume_close(&core->volume);
|
||||
core->opened = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove core from cleaning policy */
|
||||
void cache_mng_core_remove_from_cleaning_pol(struct ocf_cache *cache,
|
||||
int core_id)
|
||||
void cache_mng_core_remove_from_cleaning_pol(ocf_core_t core)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
ocf_cleaning_t clean_pol_type;
|
||||
|
||||
OCF_METADATA_LOCK_WR();
|
||||
@@ -48,16 +49,15 @@ void cache_mng_core_remove_from_cleaning_pol(struct ocf_cache *cache,
|
||||
}
|
||||
|
||||
/* Deinitialize core metadata in attached metadata */
|
||||
void cache_mng_core_deinit_attached_meta(struct ocf_cache *cache, int core_id)
|
||||
void cache_mng_core_deinit_attached_meta(ocf_core_t core)
|
||||
{
|
||||
int retry = 1;
|
||||
uint64_t core_size = 0;
|
||||
ocf_cleaning_t clean_pol_type;
|
||||
ocf_volume_t core;
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
|
||||
core = &cache->core[core_id].volume;
|
||||
|
||||
core_size = ocf_volume_get_length(core);
|
||||
core_size = ocf_volume_get_length(&core->volume);
|
||||
if (!core_size)
|
||||
core_size = ~0ULL;
|
||||
|
||||
@@ -88,31 +88,34 @@ void cache_mng_core_deinit_attached_meta(struct ocf_cache *cache, int core_id)
|
||||
}
|
||||
|
||||
/* Mark core as removed in metadata */
|
||||
void cache_mng_core_remove_from_meta(struct ocf_cache *cache, int core_id)
|
||||
void cache_mng_core_remove_from_meta(ocf_core_t core)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
|
||||
OCF_METADATA_LOCK_WR();
|
||||
|
||||
/* In metadata mark data this core was removed from cache */
|
||||
cache->core_conf_meta[core_id].added = false;
|
||||
core->conf_meta->added = false;
|
||||
|
||||
/* Clear UUID of core */
|
||||
ocf_mngt_core_clear_uuid_metadata(&cache->core[core_id]);
|
||||
cache->core_conf_meta[core_id].seq_no = OCF_SEQ_NO_INVALID;
|
||||
ocf_mngt_core_clear_uuid_metadata(core);
|
||||
core->conf_meta->seq_no = OCF_SEQ_NO_INVALID;
|
||||
|
||||
OCF_METADATA_UNLOCK_WR();
|
||||
}
|
||||
|
||||
/* Deinit in-memory structures related to this core */
|
||||
void cache_mng_core_remove_from_cache(struct ocf_cache *cache, int core_id)
|
||||
void cache_mng_core_remove_from_cache(ocf_core_t core)
|
||||
{
|
||||
env_free(cache->core[core_id].counters);
|
||||
cache->core[core_id].counters = NULL;
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
|
||||
env_free(core->counters);
|
||||
core->counters = NULL;
|
||||
env_bit_clear(core_id, cache->conf_meta->valid_core_bitmap);
|
||||
|
||||
if (!cache->core[core_id].opened &&
|
||||
--cache->ocf_core_inactive_count == 0) {
|
||||
if (!core->opened && --cache->ocf_core_inactive_count == 0)
|
||||
env_bit_clear(ocf_cache_state_incomplete, &cache->cache_state);
|
||||
}
|
||||
|
||||
cache->conf_meta->core_count--;
|
||||
}
|
||||
|
@@ -7,16 +7,15 @@
|
||||
#ifndef __OCF_MNGT_COMMON_H__
|
||||
#define __OCF_MNGT_COMMON_H__
|
||||
|
||||
int cache_mng_core_close(ocf_cache_t cache, ocf_core_id_t core_id);
|
||||
int cache_mng_core_close(ocf_core_t core);
|
||||
|
||||
void cache_mng_core_remove_from_meta(struct ocf_cache *cache, int core_id);
|
||||
void cache_mng_core_remove_from_meta(ocf_core_t core);
|
||||
|
||||
void cache_mng_core_remove_from_cache(struct ocf_cache *cache, int core_id);
|
||||
void cache_mng_core_remove_from_cache(ocf_core_t core);
|
||||
|
||||
void cache_mng_core_deinit_attached_meta(struct ocf_cache *cache, int core_id);
|
||||
void cache_mng_core_deinit_attached_meta(ocf_core_t core);
|
||||
|
||||
void cache_mng_core_remove_from_cleaning_pol(struct ocf_cache *cache,
|
||||
int core_id);
|
||||
void cache_mng_core_remove_from_cleaning_pol(ocf_core_t core);
|
||||
|
||||
int _ocf_cleaning_thread(void *priv);
|
||||
|
||||
|
@@ -150,7 +150,7 @@ static void _ocf_mngt_cache_add_core_handle_error(
|
||||
if (context->flags.counters_allocated) {
|
||||
env_bit_clear(cfg->core_id,
|
||||
cache->conf_meta->valid_core_bitmap);
|
||||
cache->core_conf_meta[cfg->core_id].added = false;
|
||||
core->conf_meta->added = false;
|
||||
core->opened = false;
|
||||
|
||||
env_free(core->counters);
|
||||
@@ -199,7 +199,7 @@ static void _ocf_mngt_cache_add_core(ocf_cache_t cache,
|
||||
uint64_t length;
|
||||
int result = 0;
|
||||
|
||||
core = &cache->core[cfg->core_id];
|
||||
core = ocf_cache_get_core(cache, cfg->core_id);
|
||||
context->core = core;
|
||||
|
||||
volume = &core->volume;
|
||||
@@ -242,7 +242,7 @@ static void _ocf_mngt_cache_add_core(ocf_cache_t cache,
|
||||
if (!length)
|
||||
OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_CORE_NOT_AVAIL);
|
||||
|
||||
cache->core_conf_meta[cfg->core_id].length = length;
|
||||
core->conf_meta->length = length;
|
||||
|
||||
clean_type = cache->conf_meta->cleaning_policy_type;
|
||||
if (ocf_cache_is_device_attached(cache) &&
|
||||
@@ -265,30 +265,25 @@ static void _ocf_mngt_cache_add_core(ocf_cache_t cache,
|
||||
|
||||
/* When adding new core to cache, reset all core/cache statistics */
|
||||
ocf_core_stats_initialize(core);
|
||||
env_atomic_set(&cache->core_runtime_meta[cfg->core_id].
|
||||
cached_clines, 0);
|
||||
env_atomic_set(&cache->core_runtime_meta[cfg->core_id].
|
||||
dirty_clines, 0);
|
||||
env_atomic64_set(&cache->core_runtime_meta[cfg->core_id].
|
||||
dirty_since, 0);
|
||||
env_atomic_set(&core->runtime_meta->cached_clines, 0);
|
||||
env_atomic_set(&core->runtime_meta->dirty_clines, 0);
|
||||
env_atomic64_set(&core->runtime_meta->dirty_since, 0);
|
||||
|
||||
/* In metadata mark data this core was added into cache */
|
||||
env_bit_set(cfg->core_id, cache->conf_meta->valid_core_bitmap);
|
||||
cache->core_conf_meta[cfg->core_id].added = true;
|
||||
core->conf_meta->added = true;
|
||||
core->opened = true;
|
||||
|
||||
/* Set default cache parameters for sequential */
|
||||
cache->core_conf_meta[cfg->core_id].seq_cutoff_policy =
|
||||
ocf_seq_cutoff_policy_default;
|
||||
cache->core_conf_meta[cfg->core_id].seq_cutoff_threshold =
|
||||
cfg->seq_cutoff_threshold;
|
||||
core->conf_meta->seq_cutoff_policy = ocf_seq_cutoff_policy_default;
|
||||
core->conf_meta->seq_cutoff_threshold = cfg->seq_cutoff_threshold;
|
||||
|
||||
/* Add core sequence number for atomic metadata matching */
|
||||
core_sequence_no = _ocf_mngt_get_core_seq_no(cache);
|
||||
if (core_sequence_no == OCF_SEQ_NO_INVALID)
|
||||
OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_TOO_MANY_CORES);
|
||||
|
||||
cache->core_conf_meta[cfg->core_id].seq_no = core_sequence_no;
|
||||
core->conf_meta->seq_no = core_sequence_no;
|
||||
|
||||
/* Update super-block with core device addition */
|
||||
ocf_metadata_flush_superblock(cache,
|
||||
@@ -661,7 +656,6 @@ static void _ocf_mngt_cache_remove_core(ocf_pipeline_t pipeline, void *priv,
|
||||
struct ocf_mngt_cache_remove_core_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
ocf_core_t core = context->core;
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
|
||||
ocf_core_log(core, log_debug, "Removing core\n");
|
||||
|
||||
@@ -669,12 +663,12 @@ static void _ocf_mngt_cache_remove_core(ocf_pipeline_t pipeline, void *priv,
|
||||
|
||||
/* Deinit everything*/
|
||||
if (ocf_cache_is_device_attached(cache)) {
|
||||
cache_mng_core_deinit_attached_meta(cache, core_id);
|
||||
cache_mng_core_remove_from_cleaning_pol(cache, core_id);
|
||||
cache_mng_core_deinit_attached_meta(core);
|
||||
cache_mng_core_remove_from_cleaning_pol(core);
|
||||
}
|
||||
cache_mng_core_remove_from_meta(cache, core_id);
|
||||
cache_mng_core_remove_from_cache(cache, core_id);
|
||||
cache_mng_core_close(cache, core_id);
|
||||
cache_mng_core_remove_from_meta(core);
|
||||
cache_mng_core_remove_from_cache(core);
|
||||
cache_mng_core_close(core);
|
||||
|
||||
/* Update super-block with core device removal */
|
||||
ocf_metadata_flush_superblock(cache,
|
||||
@@ -760,12 +754,11 @@ static void _ocf_mngt_cache_detach_core(ocf_pipeline_t pipeline,
|
||||
struct ocf_mngt_cache_remove_core_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
ocf_core_t core = context->core;
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
int status;
|
||||
|
||||
ocf_core_log(core, log_debug, "Detaching core\n");
|
||||
|
||||
status = cache_mng_core_close(cache, core_id);
|
||||
status = cache_mng_core_close(core);
|
||||
|
||||
if (status)
|
||||
OCF_PL_FINISH_RET(pipeline, status);
|
||||
@@ -893,19 +886,13 @@ int ocf_mngt_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid)
|
||||
|
||||
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,
|
||||
env_memcpy(core->conf_meta->user_data,
|
||||
OCF_CORE_USER_DATA_SIZE, data, size);
|
||||
|
||||
return 0;
|
||||
@@ -913,18 +900,13 @@ int ocf_mngt_core_set_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||
|
||||
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);
|
||||
OCF_CHECK_NULL(data);
|
||||
|
||||
core_id = ocf_core_get_id(core);
|
||||
cache = ocf_core_get_cache(core);
|
||||
|
||||
if (size > sizeof(cache->core_conf_meta[core_id].user_data))
|
||||
if (size > sizeof(core->conf_meta->user_data))
|
||||
return -EINVAL;
|
||||
|
||||
env_memcpy(data, size, cache->core_conf_meta[core_id].user_data,
|
||||
env_memcpy(data, size, core->conf_meta->user_data,
|
||||
OCF_CORE_USER_DATA_SIZE);
|
||||
|
||||
return 0;
|
||||
@@ -933,10 +915,7 @@ int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||
static int _cache_mng_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
|
||||
{
|
||||
uint32_t threshold = *(uint32_t*) cntx;
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
uint32_t threshold_old = cache->core_conf_meta[core_id].
|
||||
seq_cutoff_threshold;
|
||||
uint32_t threshold_old = core->conf_meta->seq_cutoff_threshold;
|
||||
|
||||
if (threshold_old == threshold) {
|
||||
ocf_core_log(core, log_info,
|
||||
@@ -944,7 +923,7 @@ static int _cache_mng_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
|
||||
"already set\n", threshold);
|
||||
return 0;
|
||||
}
|
||||
cache->core_conf_meta[core_id].seq_cutoff_threshold = threshold;
|
||||
core->conf_meta->seq_cutoff_threshold = threshold;
|
||||
|
||||
ocf_core_log(core, log_info, "Changing sequential cutoff "
|
||||
"threshold from %u to %u bytes successful\n",
|
||||
@@ -997,9 +976,7 @@ static const char *_cache_mng_seq_cutoff_policy_get_name(
|
||||
static int _cache_mng_set_core_seq_cutoff_policy(ocf_core_t core, void *cntx)
|
||||
{
|
||||
ocf_seq_cutoff_policy policy = *(ocf_seq_cutoff_policy*) cntx;
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
uint32_t policy_old = cache->core_conf_meta[core_id].seq_cutoff_policy;
|
||||
uint32_t policy_old = core->conf_meta->seq_cutoff_policy;
|
||||
|
||||
if (policy_old == policy) {
|
||||
ocf_core_log(core, log_info,
|
||||
@@ -1014,7 +991,7 @@ static int _cache_mng_set_core_seq_cutoff_policy(ocf_core_t core, void *cntx)
|
||||
return -OCF_ERR_INVAL;
|
||||
}
|
||||
|
||||
cache->core_conf_meta[core_id].seq_cutoff_policy = policy;
|
||||
core->conf_meta->seq_cutoff_policy = policy;
|
||||
|
||||
ocf_core_log(core, log_info,
|
||||
"Changing sequential cutoff policy from %s to %s\n",
|
||||
|
@@ -107,18 +107,14 @@ static void _ocf_mngt_end_flush(ocf_cache_t cache)
|
||||
|
||||
bool ocf_mngt_cache_is_dirty(ocf_cache_t cache)
|
||||
{
|
||||
uint32_t i;
|
||||
ocf_core_t core;
|
||||
ocf_core_id_t core_id;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
for (i = 0; i < OCF_CORE_MAX; ++i) {
|
||||
if (!cache->core_conf_meta[i].added)
|
||||
continue;
|
||||
|
||||
if (env_atomic_read(&(cache->core_runtime_meta[i].
|
||||
dirty_clines))) {
|
||||
for_each_core(cache, core, core_id) {
|
||||
if (env_atomic_read(&core->runtime_meta->dirty_clines))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -133,16 +129,16 @@ bool ocf_mngt_cache_is_dirty(ocf_cache_t cache)
|
||||
* NOTE:
|
||||
* Table is not sorted.
|
||||
*/
|
||||
static int _ocf_mngt_get_sectors(struct ocf_cache *cache, int core_id,
|
||||
static int _ocf_mngt_get_sectors(ocf_cache_t cache, ocf_core_id_t core_id,
|
||||
struct flush_data **tbl, uint32_t *num)
|
||||
{
|
||||
ocf_core_t core = ocf_cache_get_core(cache, core_id);
|
||||
uint64_t core_line;
|
||||
ocf_core_id_t i_core_id;
|
||||
struct flush_data *p;
|
||||
uint32_t i, j, dirty = 0;
|
||||
|
||||
dirty = env_atomic_read(&cache->core_runtime_meta[core_id].
|
||||
dirty_clines);
|
||||
dirty = env_atomic_read(&core->runtime_meta->dirty_clines);
|
||||
if (!dirty) {
|
||||
*num = 0;
|
||||
*tbl = NULL;
|
||||
@@ -202,7 +198,8 @@ static int _ocf_mngt_get_flush_containers(ocf_cache_t cache,
|
||||
uint32_t num;
|
||||
uint64_t core_line;
|
||||
ocf_core_id_t core_id;
|
||||
uint32_t i, j, dirty = 0;
|
||||
ocf_core_t core;
|
||||
uint32_t i, j = 0, dirty = 0;
|
||||
int step = 0;
|
||||
|
||||
/*
|
||||
@@ -226,16 +223,13 @@ static int _ocf_mngt_get_flush_containers(ocf_cache_t cache,
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < OCF_CORE_MAX; i++) {
|
||||
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
|
||||
continue;
|
||||
|
||||
fc[j].core_id = i;
|
||||
core_revmap[i] = j;
|
||||
for_each_core(cache, core, core_id) {
|
||||
fc[j].core_id = core_id;
|
||||
core_revmap[core_id] = j;
|
||||
|
||||
/* Check for dirty blocks */
|
||||
fc[j].count = env_atomic_read(&cache->
|
||||
core_runtime_meta[i].dirty_clines);
|
||||
fc[j].count = env_atomic_read(
|
||||
&core->runtime_meta->dirty_clines);
|
||||
dirty += fc[j].count;
|
||||
|
||||
if (fc[j].count) {
|
||||
@@ -600,7 +594,7 @@ static void _ocf_mngt_flush_finish(ocf_pipeline_t pipeline, void *priv,
|
||||
{
|
||||
struct ocf_mngt_cache_flush_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
int64_t core_id;
|
||||
ocf_core_t core = context->core;
|
||||
|
||||
if (!error) {
|
||||
switch(context->op) {
|
||||
@@ -610,33 +604,32 @@ static void _ocf_mngt_flush_finish(ocf_pipeline_t pipeline, void *priv,
|
||||
break;
|
||||
case flush_core:
|
||||
case purge_core:
|
||||
core_id = ocf_core_get_id(context->core);
|
||||
ENV_BUG_ON(env_atomic_read(&cache->core_runtime_meta
|
||||
[core_id].dirty_clines));
|
||||
ENV_BUG_ON(env_atomic_read(
|
||||
&core->runtime_meta->dirty_clines));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_ocf_mngt_end_flush(context->cache);
|
||||
_ocf_mngt_end_flush(cache);
|
||||
|
||||
switch (context->op) {
|
||||
case flush_cache:
|
||||
context->cmpl.flush_cache(context->cache, context->priv, error);
|
||||
context->cmpl.flush_cache(cache, context->priv, error);
|
||||
break;
|
||||
case flush_core:
|
||||
context->cmpl.flush_core(context->core, context->priv, error);
|
||||
context->cmpl.flush_core(core, context->priv, error);
|
||||
break;
|
||||
case purge_cache:
|
||||
context->cmpl.purge_cache(context->cache, context->priv, error);
|
||||
context->cmpl.purge_cache(cache, context->priv, error);
|
||||
break;
|
||||
case purge_core:
|
||||
context->cmpl.purge_core(context->core, context->priv, error);
|
||||
context->cmpl.purge_core(core, context->priv, error);
|
||||
break;
|
||||
default:
|
||||
ENV_BUG();
|
||||
}
|
||||
|
||||
ocf_pipeline_destroy(context->pipeline);
|
||||
ocf_pipeline_destroy(pipeline);
|
||||
}
|
||||
|
||||
static struct ocf_pipeline_properties _ocf_mngt_cache_flush_pipeline_properties = {
|
||||
|
Reference in New Issue
Block a user