Change nhit_hash names to avoid collision with kernel

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial 2019-08-28 14:32:22 +02:00
parent a1d3cf0c4d
commit ee3fdb0506
4 changed files with 36 additions and 37 deletions

View File

@ -1,25 +0,0 @@
/*
* Copyright(c) 2019 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef NHIT_HASH_H_
#define NHIT_HASH_H_
#include "ocf/ocf.h"
typedef struct nhit_hash *nhit_hash_t;
ocf_error_t hash_init(uint64_t hash_size, nhit_hash_t *ctx);
void hash_deinit(nhit_hash_t ctx);
void hash_insert(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba);
bool hash_query(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba,
int32_t *counter);
void hash_set_occurences(nhit_hash_t ctx, ocf_core_id_t core_id,
uint64_t core_lba, int32_t occurences);
#endif /* NHIT_HASH_H_ */

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: BSD-3-Clause-Clear * SPDX-License-Identifier: BSD-3-Clause-Clear
*/ */
#include "hash.h" #include "nhit_hash.h"
#include "../../metadata/metadata.h" #include "../../metadata/metadata.h"
#include "../../ocf_priv.h" #include "../../ocf_priv.h"
#include "../../engine/engine_common.h" #include "../../engine/engine_common.h"
@ -32,7 +32,7 @@ ocf_error_t nhit_init(ocf_cache_t cache, ocf_promotion_policy_t policy)
goto exit; goto exit;
} }
result = hash_init(ocf_metadata_get_cachelines_count(cache) * result = nhit_hash_init(ocf_metadata_get_cachelines_count(cache) *
NHIT_MAPPING_RATIO, &ctx->hash_map); NHIT_MAPPING_RATIO, &ctx->hash_map);
if (result) if (result)
goto dealloc_ctx; goto dealloc_ctx;
@ -57,7 +57,7 @@ void nhit_deinit(ocf_promotion_policy_t policy)
{ {
struct nhit_policy_context *ctx = policy->ctx; struct nhit_policy_context *ctx = policy->ctx;
hash_deinit(ctx->hash_map); nhit_hash_deinit(ctx->hash_map);
env_vfree(ctx); env_vfree(ctx);
policy->ctx = NULL; policy->ctx = NULL;
@ -137,7 +137,7 @@ ocf_error_t nhit_get_param(ocf_promotion_policy_t policy, uint8_t param_id,
static void core_line_purge(struct nhit_policy_context *ctx, ocf_core_id_t core_id, static void core_line_purge(struct nhit_policy_context *ctx, ocf_core_id_t core_id,
uint64_t core_lba) uint64_t core_lba)
{ {
hash_set_occurences(ctx->hash_map, core_id, core_lba, 0); nhit_hash_set_occurences(ctx->hash_map, core_id, core_lba, 0);
} }
void nhit_req_purge(ocf_promotion_policy_t policy, void nhit_req_purge(ocf_promotion_policy_t policy,
@ -161,13 +161,13 @@ static bool core_line_should_promote(struct nhit_policy_context *ctx,
bool hit; bool hit;
int32_t counter; int32_t counter;
hit = hash_query(ctx->hash_map, core_id, core_lba, &counter); hit = nhit_hash_query(ctx->hash_map, core_id, core_lba, &counter);
if (hit) { if (hit) {
/* we have a hit, return now */ /* we have a hit, return now */
return env_atomic_read(&ctx->insertion_threshold) <= counter; return env_atomic_read(&ctx->insertion_threshold) <= counter;
} }
hash_insert(ctx->hash_map, core_id, core_lba); nhit_hash_insert(ctx->hash_map, core_id, core_lba);
return false; return false;
} }

View File

@ -5,7 +5,7 @@
#include "../../ocf_priv.h" #include "../../ocf_priv.h"
#include "hash.h" #include "nhit_hash.h"
/* Implementation of hashmap-ish structure for tracking core lines in nhit /* Implementation of hashmap-ish structure for tracking core lines in nhit
* promotion policy. It consists of two arrays: * promotion policy. It consists of two arrays:
@ -109,7 +109,7 @@ struct nhit_hash {
env_spinlock rb_pointer_lock; env_spinlock rb_pointer_lock;
}; };
ocf_error_t hash_init(uint64_t hash_size, nhit_hash_t *ctx) ocf_error_t nhit_hash_init(uint64_t hash_size, nhit_hash_t *ctx)
{ {
int result = 0; int result = 0;
struct nhit_hash *new_ctx; struct nhit_hash *new_ctx;
@ -181,7 +181,7 @@ exit:
return result; return result;
} }
void hash_deinit(nhit_hash_t ctx) void nhit_hash_deinit(nhit_hash_t ctx)
{ {
ocf_cache_line_t i; ocf_cache_line_t i;
@ -329,7 +329,7 @@ static inline void write_unlock_hashes(nhit_hash_t ctx, ocf_core_id_t core_id1,
env_rwsem_up_write(&ctx->hash_locks[hash2]); env_rwsem_up_write(&ctx->hash_locks[hash2]);
} }
void hash_insert(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba) void nhit_hash_insert(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba)
{ {
uint64_t slot_id; uint64_t slot_id;
struct nhit_list_elem *slot; struct nhit_list_elem *slot;
@ -353,7 +353,7 @@ void hash_insert(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba)
commit_rb_slot(ctx, slot_id); commit_rb_slot(ctx, slot_id);
} }
bool hash_query(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba, bool nhit_hash_query(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba,
int32_t *counter) int32_t *counter)
{ {
ocf_cache_line_t hash = hash_function(core_id, core_lba, ocf_cache_line_t hash = hash_function(core_id, core_lba,
@ -377,7 +377,7 @@ bool hash_query(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba,
return true; return true;
} }
void hash_set_occurences(nhit_hash_t ctx, ocf_core_id_t core_id, void nhit_hash_set_occurences(nhit_hash_t ctx, ocf_core_id_t core_id,
uint64_t core_lba, int32_t occurences) uint64_t core_lba, int32_t occurences)
{ {
ocf_cache_line_t hash = hash_function(core_id, core_lba, ocf_cache_line_t hash = hash_function(core_id, core_lba,

View File

@ -0,0 +1,24 @@
/*
* Copyright(c) 2019 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef NHIT_HASH_H_
#define NHIT_HASH_H_
#include "ocf/ocf.h"
typedef struct nhit_hash *nhit_hash_t;
ocf_error_t nhit_hash_init(uint64_t hash_size, nhit_hash_t *ctx);
void nhit_hash_deinit(nhit_hash_t ctx);
void nhit_hash_insert(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba);
bool nhit_hash_query(nhit_hash_t ctx, ocf_core_id_t core_id, uint64_t core_lba,
int32_t *counter);
void nhit_hash_set_occurences(nhit_hash_t ctx, ocf_core_id_t core_id,
uint64_t core_lba, int32_t occurences);
#endif /* NHIT_HASH_H_ */