From ee3fdb05062691c663aac5a57f0ad8e3b0c774ca Mon Sep 17 00:00:00 2001 From: Jan Musial Date: Wed, 28 Aug 2019 14:32:22 +0200 Subject: [PATCH] Change nhit_hash names to avoid collision with kernel Signed-off-by: Jan Musial --- src/promotion/nhit/hash.h | 25 ---------------------- src/promotion/nhit/nhit.c | 12 +++++------ src/promotion/nhit/{hash.c => nhit_hash.c} | 12 +++++------ src/promotion/nhit/nhit_hash.h | 24 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 37 deletions(-) delete mode 100644 src/promotion/nhit/hash.h rename src/promotion/nhit/{hash.c => nhit_hash.c} (96%) create mode 100644 src/promotion/nhit/nhit_hash.h diff --git a/src/promotion/nhit/hash.h b/src/promotion/nhit/hash.h deleted file mode 100644 index 8bec31e..0000000 --- a/src/promotion/nhit/hash.h +++ /dev/null @@ -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_ */ diff --git a/src/promotion/nhit/nhit.c b/src/promotion/nhit/nhit.c index e37c91d..7648768 100644 --- a/src/promotion/nhit/nhit.c +++ b/src/promotion/nhit/nhit.c @@ -3,7 +3,7 @@ * SPDX-License-Identifier: BSD-3-Clause-Clear */ -#include "hash.h" +#include "nhit_hash.h" #include "../../metadata/metadata.h" #include "../../ocf_priv.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; } - 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); if (result) goto dealloc_ctx; @@ -57,7 +57,7 @@ void nhit_deinit(ocf_promotion_policy_t policy) { struct nhit_policy_context *ctx = policy->ctx; - hash_deinit(ctx->hash_map); + nhit_hash_deinit(ctx->hash_map); env_vfree(ctx); 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, 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, @@ -161,13 +161,13 @@ static bool core_line_should_promote(struct nhit_policy_context *ctx, bool hit; 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) { /* we have a hit, return now */ 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; } diff --git a/src/promotion/nhit/hash.c b/src/promotion/nhit/nhit_hash.c similarity index 96% rename from src/promotion/nhit/hash.c rename to src/promotion/nhit/nhit_hash.c index ee6a3b9..cb07c75 100644 --- a/src/promotion/nhit/hash.c +++ b/src/promotion/nhit/nhit_hash.c @@ -5,7 +5,7 @@ #include "../../ocf_priv.h" -#include "hash.h" +#include "nhit_hash.h" /* Implementation of hashmap-ish structure for tracking core lines in nhit * promotion policy. It consists of two arrays: @@ -109,7 +109,7 @@ struct nhit_hash { 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; struct nhit_hash *new_ctx; @@ -181,7 +181,7 @@ exit: return result; } -void hash_deinit(nhit_hash_t ctx) +void nhit_hash_deinit(nhit_hash_t ctx) { 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]); } -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; 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); } -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) { 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; } -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) { ocf_cache_line_t hash = hash_function(core_id, core_lba, diff --git a/src/promotion/nhit/nhit_hash.h b/src/promotion/nhit/nhit_hash.h new file mode 100644 index 0000000..407b34c --- /dev/null +++ b/src/promotion/nhit/nhit_hash.h @@ -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_ */