Merge pull request #229 from robertbaldyga/cleanup-metadata

Metadata interface cleanup
This commit is contained in:
Adam Rutkowski 2019-08-05 14:11:04 +02:00 committed by GitHub
commit 9649f25415
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 139 additions and 369 deletions

View File

@ -207,24 +207,4 @@ typedef void (*ocf_metadata_load_properties_end_t)(void *priv, int error,
void ocf_metadata_load_properties(ocf_volume_t volume, void ocf_metadata_load_properties(ocf_volume_t volume,
ocf_metadata_load_properties_end_t cmpl, void *priv); ocf_metadata_load_properties_end_t cmpl, void *priv);
/**
* @brief Validate cache line size
*
* @param size Cache line size
* @return true - cache line size is valid, false - cache line is invalid
*/
static inline bool ocf_metadata_line_size_is_valid(uint32_t size)
{
switch (size) {
case 4 * KiB:
case 8 * KiB:
case 16 * KiB:
case 32 * KiB:
case 64 * KiB:
return true;
default:
return false;
}
}
#endif /* METADATA_H_ */ #endif /* METADATA_H_ */

View File

@ -65,7 +65,7 @@ static bool _ocf_metadata_test_##what##_##type(struct ocf_cache *cache, \
\ \
const struct ocf_metadata_map_##type *map = raw->mem_pool; \ const struct ocf_metadata_map_##type *map = raw->mem_pool; \
\ \
_raw_bug_on(raw, line, sizeof(*map)); \ _raw_bug_on(raw, line); \
\ \
if (all) { \ if (all) { \
if (mask == (map[line].what & mask)) { \ if (mask == (map[line].what & mask)) { \
@ -95,7 +95,7 @@ static bool _ocf_metadata_test_out_##what##_##type(struct ocf_cache *cache, \
\ \
const struct ocf_metadata_map_##type *map = raw->mem_pool; \ const struct ocf_metadata_map_##type *map = raw->mem_pool; \
\ \
_raw_bug_on(raw, line, sizeof(*map)); \ _raw_bug_on(raw, line); \
\ \
if (map[line].what & ~mask) { \ if (map[line].what & ~mask) { \
return true; \ return true; \
@ -117,7 +117,7 @@ static bool _ocf_metadata_clear_##what##_##type(struct ocf_cache *cache, \
\ \
struct ocf_metadata_map_##type *map = raw->mem_pool; \ struct ocf_metadata_map_##type *map = raw->mem_pool; \
\ \
_raw_bug_on(raw, line, sizeof(*map)); \ _raw_bug_on(raw, line); \
\ \
map[line].what &= ~mask; \ map[line].what &= ~mask; \
\ \
@ -142,7 +142,7 @@ static bool _ocf_metadata_set_##what##_##type(struct ocf_cache *cache, \
\ \
struct ocf_metadata_map_##type *map = raw->mem_pool; \ struct ocf_metadata_map_##type *map = raw->mem_pool; \
\ \
_raw_bug_on(raw, line, sizeof(*map)); \ _raw_bug_on(raw, line); \
\ \
result = map[line].what ? true : false; \ result = map[line].what ? true : false; \
\ \
@ -166,7 +166,7 @@ static bool _ocf_metadata_test_and_set_##what##_##type( \
\ \
struct ocf_metadata_map_##type *map = raw->mem_pool; \ struct ocf_metadata_map_##type *map = raw->mem_pool; \
\ \
_raw_bug_on(raw, line, sizeof(*map)); \ _raw_bug_on(raw, line); \
\ \
if (all) { \ if (all) { \
if (mask == (map[line].what & mask)) { \ if (mask == (map[line].what & mask)) { \
@ -201,7 +201,7 @@ static bool _ocf_metadata_test_and_clear_##what##_##type( \
\ \
struct ocf_metadata_map_##type *map = raw->mem_pool; \ struct ocf_metadata_map_##type *map = raw->mem_pool; \
\ \
_raw_bug_on(raw, line, sizeof(*map)); \ _raw_bug_on(raw, line); \
\ \
if (all) { \ if (all) { \
if (mask == (map[line].what & mask)) { \ if (mask == (map[line].what & mask)) { \

View File

@ -59,13 +59,6 @@ static inline void ocf_metadata_set_collision_info(
cache->metadata.iface.set_collision_info(cache, line, next, prev); cache->metadata.iface.set_collision_info(cache, line, next, prev);
} }
static inline void ocf_metadata_get_collision_info(
struct ocf_cache *cache, ocf_cache_line_t line,
ocf_cache_line_t *next, ocf_cache_line_t *prev)
{
cache->metadata.iface.get_collision_info(cache, line, next, prev);
}
static inline void ocf_metadata_set_collision_next( static inline void ocf_metadata_set_collision_next(
struct ocf_cache *cache, ocf_cache_line_t line, struct ocf_cache *cache, ocf_cache_line_t line,
ocf_cache_line_t next) ocf_cache_line_t next)
@ -80,16 +73,29 @@ static inline void ocf_metadata_set_collision_prev(
cache->metadata.iface.set_collision_prev(cache, line, prev); cache->metadata.iface.set_collision_prev(cache, line, prev);
} }
static inline void ocf_metadata_get_collision_info(
struct ocf_cache *cache, ocf_cache_line_t line,
ocf_cache_line_t *next, ocf_cache_line_t *prev)
{
cache->metadata.iface.get_collision_info(cache, line, next, prev);
}
static inline ocf_cache_line_t ocf_metadata_get_collision_next( static inline ocf_cache_line_t ocf_metadata_get_collision_next(
struct ocf_cache *cache, ocf_cache_line_t line) struct ocf_cache *cache, ocf_cache_line_t line)
{ {
return cache->metadata.iface.get_collision_next(cache, line); ocf_cache_line_t next;
ocf_metadata_get_collision_info(cache, line, &next, NULL);
return next;
} }
static inline ocf_cache_line_t ocf_metadata_get_collision_prev( static inline ocf_cache_line_t ocf_metadata_get_collision_prev(
struct ocf_cache *cache, ocf_cache_line_t line) struct ocf_cache *cache, ocf_cache_line_t line)
{ {
return cache->metadata.iface.get_collision_prev(cache, line); ocf_cache_line_t prev;
ocf_metadata_get_collision_info(cache, line, NULL, &prev);
return prev;
} }
void ocf_metadata_add_to_collision(struct ocf_cache *cache, void ocf_metadata_add_to_collision(struct ocf_cache *cache,

View File

@ -36,12 +36,6 @@ static inline ocf_core_id_t ocf_metadata_get_core_id(
return cache->metadata.iface.get_core_id(cache, line); return cache->metadata.iface.get_core_id(cache, line);
} }
static inline uint64_t ocf_metadata_get_core_sector(
struct ocf_cache *cache, ocf_cache_line_t line)
{
return cache->metadata.iface.get_core_sector(cache, line);
}
static inline struct ocf_metadata_uuid *ocf_metadata_get_core_uuid( static inline struct ocf_metadata_uuid *ocf_metadata_get_core_uuid(
struct ocf_cache *cache, ocf_core_id_t core_id) struct ocf_cache *cache, ocf_core_id_t core_id)
{ {

View File

@ -2198,8 +2198,7 @@ static void ocf_metadata_hash_get_core_info(struct ocf_cache *cache,
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
collision = ocf_metadata_raw_rd_access(cache, collision = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_collision]), line, &(ctrl->raw_desc[metadata_segment_collision]), line);
ctrl->mapping_size);
if (collision) { if (collision) {
if (core_id) if (core_id)
*core_id = collision->core_id; *core_id = collision->core_id;
@ -2219,17 +2218,16 @@ static void ocf_metadata_hash_set_core_info(struct ocf_cache *cache,
ocf_cache_line_t line, ocf_core_id_t core_id, ocf_cache_line_t line, ocf_core_id_t core_id,
uint64_t core_sector) uint64_t core_sector)
{ {
struct ocf_metadata_map *collisioin; struct ocf_metadata_map *collision;
struct ocf_metadata_hash_ctrl *ctrl = struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
collisioin = ocf_metadata_raw_wr_access(cache, collision = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_collision]), line, &(ctrl->raw_desc[metadata_segment_collision]), line);
ctrl->mapping_size);
if (collisioin) { if (collision) {
collisioin->core_id = core_id; collision->core_id = core_id;
collisioin->core_line = core_sector; collision->core_line = core_sector;
} else { } else {
ocf_metadata_error(cache); ocf_metadata_error(cache);
} }
@ -2243,8 +2241,7 @@ static ocf_core_id_t ocf_metadata_hash_get_core_id(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
collision = ocf_metadata_raw_rd_access(cache, collision = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_collision]), line, &(ctrl->raw_desc[metadata_segment_collision]), line);
ctrl->mapping_size);
if (collision) if (collision)
return collision->core_id; return collision->core_id;
@ -2253,24 +2250,6 @@ static ocf_core_id_t ocf_metadata_hash_get_core_id(
return OCF_CORE_MAX; return OCF_CORE_MAX;
} }
static uint64_t ocf_metadata_hash_get_core_sector(
struct ocf_cache *cache, ocf_cache_line_t line)
{
const struct ocf_metadata_map *collision;
struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
collision = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_collision]), line,
ctrl->mapping_size);
if (collision)
return collision->core_line;
ocf_metadata_error(cache);
return ULLONG_MAX;
}
static struct ocf_metadata_uuid *ocf_metadata_hash_get_core_uuid( static struct ocf_metadata_uuid *ocf_metadata_hash_get_core_uuid(
struct ocf_cache *cache, ocf_core_id_t core_id) struct ocf_cache *cache, ocf_core_id_t core_id)
{ {
@ -2279,8 +2258,7 @@ static struct ocf_metadata_uuid *ocf_metadata_hash_get_core_uuid(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
muuid = ocf_metadata_raw_wr_access(cache, muuid = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_core_uuid]), &(ctrl->raw_desc[metadata_segment_core_uuid]), core_id);
core_id, sizeof(struct ocf_metadata_uuid));
if (!muuid) if (!muuid)
ocf_metadata_error(cache); ocf_metadata_error(cache);
@ -2302,12 +2280,10 @@ static void ocf_metadata_hash_get_core_and_part_id(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
collision = ocf_metadata_raw_rd_access(cache, collision = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_collision]), line, &(ctrl->raw_desc[metadata_segment_collision]), line);
ctrl->mapping_size);
info = ocf_metadata_raw_rd_access(cache, info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (collision && info) { if (collision && info) {
if (core_id) if (core_id)
@ -2338,8 +2314,7 @@ static ocf_cache_line_t ocf_metadata_hash_get_hash(
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; = (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
result = ocf_metadata_raw_get(cache, result = ocf_metadata_raw_get(cache,
&(ctrl->raw_desc[metadata_segment_hash]), index, &(ctrl->raw_desc[metadata_segment_hash]), index, &line);
&line, sizeof(line));
if (result) if (result)
ocf_metadata_error(cache); ocf_metadata_error(cache);
@ -2358,25 +2333,12 @@ static void ocf_metadata_hash_set_hash(struct ocf_cache *cache,
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; = (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
result = ocf_metadata_raw_set(cache, result = ocf_metadata_raw_set(cache,
&(ctrl->raw_desc[metadata_segment_hash]), index, &(ctrl->raw_desc[metadata_segment_hash]), index, &line);
&line, sizeof(line));
if (result) if (result)
ocf_metadata_error(cache); ocf_metadata_error(cache);
} }
/*
* Hash Table - Get Entries
*/
static ocf_cache_line_t ocf_metadata_hash_entries_hash(
struct ocf_cache *cache)
{
struct ocf_metadata_hash_ctrl *ctrl
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
return ctrl->raw_desc[metadata_segment_hash].entries;
}
/******************************************************************************* /*******************************************************************************
* Cleaning Policy * Cleaning Policy
******************************************************************************/ ******************************************************************************/
@ -2394,7 +2356,7 @@ static void ocf_metadata_hash_get_cleaning_policy(
result = ocf_metadata_raw_get(cache, result = ocf_metadata_raw_get(cache,
&(ctrl->raw_desc[metadata_segment_cleaning]), line, &(ctrl->raw_desc[metadata_segment_cleaning]), line,
cleaning_policy, sizeof(*cleaning_policy)); cleaning_policy);
if (result) if (result)
ocf_metadata_error(cache); ocf_metadata_error(cache);
@ -2413,7 +2375,7 @@ static void ocf_metadata_hash_set_cleaning_policy(
result = ocf_metadata_raw_set(cache, result = ocf_metadata_raw_set(cache,
&(ctrl->raw_desc[metadata_segment_cleaning]), line, &(ctrl->raw_desc[metadata_segment_cleaning]), line,
cleaning_policy, sizeof(*cleaning_policy)); cleaning_policy);
if (result) if (result)
ocf_metadata_error(cache); ocf_metadata_error(cache);
@ -2436,7 +2398,7 @@ static void ocf_metadata_hash_get_eviction_policy(
result = ocf_metadata_raw_get(cache, result = ocf_metadata_raw_get(cache,
&(ctrl->raw_desc[metadata_segment_eviction]), line, &(ctrl->raw_desc[metadata_segment_eviction]), line,
eviction_policy, sizeof(*eviction_policy)); eviction_policy);
if (result) if (result)
ocf_metadata_error(cache); ocf_metadata_error(cache);
@ -2455,7 +2417,7 @@ static void ocf_metadata_hash_set_eviction_policy(
result = ocf_metadata_raw_set(cache, result = ocf_metadata_raw_set(cache,
&(ctrl->raw_desc[metadata_segment_eviction]), line, &(ctrl->raw_desc[metadata_segment_eviction]), line,
eviction_policy, sizeof(*eviction_policy)); eviction_policy);
if (result) if (result)
ocf_metadata_error(cache); ocf_metadata_error(cache);
@ -2544,8 +2506,7 @@ static void ocf_metadata_hash_set_collision_info(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_wr_access(cache, info = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) { if (info) {
info->next_col = next; info->next_col = next;
@ -2564,8 +2525,7 @@ static void ocf_metadata_hash_set_collision_next(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_wr_access(cache, info = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) if (info)
info->next_col = next; info->next_col = next;
@ -2582,8 +2542,7 @@ static void ocf_metadata_hash_set_collision_prev(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_wr_access(cache, info = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) if (info)
info->prev_col = prev; info->prev_col = prev;
@ -2602,8 +2561,7 @@ static void ocf_metadata_hash_get_collision_info(
ENV_BUG_ON(NULL == next && NULL == prev); ENV_BUG_ON(NULL == next && NULL == prev);
info = ocf_metadata_raw_rd_access(cache, info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) { if (info) {
if (next) if (next)
*next = info->next_col; *next = info->next_col;
@ -2619,98 +2577,10 @@ static void ocf_metadata_hash_get_collision_info(
} }
} }
static ocf_cache_line_t ocf_metadata_hash_get_collision_next(
struct ocf_cache *cache, ocf_cache_line_t line)
{
const struct ocf_metadata_list_info *info;
struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line,
sizeof(*info));
if (info)
return info->next_col;
ocf_metadata_error(cache);
return cache->device->collision_table_entries;
}
static ocf_cache_line_t ocf_metadata_hash_get_collision_prev(
struct ocf_cache *cache, ocf_cache_line_t line)
{
const struct ocf_metadata_list_info *info;
struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line,
sizeof(*info));
if (info)
return info->prev_col;
ocf_metadata_error(cache);
return cache->device->collision_table_entries;
}
/******************************************************************************* /*******************************************************************************
* Partition * Partition
******************************************************************************/ ******************************************************************************/
static ocf_part_id_t ocf_metadata_hash_get_partition_id(
struct ocf_cache *cache, ocf_cache_line_t line)
{
const struct ocf_metadata_list_info *info;
struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line,
sizeof(*info));
if (info)
return info->partition_id;
ocf_metadata_error(cache);
return PARTITION_DEFAULT;
}
static ocf_cache_line_t ocf_metadata_hash_get_partition_next(
struct ocf_cache *cache, ocf_cache_line_t line)
{
const struct ocf_metadata_list_info *info;
struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line,
sizeof(*info));
if (info)
return info->partition_next;
ocf_metadata_error(cache);
return PARTITION_DEFAULT;
}
static ocf_cache_line_t ocf_metadata_hash_get_partition_prev(
struct ocf_cache *cache, ocf_cache_line_t line)
{
const struct ocf_metadata_list_info *info;
struct ocf_metadata_hash_ctrl *ctrl =
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line,
sizeof(*info));
if (info)
return info->partition_prev;
ocf_metadata_error(cache);
return PARTITION_DEFAULT;
}
static void ocf_metadata_hash_get_partition_info( static void ocf_metadata_hash_get_partition_info(
struct ocf_cache *cache, ocf_cache_line_t line, struct ocf_cache *cache, ocf_cache_line_t line,
ocf_part_id_t *part_id, ocf_cache_line_t *next_line, ocf_part_id_t *part_id, ocf_cache_line_t *next_line,
@ -2721,8 +2591,7 @@ static void ocf_metadata_hash_get_partition_info(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_rd_access(cache, info = ocf_metadata_raw_rd_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) { if (info) {
if (part_id) if (part_id)
@ -2751,8 +2620,7 @@ static void ocf_metadata_hash_set_partition_next(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_wr_access(cache, info = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) if (info)
info->partition_next = next_line; info->partition_next = next_line;
@ -2769,8 +2637,7 @@ static void ocf_metadata_hash_set_partition_prev(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_wr_access(cache, info = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) if (info)
info->partition_prev = prev_line; info->partition_prev = prev_line;
@ -2788,8 +2655,7 @@ static void ocf_metadata_hash_set_partition_info(
(struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv; (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
info = ocf_metadata_raw_wr_access(cache, info = ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_list_info]), line, &(ctrl->raw_desc[metadata_segment_list_info]), line);
sizeof(*info));
if (info) { if (info) {
info->partition_id = part_id; info->partition_id = part_id;
@ -2844,7 +2710,6 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
.set_core_info = ocf_metadata_hash_set_core_info, .set_core_info = ocf_metadata_hash_set_core_info,
.get_core_info = ocf_metadata_hash_get_core_info, .get_core_info = ocf_metadata_hash_get_core_info,
.get_core_id = ocf_metadata_hash_get_core_id, .get_core_id = ocf_metadata_hash_get_core_id,
.get_core_sector = ocf_metadata_hash_get_core_sector,
.get_core_uuid = ocf_metadata_hash_get_core_uuid, .get_core_uuid = ocf_metadata_hash_get_core_uuid,
/* /*
@ -2860,15 +2725,10 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
.set_collision_info = ocf_metadata_hash_set_collision_info, .set_collision_info = ocf_metadata_hash_set_collision_info,
.set_collision_next = ocf_metadata_hash_set_collision_next, .set_collision_next = ocf_metadata_hash_set_collision_next,
.set_collision_prev = ocf_metadata_hash_set_collision_prev, .set_collision_prev = ocf_metadata_hash_set_collision_prev,
.get_collision_next = ocf_metadata_hash_get_collision_next,
.get_collision_prev = ocf_metadata_hash_get_collision_prev,
/* /*
* Partition Info * Partition Info
*/ */
.get_partition_id = ocf_metadata_hash_get_partition_id,
.get_partition_next = ocf_metadata_hash_get_partition_next,
.get_partition_prev = ocf_metadata_hash_get_partition_prev,
.get_partition_info = ocf_metadata_hash_get_partition_info, .get_partition_info = ocf_metadata_hash_get_partition_info,
.set_partition_next = ocf_metadata_hash_set_partition_next, .set_partition_next = ocf_metadata_hash_set_partition_next,
.set_partition_prev = ocf_metadata_hash_set_partition_prev, .set_partition_prev = ocf_metadata_hash_set_partition_prev,
@ -2879,7 +2739,6 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
*/ */
.get_hash = ocf_metadata_hash_get_hash, .get_hash = ocf_metadata_hash_get_hash,
.set_hash = ocf_metadata_hash_set_hash, .set_hash = ocf_metadata_hash_set_hash,
.entries_hash = ocf_metadata_hash_entries_hash,
/* /*
* Cleaning Policy * Cleaning Policy

View File

@ -13,24 +13,6 @@
#define PARTITION_INVALID ((ocf_part_id_t)-1) #define PARTITION_INVALID ((ocf_part_id_t)-1)
#define PARTITION_SIZE_MAX ((ocf_cache_line_t)-1) #define PARTITION_SIZE_MAX ((ocf_cache_line_t)-1)
static inline ocf_part_id_t ocf_metadata_get_partition_id(
struct ocf_cache *cache, ocf_cache_line_t line)
{
return cache->metadata.iface.get_partition_id(cache, line);
}
static inline ocf_cache_line_t ocf_metadata_get_partition_next(
struct ocf_cache *cache, ocf_cache_line_t line)
{
return cache->metadata.iface.get_partition_next(cache, line);
}
static inline ocf_cache_line_t ocf_metadata_get_partition_prev(
struct ocf_cache *cache, ocf_cache_line_t line)
{
return cache->metadata.iface.get_partition_prev(cache, line);
}
static inline void ocf_metadata_get_partition_info( static inline void ocf_metadata_get_partition_info(
struct ocf_cache *cache, ocf_cache_line_t line, struct ocf_cache *cache, ocf_cache_line_t line,
ocf_part_id_t *part_id, ocf_cache_line_t *next_line, ocf_part_id_t *part_id, ocf_cache_line_t *next_line,
@ -40,6 +22,36 @@ static inline void ocf_metadata_get_partition_info(
next_line, prev_line); next_line, prev_line);
} }
static inline ocf_part_id_t ocf_metadata_get_partition_id(
struct ocf_cache *cache, ocf_cache_line_t line)
{
ocf_part_id_t part_id;
ocf_metadata_get_partition_info(cache, line, &part_id, NULL, NULL);
return part_id;
}
static inline ocf_cache_line_t ocf_metadata_get_partition_next(
struct ocf_cache *cache, ocf_cache_line_t line)
{
ocf_cache_line_t next;
ocf_metadata_get_partition_info(cache, line, NULL, &next, NULL);
return next;
}
static inline ocf_cache_line_t ocf_metadata_get_partition_prev(
struct ocf_cache *cache, ocf_cache_line_t line)
{
ocf_cache_line_t prev;
ocf_metadata_get_partition_info(cache, line, NULL, NULL, &prev);
return prev;
}
static inline void ocf_metadata_set_partition_next( static inline void ocf_metadata_set_partition_next(
struct ocf_cache *cache, ocf_cache_line_t line, struct ocf_cache *cache, ocf_cache_line_t line,
ocf_cache_line_t next_line) ocf_cache_line_t next_line)

View File

@ -152,49 +152,34 @@ static uint32_t _raw_ram_checksum(ocf_cache_t cache,
/* /*
* RAM Implementation - Get entry * RAM Implementation - Get entry
*/ */
static int _raw_ram_get(ocf_cache_t cache, static int _raw_ram_get(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data)
void *data, uint32_t size)
{ {
ENV_BUG_ON(!_raw_is_valid(raw, line, size)); ENV_BUG_ON(!_raw_is_valid(raw, entry));
return _RAW_RAM_GET(raw, line, data); return _RAW_RAM_GET(raw, entry, data);
} }
/* /*
* RAM Implementation - Read only entry access * RAM Implementation - Read only entry access
*/ */
static const void *_raw_ram_rd_access(ocf_cache_t cache, static void *_raw_ram_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, struct ocf_metadata_raw *raw, uint32_t entry)
uint32_t size)
{ {
ENV_BUG_ON(!_raw_is_valid(raw, line, size)); ENV_BUG_ON(!_raw_is_valid(raw, entry));
return _RAW_RAM_ADDR(raw, line); return _RAW_RAM_ADDR(raw, entry);
}
/*
* RAM Implementation - Read only entry access
*/
static void *_raw_ram_wr_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line,
uint32_t size)
{
ENV_BUG_ON(!_raw_is_valid(raw, line, size));
return _RAW_RAM_ADDR(raw, line);
} }
/* /*
* RAM Implementation - Set Entry * RAM Implementation - Set Entry
*/ */
static int _raw_ram_set(ocf_cache_t cache, static int _raw_ram_set(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data)
void *data, uint32_t size)
{ {
ENV_BUG_ON(!_raw_is_valid(raw, line, size)); ENV_BUG_ON(!_raw_is_valid(raw, entry));
return _RAW_RAM_SET(raw, line, data); return _RAW_RAM_SET(raw, entry, data);
} }
struct _raw_ram_load_all_context { struct _raw_ram_load_all_context {
@ -558,8 +543,7 @@ static const struct raw_iface IRAW[metadata_raw_type_max] = {
.checksum = _raw_ram_checksum, .checksum = _raw_ram_checksum,
.get = _raw_ram_get, .get = _raw_ram_get,
.set = _raw_ram_set, .set = _raw_ram_set,
.rd_access = _raw_ram_rd_access, .access = _raw_ram_access,
.wr_access = _raw_ram_wr_access,
.load_all = _raw_ram_load_all, .load_all = _raw_ram_load_all,
.flush_all = _raw_ram_flush_all, .flush_all = _raw_ram_flush_all,
.flush_mark = _raw_ram_flush_mark, .flush_mark = _raw_ram_flush_mark,
@ -573,8 +557,7 @@ static const struct raw_iface IRAW[metadata_raw_type_max] = {
.checksum = raw_dynamic_checksum, .checksum = raw_dynamic_checksum,
.get = raw_dynamic_get, .get = raw_dynamic_get,
.set = raw_dynamic_set, .set = raw_dynamic_set,
.rd_access = raw_dynamic_rd_access, .access = raw_dynamic_access,
.wr_access = raw_dynamic_wr_access,
.load_all = raw_dynamic_load_all, .load_all = raw_dynamic_load_all,
.flush_all = raw_dynamic_flush_all, .flush_all = raw_dynamic_flush_all,
.flush_mark = raw_dynamic_flush_mark, .flush_mark = raw_dynamic_flush_mark,
@ -588,8 +571,7 @@ static const struct raw_iface IRAW[metadata_raw_type_max] = {
.checksum = raw_volatile_checksum, .checksum = raw_volatile_checksum,
.get = _raw_ram_get, .get = _raw_ram_get,
.set = _raw_ram_set, .set = _raw_ram_set,
.rd_access = _raw_ram_rd_access, .access = _raw_ram_access,
.wr_access = _raw_ram_wr_access,
.load_all = raw_volatile_load_all, .load_all = raw_volatile_load_all,
.flush_all = raw_volatile_flush_all, .flush_all = raw_volatile_flush_all,
.flush_mark = raw_volatile_flush_mark, .flush_mark = raw_volatile_flush_mark,
@ -603,8 +585,7 @@ static const struct raw_iface IRAW[metadata_raw_type_max] = {
.checksum = _raw_ram_checksum, .checksum = _raw_ram_checksum,
.get = _raw_ram_get, .get = _raw_ram_get,
.set = _raw_ram_set, .set = _raw_ram_set,
.rd_access = _raw_ram_rd_access, .access = _raw_ram_access,
.wr_access = _raw_ram_wr_access,
.load_all = _raw_ram_load_all, .load_all = _raw_ram_load_all,
.flush_all = _raw_ram_flush_all, .flush_all = _raw_ram_flush_all,
.flush_mark = raw_atomic_flush_mark, .flush_mark = raw_atomic_flush_mark,

View File

@ -103,21 +103,14 @@ struct raw_iface {
struct ocf_metadata_raw *raw); struct ocf_metadata_raw *raw);
int (*get)(ocf_cache_t cache, int (*get)(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data);
void *data, uint32_t size);
int (*set)(ocf_cache_t cache, int (*set)(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data);
void *data, uint32_t size);
const void* (*rd_access)(ocf_cache_t cache, void* (*access)(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry);
uint32_t size);
void* (*wr_access)(ocf_cache_t cache,
struct ocf_metadata_raw *raw,
ocf_cache_line_t line, uint32_t size);
void (*load_all)(ocf_cache_t cache, struct ocf_metadata_raw *raw, void (*load_all)(ocf_cache_t cache, struct ocf_metadata_raw *raw,
ocf_metadata_end_t cmpl, void *priv); ocf_metadata_end_t cmpl, void *priv);
@ -130,8 +123,7 @@ struct raw_iface {
uint8_t stop); uint8_t stop);
int (*flush_do_asynch)(ocf_cache_t cache, struct ocf_request *req, int (*flush_do_asynch)(ocf_cache_t cache, struct ocf_request *req,
struct ocf_metadata_raw *raw, struct ocf_metadata_raw *raw, ocf_req_end_t complete);
ocf_req_end_t complete);
}; };
/** /**
@ -196,16 +188,14 @@ static inline uint32_t ocf_metadata_raw_checksum(struct ocf_cache* cache,
* *
* @param cache - Cache instance * @param cache - Cache instance
* @param raw - RAW descriptor * @param raw - RAW descriptor
* @param line - Cache line to be get * @param entry - Entry to be get
* @param data - Data where metadata entry will be copied into * @param data - Data where metadata entry will be copied into
* @param size - Size of data
* @return 0 - Operation success, otherwise error * @return 0 - Operation success, otherwise error
*/ */
static inline int ocf_metadata_raw_get(ocf_cache_t cache, static inline int ocf_metadata_raw_get(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, void *data, struct ocf_metadata_raw *raw, uint32_t entry, void *data)
uint32_t size)
{ {
return raw->iface->get(cache, raw, line, data, size); return raw->iface->get(cache, raw, entry, data);
} }
/** /**
@ -213,16 +203,14 @@ static inline int ocf_metadata_raw_get(ocf_cache_t cache,
* *
* @param cache - Cache instance * @param cache - Cache instance
* @param raw - RAW descriptor * @param raw - RAW descriptor
* @param line - Cache line to be get * @param entry - Entry to be get
* @param data - Data where metadata entry will be copied into * @param data - Data where metadata entry will be copied into
* @param size - Size of data
* @return 0 - Point to accessed data, in case of error NULL * @return 0 - Point to accessed data, in case of error NULL
*/ */
static inline void *ocf_metadata_raw_wr_access(ocf_cache_t cache, static inline void *ocf_metadata_raw_wr_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, struct ocf_metadata_raw *raw, uint32_t entry)
uint32_t size)
{ {
return raw->iface->wr_access(cache, raw, line, size); return raw->iface->access(cache, raw, entry);
} }
/** /**
@ -230,16 +218,14 @@ static inline void *ocf_metadata_raw_wr_access(ocf_cache_t cache,
* *
* @param cache - Cache instance * @param cache - Cache instance
* @param raw - RAW descriptor * @param raw - RAW descriptor
* @param line - Cache line to be get * @param entry - Entry to be get
* @param data - Data where metadata entry will be copied into * @param data - Data where metadata entry will be copied into
* @param size - Size of data
* @return 0 - Point to accessed data, in case of error NULL * @return 0 - Point to accessed data, in case of error NULL
*/ */
static inline const void *ocf_metadata_raw_rd_access( static inline const void *ocf_metadata_raw_rd_access( ocf_cache_t cache,
ocf_cache_t cache, struct ocf_metadata_raw *raw, struct ocf_metadata_raw *raw, uint32_t entry)
ocf_cache_line_t line, uint32_t size)
{ {
return raw->iface->rd_access(cache, raw, line, size); return raw->iface->access(cache, raw, entry);
} }
/** /**
@ -247,16 +233,14 @@ static inline const void *ocf_metadata_raw_rd_access(
* *
* @param cache - Cache instance * @param cache - Cache instance
* @param raw - RAW descriptor * @param raw - RAW descriptor
* @param line - Cache line to be set * @param entry - Entry to be set
* @param data - Data taht will be copied into metadata entry * @param data - Data taht will be copied into metadata entry
* @param size - Size of data
* @return 0 - Operation success, otherwise error * @return 0 - Operation success, otherwise error
*/ */
static inline int ocf_metadata_raw_set(ocf_cache_t cache, static inline int ocf_metadata_raw_set(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, void *data, struct ocf_metadata_raw *raw, uint32_t entry, void *data)
uint32_t size)
{ {
return raw->iface->set(cache, raw, line, data, size); return raw->iface->set(cache, raw, entry, data);
} }
/** /**
@ -307,25 +291,20 @@ static inline int ocf_metadata_raw_flush_do_asynch(ocf_cache_t cache,
/* /*
* Check if line is valid for specified RAW descriptor * Check if line is valid for specified RAW descriptor
*/ */
static inline bool _raw_is_valid(struct ocf_metadata_raw *raw, static inline bool _raw_is_valid(struct ocf_metadata_raw *raw, uint32_t entry)
ocf_cache_line_t line, uint32_t size)
{ {
if (!raw) if (!raw)
return false; return false;
if (size != raw->entry_size) if (entry >= raw->entries)
return false;
if (line >= raw->entries)
return false; return false;
return true; return true;
} }
static inline void _raw_bug_on(struct ocf_metadata_raw *raw, static inline void _raw_bug_on(struct ocf_metadata_raw *raw, uint32_t entry)
ocf_cache_line_t line, uint32_t size)
{ {
ENV_BUG_ON(!_raw_is_valid(raw, line, size)); ENV_BUG_ON(!_raw_is_valid(raw, entry));
} }
#define MAX_STACK_TAB_SIZE 32 #define MAX_STACK_TAB_SIZE 32

View File

@ -64,15 +64,15 @@ struct _raw_ctrl {
}; };
static void *_raw_dynamic_get_item(ocf_cache_t cache, static void *_raw_dynamic_get_item(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t size) struct ocf_metadata_raw *raw, uint32_t entry)
{ {
void *new = NULL; void *new = NULL;
struct _raw_ctrl *ctrl = (struct _raw_ctrl *)raw->priv; struct _raw_ctrl *ctrl = (struct _raw_ctrl *)raw->priv;
uint32_t page = _RAW_DYNAMIC_PAGE(raw, line); uint32_t page = _RAW_DYNAMIC_PAGE(raw, entry);
ENV_BUG_ON(!_raw_is_valid(raw, line, size)); ENV_BUG_ON(!_raw_is_valid(raw, entry));
OCF_DEBUG_PARAM(cache, "Accessing item %u on page %u", line, page); OCF_DEBUG_PARAM(cache, "Accessing item %u on page %u", entry, page);
if (!ctrl->pages[page]) { if (!ctrl->pages[page]) {
/* No page, allocate one, and set*/ /* No page, allocate one, and set*/
@ -107,7 +107,7 @@ _raw_dynamic_get_item_SKIP:
} }
if (ctrl->pages[page]) if (ctrl->pages[page])
return ctrl->pages[page] + _RAW_DYNAMIC_PAGE_OFFSET(raw, line); return ctrl->pages[page] + _RAW_DYNAMIC_PAGE_OFFSET(raw, entry);
return NULL; return NULL;
} }
@ -220,56 +220,43 @@ uint32_t raw_dynamic_checksum(ocf_cache_t cache,
/* /*
* RAM DYNAMIC Implementation - Get * RAM DYNAMIC Implementation - Get
*/ */
int raw_dynamic_get(ocf_cache_t cache, int raw_dynamic_get(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data)
void *data, uint32_t size)
{ {
void *item = _raw_dynamic_get_item(cache, raw, line, size); void *item = _raw_dynamic_get_item(cache, raw, entry);
if (!item) { if (!item) {
ENV_BUG_ON(env_memset(data, size, 0)); ENV_BUG_ON(env_memset(data, raw->entry_size, 0));
ocf_metadata_error(cache); ocf_metadata_error(cache);
return -1; return -1;
} }
return env_memcpy(data, size, item, size); return env_memcpy(data, raw->entry_size, item, raw->entry_size);
} }
/* /*
* RAM DYNAMIC Implementation - Set * RAM DYNAMIC Implementation - Set
*/ */
int raw_dynamic_set(ocf_cache_t cache, int raw_dynamic_set(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data)
void *data, uint32_t size)
{ {
void *item = _raw_dynamic_get_item(cache, raw, line, size); void *item = _raw_dynamic_get_item(cache, raw, entry);
if (!item) { if (!item) {
ocf_metadata_error(cache); ocf_metadata_error(cache);
return -1; return -1;
} }
return env_memcpy(item, size, data, size); return env_memcpy(item, raw->entry_size, data, raw->entry_size);
} }
/* /*
* RAM DYNAMIC Implementation - access * RAM DYNAMIC Implementation - access
*/ */
const void *raw_dynamic_rd_access(ocf_cache_t cache, void *raw_dynamic_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, struct ocf_metadata_raw *raw, uint32_t entry)
uint32_t size)
{ {
return _raw_dynamic_get_item(cache, raw, line, size); return _raw_dynamic_get_item(cache, raw, entry);
}
/*
* RAM DYNAMIC Implementation - access
*/
void *raw_dynamic_wr_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line,
uint32_t size)
{
return _raw_dynamic_get_item(cache, raw, line, size);
} }
/* /*

View File

@ -43,30 +43,20 @@ uint32_t raw_dynamic_checksum(ocf_cache_t cache,
/* /*
* RAW DYNAMIC - Get specified entry * RAW DYNAMIC - Get specified entry
*/ */
int raw_dynamic_get(ocf_cache_t cache, int raw_dynamic_get(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data);
void *data, uint32_t size);
/* /*
* RAW DYNAMIC - Set specified entry * RAW DYNAMIC - Set specified entry
*/ */
int raw_dynamic_set(ocf_cache_t cache, int raw_dynamic_set(ocf_cache_t cache, struct ocf_metadata_raw *raw,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, uint32_t entry, void *data);
void *data, uint32_t size);
/*
* RAW DYNAMIC - Read only access for specified entry
*/
const void *raw_dynamic_rd_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line,
uint32_t size);
/* /*
* RAW DYNAMIC - Write access for specified entry * RAW DYNAMIC - Write access for specified entry
*/ */
void *raw_dynamic_wr_access(ocf_cache_t cache, void *raw_dynamic_access(ocf_cache_t cache,
struct ocf_metadata_raw *raw, ocf_cache_line_t line, struct ocf_metadata_raw *raw, uint32_t entry);
uint32_t size);
/* /*
* RAW DYNAMIC - Load all metadata of this RAW metadata container * RAW DYNAMIC - Load all metadata of this RAW metadata container

View File

@ -340,9 +340,6 @@ struct ocf_metadata_iface {
ocf_core_id_t (*get_core_id)(struct ocf_cache *cache, ocf_core_id_t (*get_core_id)(struct ocf_cache *cache,
ocf_cache_line_t line); ocf_cache_line_t line);
uint64_t (*get_core_sector)(struct ocf_cache *cache,
ocf_cache_line_t line);
void (*get_core_and_part_id)(struct ocf_cache *cache, void (*get_core_and_part_id)(struct ocf_cache *cache,
ocf_cache_line_t line, ocf_core_id_t *core_id, ocf_cache_line_t line, ocf_core_id_t *core_id,
ocf_part_id_t *part_id); ocf_part_id_t *part_id);
@ -364,21 +361,6 @@ struct ocf_metadata_iface {
void (*set_collision_prev)(struct ocf_cache *cache, void (*set_collision_prev)(struct ocf_cache *cache,
ocf_cache_line_t line, ocf_cache_line_t prev); ocf_cache_line_t line, ocf_cache_line_t prev);
ocf_cache_line_t (*get_collision_next)(struct ocf_cache *cache,
ocf_cache_line_t line);
ocf_cache_line_t (*get_collision_prev)(struct ocf_cache *cache,
ocf_cache_line_t line);
ocf_part_id_t (*get_partition_id)(struct ocf_cache *cache,
ocf_cache_line_t line);
ocf_cache_line_t (*get_partition_next)(struct ocf_cache *cache,
ocf_cache_line_t line);
ocf_cache_line_t (*get_partition_prev)(struct ocf_cache *cache,
ocf_cache_line_t line);
void (*get_partition_info)(struct ocf_cache *cache, void (*get_partition_info)(struct ocf_cache *cache,
ocf_cache_line_t line, ocf_part_id_t *part_id, ocf_cache_line_t line, ocf_part_id_t *part_id,
ocf_cache_line_t *next_line, ocf_cache_line_t *next_line,