Remove memcpy from collision/eviction policy metadata api
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
ec723e15e1
commit
fec61528e6
@ -155,17 +155,9 @@ static struct acp_context *_acp_get_ctx_from_cache(struct ocf_cache *cache)
|
||||
}
|
||||
|
||||
static struct acp_cleaning_policy_meta* _acp_meta_get(
|
||||
struct ocf_cache *cache, uint32_t cache_line,
|
||||
struct cleaning_policy_meta *policy_meta)
|
||||
struct ocf_cache *cache, uint32_t cache_line)
|
||||
{
|
||||
ocf_metadata_get_cleaning_policy(cache, cache_line, policy_meta);
|
||||
return &policy_meta->meta.acp;
|
||||
}
|
||||
|
||||
static void _acp_meta_set(struct ocf_cache *cache, uint32_t cache_line,
|
||||
struct cleaning_policy_meta *policy_meta)
|
||||
{
|
||||
ocf_metadata_set_cleaning_policy(cache, cache_line, policy_meta);
|
||||
return &ocf_metadata_get_cleaning_policy(cache, cache_line)->meta.acp;
|
||||
}
|
||||
|
||||
static struct acp_core_line_info _acp_core_line_info(struct ocf_cache *cache,
|
||||
@ -222,13 +214,10 @@ static int _acp_load_cores(struct ocf_cache *cache)
|
||||
void cleaning_policy_acp_init_cache_block(struct ocf_cache *cache,
|
||||
uint32_t cache_line)
|
||||
{
|
||||
struct cleaning_policy_meta policy_meta;
|
||||
struct acp_cleaning_policy_meta *acp_meta;
|
||||
|
||||
/* TODO: acp meta is going to be removed soon */
|
||||
acp_meta = _acp_meta_get(cache, cache_line, &policy_meta);
|
||||
acp_meta = _acp_meta_get(cache, cache_line);
|
||||
acp_meta->dirty = 0;
|
||||
_acp_meta_set(cache, cache_line, &policy_meta);
|
||||
}
|
||||
|
||||
void cleaning_policy_acp_deinitialize(struct ocf_cache *cache)
|
||||
@ -613,18 +602,16 @@ void cleaning_policy_acp_set_hot_cache_line(struct ocf_cache *cache,
|
||||
uint32_t cache_line)
|
||||
{
|
||||
struct acp_context *acp = _acp_get_ctx_from_cache(cache);
|
||||
struct cleaning_policy_meta policy_meta;
|
||||
struct acp_cleaning_policy_meta *acp_meta;
|
||||
struct acp_chunk_info *chunk;
|
||||
|
||||
ACP_LOCK_CHUNKS_WR();
|
||||
|
||||
acp_meta = _acp_meta_get(cache, cache_line, &policy_meta);
|
||||
acp_meta = _acp_meta_get(cache, cache_line);
|
||||
chunk = _acp_get_chunk(cache, cache_line);
|
||||
|
||||
if (!acp_meta->dirty) {
|
||||
acp_meta->dirty = 1;
|
||||
_acp_meta_set(cache, cache_line, &policy_meta);
|
||||
chunk->num_dirty++;
|
||||
}
|
||||
|
||||
@ -637,18 +624,16 @@ void cleaning_policy_acp_purge_block(struct ocf_cache *cache,
|
||||
uint32_t cache_line)
|
||||
{
|
||||
struct acp_context *acp = _acp_get_ctx_from_cache(cache);
|
||||
struct cleaning_policy_meta policy_meta;
|
||||
struct acp_cleaning_policy_meta *acp_meta;
|
||||
struct acp_chunk_info *chunk;
|
||||
|
||||
ACP_LOCK_CHUNKS_WR();
|
||||
|
||||
acp_meta = _acp_meta_get(cache, cache_line, &policy_meta);
|
||||
acp_meta = _acp_meta_get(cache, cache_line);
|
||||
chunk = _acp_get_chunk(cache, cache_line);
|
||||
|
||||
if (acp_meta->dirty) {
|
||||
acp_meta->dirty = 0;
|
||||
_acp_meta_set(cache, cache_line, &policy_meta);
|
||||
chunk->num_dirty--;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ static void add_alru_head(struct ocf_cache *cache, int partition_id,
|
||||
unsigned int curr_head_index;
|
||||
unsigned int collision_table_entries = cache->device->collision_table_entries;
|
||||
struct ocf_user_part *part = &cache->user_parts[partition_id];
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
|
||||
ENV_BUG_ON(!(collision_index < collision_table_entries));
|
||||
|
||||
@ -112,14 +112,12 @@ static void add_alru_head(struct ocf_cache *cache, int partition_id,
|
||||
if (env_atomic_read(&part->runtime->cleaning.policy.alru.size) == 0) {
|
||||
update_alru_head_tail(cache, partition_id, collision_index);
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
policy.meta.alru.lru_next = collision_table_entries;
|
||||
policy.meta.alru.lru_prev = collision_table_entries;
|
||||
policy.meta.alru.timestamp = env_ticks_to_secs(
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
collision_index)->meta.alru;
|
||||
alru->lru_next = collision_table_entries;
|
||||
alru->lru_prev = collision_table_entries;
|
||||
alru->timestamp = env_ticks_to_secs(
|
||||
env_get_tick_count());
|
||||
ocf_metadata_set_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
} else {
|
||||
/* Not the first node to be added. */
|
||||
|
||||
@ -127,20 +125,16 @@ static void add_alru_head(struct ocf_cache *cache, int partition_id,
|
||||
|
||||
ENV_BUG_ON(!(curr_head_index < collision_table_entries));
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
policy.meta.alru.lru_next = curr_head_index;
|
||||
policy.meta.alru.lru_prev = collision_table_entries;
|
||||
policy.meta.alru.timestamp = env_ticks_to_secs(
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
collision_index)->meta.alru;
|
||||
alru->lru_next = curr_head_index;
|
||||
alru->lru_prev = collision_table_entries;
|
||||
alru->timestamp = env_ticks_to_secs(
|
||||
env_get_tick_count());
|
||||
ocf_metadata_set_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, curr_head_index,
|
||||
&policy);
|
||||
policy.meta.alru.lru_prev = collision_index;
|
||||
ocf_metadata_set_cleaning_policy(cache, curr_head_index,
|
||||
&policy);
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
curr_head_index)->meta.alru;
|
||||
alru->lru_prev = collision_index;
|
||||
|
||||
update_alru_head(cache, partition_id, collision_index);
|
||||
}
|
||||
@ -157,7 +151,7 @@ static void remove_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
struct ocf_user_part *part = &cache->user_parts[partition_id];
|
||||
struct alru_cleaning_policy *cleaning_policy =
|
||||
&part->runtime->cleaning.policy.alru;
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
|
||||
ENV_BUG_ON(!(collision_index < collision_table_entries));
|
||||
|
||||
@ -167,11 +161,11 @@ static void remove_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
ENV_BUG();
|
||||
}
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, collision_index, &policy);
|
||||
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache, collision_index)
|
||||
->meta.alru;
|
||||
/* Set prev and next (even if non existent) */
|
||||
next_lru_node = policy.meta.alru.lru_next;
|
||||
prev_lru_node = policy.meta.alru.lru_prev;
|
||||
next_lru_node = alru->lru_next;
|
||||
prev_lru_node = alru->lru_prev;
|
||||
|
||||
/* Check if entry is not part of the ALRU list */
|
||||
if ((next_lru_node == collision_table_entries) &&
|
||||
@ -186,11 +180,9 @@ static void remove_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
*/
|
||||
if (cleaning_policy->lru_head == collision_index &&
|
||||
cleaning_policy->lru_tail == collision_index) {
|
||||
policy.meta.alru.lru_next = collision_table_entries;
|
||||
policy.meta.alru.lru_prev = collision_table_entries;
|
||||
alru->lru_next = collision_table_entries;
|
||||
alru->lru_prev = collision_table_entries;
|
||||
|
||||
ocf_metadata_set_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
|
||||
update_alru_head_tail(cache, partition_id,
|
||||
collision_table_entries);
|
||||
@ -201,22 +193,18 @@ static void remove_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
*/
|
||||
else if ((cleaning_policy->lru_tail != collision_index) &&
|
||||
(cleaning_policy->lru_head == collision_index)) {
|
||||
struct cleaning_policy_meta next_policy;
|
||||
struct alru_cleaning_policy_meta *next_alru;
|
||||
|
||||
ENV_BUG_ON(!(next_lru_node < collision_table_entries));
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, next_lru_node,
|
||||
&next_policy);
|
||||
next_alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
next_lru_node)->meta.alru;
|
||||
|
||||
update_alru_head(cache, partition_id, next_lru_node);
|
||||
|
||||
policy.meta.alru.lru_next = collision_table_entries;
|
||||
next_policy.meta.alru.lru_prev = collision_table_entries;
|
||||
alru->lru_next = collision_table_entries;
|
||||
next_alru->lru_prev = collision_table_entries;
|
||||
|
||||
ocf_metadata_set_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
ocf_metadata_set_cleaning_policy(cache, next_lru_node,
|
||||
&next_policy);
|
||||
}
|
||||
|
||||
/* Case 2: else if this collision_index is ALRU tail, but not head,
|
||||
@ -224,53 +212,41 @@ static void remove_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
*/
|
||||
else if ((cleaning_policy->lru_head != collision_index) &&
|
||||
(cleaning_policy->lru_tail == collision_index)) {
|
||||
struct cleaning_policy_meta prev_policy;
|
||||
struct alru_cleaning_policy_meta *prev_alru;
|
||||
|
||||
ENV_BUG_ON(!(prev_lru_node < collision_table_entries));
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, prev_lru_node,
|
||||
&prev_policy);
|
||||
prev_alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
prev_lru_node)->meta.alru;
|
||||
|
||||
update_alru_tail(cache, partition_id, prev_lru_node);
|
||||
|
||||
policy.meta.alru.lru_prev = collision_table_entries;
|
||||
prev_policy.meta.alru.lru_next = collision_table_entries;
|
||||
alru->lru_prev = collision_table_entries;
|
||||
prev_alru->lru_next = collision_table_entries;
|
||||
|
||||
ocf_metadata_set_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
ocf_metadata_set_cleaning_policy(cache, prev_lru_node,
|
||||
&prev_policy);
|
||||
}
|
||||
|
||||
/* Case 3: else this collision_index is a middle node. There is no
|
||||
* change to the head and the tail pointers.
|
||||
*/
|
||||
else {
|
||||
struct cleaning_policy_meta next_policy;
|
||||
struct cleaning_policy_meta prev_policy;
|
||||
struct alru_cleaning_policy_meta *prev_alru, *next_alru;
|
||||
|
||||
ENV_BUG_ON(!(next_lru_node < collision_table_entries));
|
||||
ENV_BUG_ON(!(prev_lru_node < collision_table_entries));
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, prev_lru_node,
|
||||
&prev_policy);
|
||||
ocf_metadata_get_cleaning_policy(cache, next_lru_node,
|
||||
&next_policy);
|
||||
|
||||
prev_alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
prev_lru_node)->meta.alru;
|
||||
next_alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
next_lru_node)->meta.alru;
|
||||
/* Update prev and next nodes */
|
||||
prev_policy.meta.alru.lru_next = policy.meta.alru.lru_next;
|
||||
next_policy.meta.alru.lru_prev = policy.meta.alru.lru_prev;
|
||||
prev_alru->lru_next = alru->lru_next;
|
||||
next_alru->lru_prev = alru->lru_prev;
|
||||
|
||||
/* Update the given node */
|
||||
policy.meta.alru.lru_next = collision_table_entries;
|
||||
policy.meta.alru.lru_prev = collision_table_entries;
|
||||
alru->lru_next = collision_table_entries;
|
||||
alru->lru_prev = collision_table_entries;
|
||||
|
||||
ocf_metadata_set_cleaning_policy(cache, collision_index,
|
||||
&policy);
|
||||
ocf_metadata_set_cleaning_policy(cache, prev_lru_node,
|
||||
&prev_policy);
|
||||
ocf_metadata_set_cleaning_policy(cache, next_lru_node,
|
||||
&next_policy);
|
||||
}
|
||||
|
||||
env_atomic_dec(&part->runtime->cleaning.policy.alru.size);
|
||||
@ -284,14 +260,15 @@ static bool is_on_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
struct ocf_user_part *part = &cache->user_parts[partition_id];
|
||||
struct alru_cleaning_policy *cleaning_policy =
|
||||
&part->runtime->cleaning.policy.alru;
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
|
||||
ENV_BUG_ON(!(collision_index < collision_table_entries));
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, collision_index, &policy);
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache, collision_index)
|
||||
->meta.alru;
|
||||
|
||||
next_lru_node = policy.meta.alru.lru_next;
|
||||
prev_lru_node = policy.meta.alru.lru_prev;
|
||||
next_lru_node = alru->lru_next;
|
||||
prev_lru_node = alru->lru_prev;
|
||||
|
||||
return cleaning_policy->lru_tail == collision_index ||
|
||||
cleaning_policy->lru_head == collision_index ||
|
||||
@ -305,15 +282,13 @@ static bool is_on_alru_list(struct ocf_cache *cache, int partition_id,
|
||||
void cleaning_policy_alru_init_cache_block(struct ocf_cache *cache,
|
||||
uint32_t cache_line)
|
||||
{
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, cache_line, &policy);
|
||||
|
||||
policy.meta.alru.timestamp = 0;
|
||||
policy.meta.alru.lru_prev = cache->device->collision_table_entries;
|
||||
policy.meta.alru.lru_next = cache->device->collision_table_entries;
|
||||
|
||||
ocf_metadata_set_cleaning_policy(cache, cache_line, &policy);
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
cache_line)->meta.alru;
|
||||
alru->timestamp = 0;
|
||||
alru->lru_prev = cache->device->collision_table_entries;
|
||||
alru->lru_next = cache->device->collision_table_entries;
|
||||
}
|
||||
|
||||
void cleaning_policy_alru_purge_cache_block(struct ocf_cache *cache,
|
||||
@ -331,17 +306,17 @@ void cleaning_policy_alru_purge_cache_block(struct ocf_cache *cache,
|
||||
static void __cleaning_policy_alru_purge_cache_block_any(
|
||||
struct ocf_cache *cache, uint32_t cache_line)
|
||||
{
|
||||
struct alru_context *alru = cache->cleaner.cleaning_policy_context;
|
||||
struct alru_context *ctx = cache->cleaner.cleaning_policy_context;
|
||||
|
||||
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache,
|
||||
cache_line);
|
||||
|
||||
env_spinlock_lock(&alru->list_lock[part_id]);
|
||||
env_spinlock_lock(&ctx->list_lock[part_id]);
|
||||
|
||||
if (is_on_alru_list(cache, part_id, cache_line))
|
||||
remove_alru_list(cache, part_id, cache_line);
|
||||
|
||||
env_spinlock_unlock(&alru->list_lock[part_id]);
|
||||
env_spinlock_unlock(&ctx->list_lock[part_id]);
|
||||
}
|
||||
|
||||
int cleaning_policy_alru_purge_range(struct ocf_cache *cache, int core_id,
|
||||
@ -366,23 +341,24 @@ int cleaning_policy_alru_purge_range(struct ocf_cache *cache, int core_id,
|
||||
void cleaning_policy_alru_set_hot_cache_line(struct ocf_cache *cache,
|
||||
uint32_t cache_line)
|
||||
{
|
||||
struct alru_context *alru = cache->cleaner.cleaning_policy_context;
|
||||
struct alru_context *ctx = cache->cleaner.cleaning_policy_context;
|
||||
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache,
|
||||
cache_line);
|
||||
struct ocf_user_part *part = &cache->user_parts[part_id];
|
||||
|
||||
uint32_t prev_lru_node, next_lru_node;
|
||||
uint32_t collision_table_entries = cache->device->collision_table_entries;
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
|
||||
ENV_WARN_ON(!metadata_test_dirty(cache, cache_line));
|
||||
ENV_WARN_ON(!metadata_test_valid_any(cache, cache_line));
|
||||
|
||||
env_spinlock_lock(&alru->list_lock[part_id]);
|
||||
env_spinlock_lock(&ctx->list_lock[part_id]);
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, cache_line, &policy);
|
||||
next_lru_node = policy.meta.alru.lru_next;
|
||||
prev_lru_node = policy.meta.alru.lru_prev;
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
cache_line)->meta.alru;
|
||||
next_lru_node = alru->lru_next;
|
||||
prev_lru_node = alru->lru_prev;
|
||||
|
||||
if ((next_lru_node != collision_table_entries) ||
|
||||
(prev_lru_node != collision_table_entries) ||
|
||||
@ -394,7 +370,7 @@ void cleaning_policy_alru_set_hot_cache_line(struct ocf_cache *cache,
|
||||
|
||||
add_alru_head(cache, part_id, cache_line);
|
||||
|
||||
env_spinlock_unlock(&alru->list_lock[part_id]);
|
||||
env_spinlock_unlock(&ctx->list_lock[part_id]);
|
||||
}
|
||||
|
||||
static void _alru_rebuild(struct ocf_cache *cache)
|
||||
@ -466,31 +442,31 @@ int cleaning_policy_alru_initialize(ocf_cache_t cache, int init_metadata)
|
||||
{
|
||||
struct ocf_user_part *part;
|
||||
ocf_part_id_t part_id;
|
||||
struct alru_context *alru;
|
||||
struct alru_context *ctx;
|
||||
int error = 0;
|
||||
unsigned i;
|
||||
|
||||
alru = env_vzalloc(sizeof(*alru));
|
||||
if (!alru) {
|
||||
ctx = env_vzalloc(sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
ocf_cache_log(cache, log_err, "alru context allocation error\n");
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
error = env_spinlock_init(&alru->list_lock[i]);
|
||||
error = env_spinlock_init(&ctx->list_lock[i]);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
while (i--)
|
||||
env_spinlock_destroy(&alru->list_lock[i]);
|
||||
env_vfree(alru);
|
||||
env_spinlock_destroy(&ctx->list_lock[i]);
|
||||
env_vfree(ctx);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
cache->cleaner.cleaning_policy_context = alru;
|
||||
cache->cleaner.cleaning_policy_context = ctx;
|
||||
|
||||
for_each_part(cache, part, part_id) {
|
||||
cleaning_policy_alru_initialize_part(cache,
|
||||
@ -681,14 +657,14 @@ static void get_block_to_flush(struct flush_data* dst,
|
||||
static bool more_blocks_to_flush(struct ocf_cache *cache,
|
||||
ocf_cache_line_t cache_line, uint32_t last_access)
|
||||
{
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
|
||||
if (cache_line >= cache->device->collision_table_entries)
|
||||
return false;
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, cache_line, &policy);
|
||||
|
||||
if (policy.meta.alru.timestamp >= last_access)
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
cache_line)->meta.alru;
|
||||
if (alru->timestamp >= last_access)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -712,12 +688,12 @@ static bool block_is_busy(struct ocf_cache *cache,
|
||||
return false;
|
||||
}
|
||||
|
||||
static int get_data_to_flush(struct alru_context *alru)
|
||||
static int get_data_to_flush(struct alru_context *ctx)
|
||||
{
|
||||
struct alru_flush_ctx *fctx = &alru->flush_ctx;
|
||||
struct alru_flush_ctx *fctx = &ctx->flush_ctx;
|
||||
ocf_cache_t cache = fctx->cache;
|
||||
struct alru_cleaning_policy_config *config;
|
||||
struct cleaning_policy_meta policy;
|
||||
struct alru_cleaning_policy_meta *alru;
|
||||
ocf_cache_line_t cache_line;
|
||||
struct ocf_user_part *part;
|
||||
uint32_t last_access;
|
||||
@ -727,19 +703,23 @@ static int get_data_to_flush(struct alru_context *alru)
|
||||
config = (void *)&cache->conf_meta->cleaning[ocf_cleaning_alru].data;
|
||||
|
||||
for_each_part(cache, part, part_id) {
|
||||
env_spinlock_lock(&alru->list_lock[part_id]);
|
||||
env_spinlock_lock(&ctx->list_lock[part_id]);
|
||||
|
||||
cache_line = part->runtime->cleaning.policy.alru.lru_tail;
|
||||
|
||||
last_access = compute_timestamp(config);
|
||||
|
||||
#if OCF_CLEANING_DEBUG == 1
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache, cache_line)
|
||||
->meta.alru;
|
||||
OCF_DEBUG_PARAM(cache, "Last access=%u, timestamp=%u rel=%d",
|
||||
last_access, policy.meta.alru.timestamp,
|
||||
policy.meta.alru.timestamp < last_access);
|
||||
last_access, alru->timestamp,
|
||||
alru->timestamp < last_access);
|
||||
#endif
|
||||
|
||||
while (more_blocks_to_flush(cache, cache_line, last_access)) {
|
||||
if (to_flush >= fctx->clines_no) {
|
||||
env_spinlock_unlock(&alru->list_lock[part_id]);
|
||||
env_spinlock_unlock(&ctx->list_lock[part_id]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -749,11 +729,12 @@ static int get_data_to_flush(struct alru_context *alru)
|
||||
to_flush++;
|
||||
}
|
||||
|
||||
ocf_metadata_get_cleaning_policy(cache, cache_line, &policy);
|
||||
cache_line = policy.meta.alru.lru_prev;
|
||||
alru = &ocf_metadata_get_cleaning_policy(cache,
|
||||
cache_line)->meta.alru;
|
||||
cache_line = alru->lru_prev;
|
||||
}
|
||||
|
||||
env_spinlock_unlock(&alru->list_lock[part_id]);
|
||||
env_spinlock_unlock(&ctx->list_lock[part_id]);
|
||||
}
|
||||
|
||||
end:
|
||||
@ -778,9 +759,9 @@ static void alru_clean_complete(void *priv, int err)
|
||||
fctx->cmpl(&fctx->cache->cleaner, interval);
|
||||
}
|
||||
|
||||
static void alru_clean(struct alru_context *alru)
|
||||
static void alru_clean(struct alru_context *ctx)
|
||||
{
|
||||
struct alru_flush_ctx *fctx = &alru->flush_ctx;
|
||||
struct alru_flush_ctx *fctx = &ctx->flush_ctx;
|
||||
ocf_cache_t cache = fctx->cache;
|
||||
int to_clean;
|
||||
|
||||
@ -802,7 +783,7 @@ static void alru_clean(struct alru_context *alru)
|
||||
goto end;
|
||||
}
|
||||
|
||||
to_clean = get_data_to_flush(alru);
|
||||
to_clean = get_data_to_flush(ctx);
|
||||
if (to_clean > 0) {
|
||||
fctx->flush_perfomed = true;
|
||||
ocf_cleaner_do_flush_data_async(cache, fctx->flush_data, to_clean,
|
||||
@ -822,8 +803,8 @@ end:
|
||||
|
||||
void cleaning_alru_perform_cleaning(ocf_cache_t cache, ocf_cleaner_end_t cmpl)
|
||||
{
|
||||
struct alru_context *alru = cache->cleaner.cleaning_policy_context;
|
||||
struct alru_flush_ctx *fctx = &alru->flush_ctx;
|
||||
struct alru_context *ctx = cache->cleaner.cleaning_policy_context;
|
||||
struct alru_flush_ctx *fctx = &ctx->flush_ctx;
|
||||
struct alru_cleaning_policy_config *config;
|
||||
|
||||
config = (void *)&cache->conf_meta->cleaning[ocf_cleaning_alru].data;
|
||||
@ -841,5 +822,5 @@ void cleaning_alru_perform_cleaning(ocf_cache_t cache, ocf_cleaner_end_t cmpl)
|
||||
fctx->cmpl = cmpl;
|
||||
fctx->flush_perfomed = false;
|
||||
|
||||
alru_clean(alru);
|
||||
alru_clean(ctx);
|
||||
}
|
||||
|
@ -23,14 +23,12 @@ static void add_lru_head(ocf_cache_t cache,
|
||||
unsigned int collision_index)
|
||||
|
||||
{
|
||||
union eviction_policy_meta eviction;
|
||||
struct lru_eviction_policy_meta *node;
|
||||
unsigned int curr_head_index;
|
||||
|
||||
ENV_BUG_ON(collision_index == end_marker);
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, collision_index, &eviction);
|
||||
node = &eviction.lru;
|
||||
node = &ocf_metadata_get_eviction_policy(cache, collision_index)->lru;
|
||||
|
||||
/* First node to be added/ */
|
||||
if (!list->num_nodes) {
|
||||
@ -41,11 +39,7 @@ static void add_lru_head(ocf_cache_t cache,
|
||||
node->prev = end_marker;
|
||||
|
||||
list->num_nodes = 1;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, collision_index,
|
||||
&eviction);
|
||||
} else {
|
||||
union eviction_policy_meta eviction_curr_head;
|
||||
struct lru_eviction_policy_meta *curr_head;
|
||||
|
||||
/* Not the first node to be added. */
|
||||
@ -53,9 +47,8 @@ static void add_lru_head(ocf_cache_t cache,
|
||||
|
||||
ENV_BUG_ON(curr_head_index == end_marker);
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, curr_head_index,
|
||||
&eviction_curr_head);
|
||||
curr_head = &eviction_curr_head.lru;
|
||||
curr_head = &ocf_metadata_get_eviction_policy(cache,
|
||||
curr_head_index)->lru;
|
||||
|
||||
node->next = curr_head_index;
|
||||
node->prev = end_marker;
|
||||
@ -64,11 +57,6 @@ static void add_lru_head(ocf_cache_t cache,
|
||||
list->head = collision_index;
|
||||
|
||||
++list->num_nodes;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, curr_head_index,
|
||||
&eviction_curr_head);
|
||||
ocf_metadata_set_evicition_policy(cache, collision_index,
|
||||
&eviction);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,13 +67,11 @@ static void remove_lru_list(ocf_cache_t cache,
|
||||
{
|
||||
int is_head = 0, is_tail = 0;
|
||||
uint32_t prev_lru_node, next_lru_node;
|
||||
union eviction_policy_meta eviction;
|
||||
struct lru_eviction_policy_meta *node;
|
||||
|
||||
ENV_BUG_ON(collision_index == end_marker);
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, collision_index, &eviction);
|
||||
node = &eviction.lru;
|
||||
node = &ocf_metadata_get_eviction_policy(cache, collision_index)->lru;
|
||||
|
||||
is_head = (list->head == collision_index);
|
||||
is_tail = (list->tail == collision_index);
|
||||
@ -101,9 +87,6 @@ static void remove_lru_list(ocf_cache_t cache,
|
||||
node->next = end_marker;
|
||||
node->prev = end_marker;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, collision_index,
|
||||
&eviction);
|
||||
|
||||
list->head = end_marker;
|
||||
list->tail = end_marker;
|
||||
}
|
||||
@ -112,69 +95,49 @@ static void remove_lru_list(ocf_cache_t cache,
|
||||
* update head and return
|
||||
*/
|
||||
else if (is_head) {
|
||||
union eviction_policy_meta eviction_next;
|
||||
struct lru_eviction_policy_meta *next_node;
|
||||
|
||||
ENV_BUG_ON(next_lru_node == end_marker);
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, next_lru_node,
|
||||
&eviction_next);
|
||||
next_node = &eviction_next.lru;
|
||||
next_node = &ocf_metadata_get_eviction_policy(cache,
|
||||
next_lru_node)->lru;
|
||||
|
||||
list->head = next_lru_node;
|
||||
node->next = end_marker;
|
||||
next_node->prev = end_marker;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, collision_index,
|
||||
&eviction);
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, next_lru_node,
|
||||
&eviction_next);
|
||||
}
|
||||
|
||||
/* Case 3: else if this collision_index is LRU tail, but not head,
|
||||
* update tail and return
|
||||
*/
|
||||
else if (is_tail) {
|
||||
union eviction_policy_meta eviction_prev;
|
||||
struct lru_eviction_policy_meta *prev_node;
|
||||
|
||||
ENV_BUG_ON(prev_lru_node == end_marker);
|
||||
|
||||
list->tail = prev_lru_node;
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, prev_lru_node,
|
||||
&eviction_prev);
|
||||
prev_node = &eviction_prev.lru;
|
||||
prev_node = &ocf_metadata_get_eviction_policy(cache,
|
||||
prev_lru_node)->lru;
|
||||
|
||||
node->prev = end_marker;
|
||||
prev_node->next = end_marker;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, collision_index,
|
||||
&eviction);
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, prev_lru_node,
|
||||
&eviction_prev);
|
||||
}
|
||||
|
||||
/* Case 4: else this collision_index is a middle node. There is no
|
||||
* change to the head and the tail pointers.
|
||||
*/
|
||||
else {
|
||||
union eviction_policy_meta eviction_prev;
|
||||
union eviction_policy_meta eviction_next;
|
||||
struct lru_eviction_policy_meta *prev_node;
|
||||
struct lru_eviction_policy_meta *next_node;
|
||||
|
||||
ENV_BUG_ON(next_lru_node == end_marker);
|
||||
ENV_BUG_ON(prev_lru_node == end_marker);
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, next_lru_node,
|
||||
&eviction_next);
|
||||
next_node = &eviction_next.lru;
|
||||
ocf_metadata_get_evicition_policy(cache, prev_lru_node,
|
||||
&eviction_prev);
|
||||
prev_node = &eviction_prev.lru;
|
||||
next_node = &ocf_metadata_get_eviction_policy(cache,
|
||||
next_lru_node)->lru;
|
||||
prev_node = &ocf_metadata_get_eviction_policy(cache,
|
||||
prev_lru_node)->lru;
|
||||
|
||||
/* Update prev and next nodes */
|
||||
prev_node->next = node->next;
|
||||
@ -183,13 +146,6 @@ static void remove_lru_list(ocf_cache_t cache,
|
||||
/* Update the given node */
|
||||
node->next = end_marker;
|
||||
node->prev = end_marker;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, collision_index,
|
||||
&eviction);
|
||||
ocf_metadata_set_evicition_policy(cache, next_lru_node,
|
||||
&eviction_next);
|
||||
ocf_metadata_set_evicition_policy(cache, prev_lru_node,
|
||||
&eviction_prev);
|
||||
}
|
||||
|
||||
--list->num_nodes;
|
||||
@ -199,16 +155,12 @@ static void remove_lru_list(ocf_cache_t cache,
|
||||
|
||||
void evp_lru_init_cline(ocf_cache_t cache, ocf_cache_line_t cline)
|
||||
{
|
||||
union eviction_policy_meta eviction;
|
||||
struct lru_eviction_policy_meta *node;
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, cline, &eviction);
|
||||
node = &eviction.lru;
|
||||
node = &ocf_metadata_get_eviction_policy(cache, cline)->lru;
|
||||
|
||||
node->prev = end_marker;
|
||||
node->next = end_marker;
|
||||
|
||||
ocf_metadata_set_evicition_policy(cache, cline, &eviction);
|
||||
}
|
||||
|
||||
|
||||
@ -236,14 +188,12 @@ static void evp_lru_clean_end(void *private_data, int error)
|
||||
static int evp_lru_clean_getter(ocf_cache_t cache,
|
||||
void *getter_context, uint32_t item, ocf_cache_line_t *line)
|
||||
{
|
||||
union eviction_policy_meta eviction;
|
||||
struct ocf_cleaner_attribs *attribs = getter_context;
|
||||
ocf_cache_line_t prev_cline, curr_cline = attribs->getter_item;
|
||||
|
||||
while (curr_cline != end_marker) {
|
||||
ocf_metadata_get_evicition_policy(cache, curr_cline,
|
||||
&eviction);
|
||||
prev_cline = eviction.lru.prev;
|
||||
prev_cline = ocf_metadata_get_eviction_policy(cache,
|
||||
curr_cline)->lru.prev;
|
||||
|
||||
/* Prevent evicting already locked items */
|
||||
if (ocf_cache_line_is_used(cache, curr_cline)) {
|
||||
@ -351,7 +301,6 @@ uint32_t evp_lru_req_clines(ocf_cache_t cache, ocf_queue_t io_queue,
|
||||
uint32_t i;
|
||||
ocf_cache_line_t curr_cline, prev_cline;
|
||||
struct ocf_user_part *part = &cache->user_parts[part_id];
|
||||
union eviction_policy_meta eviction;
|
||||
|
||||
if (cline_no == 0)
|
||||
return 0;
|
||||
@ -366,9 +315,8 @@ uint32_t evp_lru_req_clines(ocf_cache_t cache, ocf_queue_t io_queue,
|
||||
if (curr_cline == end_marker)
|
||||
break;
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, curr_cline,
|
||||
&eviction);
|
||||
prev_cline = eviction.lru.prev;
|
||||
prev_cline = ocf_metadata_get_eviction_policy(cache,
|
||||
curr_cline)->lru.prev;
|
||||
|
||||
/* Prevent evicting already locked items */
|
||||
if (ocf_cache_line_is_used(cache, curr_cline)) {
|
||||
@ -414,13 +362,11 @@ void evp_lru_hot_cline(ocf_cache_t cache, ocf_cache_line_t cline)
|
||||
{
|
||||
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache, cline);
|
||||
struct ocf_user_part *part = &cache->user_parts[part_id];
|
||||
union eviction_policy_meta eviction;
|
||||
struct lru_eviction_policy_meta *node;
|
||||
int cline_dirty;
|
||||
struct ocf_lru_list *list;
|
||||
|
||||
ocf_metadata_get_evicition_policy(cache, cline, &eviction);
|
||||
node = &eviction.lru;
|
||||
node = &ocf_metadata_get_eviction_policy(cache, cline)->lru;
|
||||
|
||||
cline_dirty = metadata_test_dirty(cache, cline);
|
||||
list = cline_dirty ?
|
||||
|
@ -6,24 +6,12 @@
|
||||
#ifndef __METADATA_CLEANING_POLICY_H__
|
||||
#define __METADATA_CLEANING_POLICY_H__
|
||||
|
||||
/*
|
||||
* GET
|
||||
*/
|
||||
static inline void
|
||||
static inline struct cleaning_policy_meta *
|
||||
ocf_metadata_get_cleaning_policy(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, struct cleaning_policy_meta *policy)
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
cache->metadata.iface.get_cleaning_policy(cache, line, policy);
|
||||
return cache->metadata.iface.get_cleaning_policy(cache, line);
|
||||
}
|
||||
|
||||
/*
|
||||
* SET
|
||||
*/
|
||||
static inline void
|
||||
ocf_metadata_set_cleaning_policy(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, struct cleaning_policy_meta *policy)
|
||||
{
|
||||
cache->metadata.iface.set_cleaning_policy(cache, line, policy);
|
||||
}
|
||||
|
||||
#endif /* METADATA_CLEANING_POLICY_H_ */
|
||||
|
@ -6,21 +6,11 @@
|
||||
#ifndef __METADATA_EVICTION_H__
|
||||
#define __METADATA_EVICTION_H__
|
||||
|
||||
static inline void ocf_metadata_get_evicition_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||
union eviction_policy_meta *eviction)
|
||||
static inline union eviction_policy_meta *
|
||||
ocf_metadata_get_eviction_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line)
|
||||
{
|
||||
cache->metadata.iface.get_eviction_policy(cache, line, eviction);
|
||||
}
|
||||
|
||||
/*
|
||||
* SET
|
||||
*/
|
||||
static inline void ocf_metadata_set_evicition_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||
union eviction_policy_meta *eviction)
|
||||
{
|
||||
cache->metadata.iface.set_eviction_policy(cache, line, eviction);
|
||||
return cache->metadata.iface.get_eviction_policy(cache, line);
|
||||
}
|
||||
|
||||
#endif /* METADATA_EVICTION_H_ */
|
||||
|
@ -2410,39 +2410,15 @@ static void ocf_metadata_hash_set_hash(struct ocf_cache *cache,
|
||||
/*
|
||||
* Cleaning policy - Get
|
||||
*/
|
||||
static void ocf_metadata_hash_get_cleaning_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||
struct cleaning_policy_meta *cleaning_policy)
|
||||
static struct cleaning_policy_meta *
|
||||
ocf_metadata_hash_get_cleaning_policy(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
int result = 0;
|
||||
struct ocf_metadata_hash_ctrl *ctrl
|
||||
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
|
||||
|
||||
result = ocf_metadata_raw_get(cache,
|
||||
&(ctrl->raw_desc[metadata_segment_cleaning]), line,
|
||||
cleaning_policy);
|
||||
|
||||
if (result)
|
||||
ocf_metadata_error(cache);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleaning policy - Set
|
||||
*/
|
||||
static void ocf_metadata_hash_set_cleaning_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||
struct cleaning_policy_meta *cleaning_policy)
|
||||
{
|
||||
int result = 0;
|
||||
struct ocf_metadata_hash_ctrl *ctrl
|
||||
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
|
||||
|
||||
result = ocf_metadata_raw_set(cache,
|
||||
&(ctrl->raw_desc[metadata_segment_cleaning]), line,
|
||||
cleaning_policy);
|
||||
|
||||
if (result)
|
||||
ocf_metadata_error(cache);
|
||||
return ocf_metadata_raw_wr_access(cache,
|
||||
&(ctrl->raw_desc[metadata_segment_cleaning]), line);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -2452,39 +2428,15 @@ static void ocf_metadata_hash_set_cleaning_policy(
|
||||
/*
|
||||
* Eviction policy - Get
|
||||
*/
|
||||
static void ocf_metadata_hash_get_eviction_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||
union eviction_policy_meta *eviction_policy)
|
||||
static union eviction_policy_meta *
|
||||
ocf_metadata_hash_get_eviction_policy(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
int result = 0;
|
||||
struct ocf_metadata_hash_ctrl *ctrl
|
||||
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
|
||||
|
||||
result = ocf_metadata_raw_get(cache,
|
||||
&(ctrl->raw_desc[metadata_segment_eviction]), line,
|
||||
eviction_policy);
|
||||
|
||||
if (result)
|
||||
ocf_metadata_error(cache);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleaning policy - Set
|
||||
*/
|
||||
static void ocf_metadata_hash_set_eviction_policy(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||
union eviction_policy_meta *eviction_policy)
|
||||
{
|
||||
int result = 0;
|
||||
struct ocf_metadata_hash_ctrl *ctrl
|
||||
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
|
||||
|
||||
result = ocf_metadata_raw_set(cache,
|
||||
&(ctrl->raw_desc[metadata_segment_eviction]), line,
|
||||
eviction_policy);
|
||||
|
||||
if (result)
|
||||
ocf_metadata_error(cache);
|
||||
return ocf_metadata_raw_wr_access(cache,
|
||||
&(ctrl->raw_desc[metadata_segment_eviction]), line);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -2837,13 +2789,11 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
|
||||
* Cleaning Policy
|
||||
*/
|
||||
.get_cleaning_policy = ocf_metadata_hash_get_cleaning_policy,
|
||||
.set_cleaning_policy = ocf_metadata_hash_set_cleaning_policy,
|
||||
|
||||
/*
|
||||
* Eviction Policy
|
||||
*/
|
||||
.get_eviction_policy = ocf_metadata_hash_get_eviction_policy,
|
||||
.set_eviction_policy = ocf_metadata_hash_set_eviction_policy,
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -257,46 +257,20 @@ struct ocf_metadata_iface {
|
||||
*
|
||||
* @param[in] cache - Cache instance
|
||||
* @param[in] line - cache line for which eviction policy is requested
|
||||
* @param[out] eviction_policy - Eviction policy
|
||||
* @return eviction policy metadata
|
||||
*/
|
||||
void (*get_eviction_policy)(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line,
|
||||
union eviction_policy_meta *eviction_policy);
|
||||
|
||||
/**
|
||||
* @brief Set eviction policy
|
||||
*
|
||||
* @param[in] cache - Cache instance
|
||||
* @param[in] line - Eviction policy values which will be stored in
|
||||
* metadata service
|
||||
* @param[out] eviction_policy - Eviction policy
|
||||
*/
|
||||
void (*set_eviction_policy)(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line,
|
||||
union eviction_policy_meta *eviction_policy);
|
||||
union eviction_policy_meta *(*get_eviction_policy)(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line);
|
||||
|
||||
/**
|
||||
* @brief Get cleaning policy
|
||||
*
|
||||
* @param[in] cache - Cache instance
|
||||
* @param[in] line - cache line for which cleaning policy is requested
|
||||
* @param[out] cleaning_policy - Cleaning policy
|
||||
* @return cleaning_policy metadata
|
||||
*/
|
||||
void (*get_cleaning_policy)(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line,
|
||||
struct cleaning_policy_meta *cleaning_policy);
|
||||
|
||||
/**
|
||||
* @brief Set cleaning policy
|
||||
*
|
||||
* @param[in] cache - Cache instance
|
||||
* @param[in] line
|
||||
* @param[in] cleaning_policy - Cleaning policy values which will be
|
||||
* stored in metadata service
|
||||
*/
|
||||
void (*set_cleaning_policy)(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line,
|
||||
struct cleaning_policy_meta *cleaning_policy);
|
||||
struct cleaning_policy_meta *(*get_cleaning_policy)(
|
||||
struct ocf_cache *cache, ocf_cache_line_t line);
|
||||
|
||||
/**
|
||||
* @brief Get hash table for specified index
|
||||
|
Loading…
Reference in New Issue
Block a user