Move common user and freelist partition data to a new struct

New structure ocf_part is added to contain all the data common for both
user partitions and freelist partition: part_runtime and part_id.
ocf_user_part now contains ocf_part structure as well as pointer to
cleaning partition runtime metadata (moved out from part_runtime) and
user partition config (no change here).

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2021-06-14 17:05:42 +02:00
parent c0b76f9e01
commit 87f834c793
48 changed files with 561 additions and 563 deletions

View File

@@ -36,6 +36,11 @@
#define OCF_METADATA_HASH_DIFF_MAX 1000
struct ocf_part_runtime_meta {
struct ocf_part_runtime runtime;
struct cleaning_policy clean_pol;
};
enum {
ocf_metadata_status_type_valid = 0,
ocf_metadata_status_type_dirty,
@@ -86,10 +91,10 @@ static ocf_cache_line_t ocf_metadata_get_entries(
return 32;
case metadata_segment_part_config:
return OCF_IO_CLASS_MAX + 1;
return OCF_USER_IO_CLASS_MAX + 1;
case metadata_segment_part_runtime:
return OCF_IO_CLASS_MAX + 1;
return OCF_USER_IO_CLASS_MAX + 1;
case metadata_segment_core_config:
return OCF_CORE_MAX;
@@ -154,7 +159,7 @@ static int64_t ocf_metadata_get_element_size(
break;
case metadata_segment_part_runtime:
size = sizeof(struct ocf_user_part_runtime);
size = sizeof(struct ocf_part_runtime_meta);
break;
case metadata_segment_hash:
@@ -515,7 +520,7 @@ static int ocf_metadata_init_fixed_size(struct ocf_cache *cache,
struct ocf_core_meta_config *core_meta_config;
struct ocf_core_meta_runtime *core_meta_runtime;
struct ocf_user_part_config *part_config;
struct ocf_user_part_runtime *part_runtime;
struct ocf_part_runtime_meta *part_runtime_meta;
struct ocf_metadata_segment *superblock;
ocf_core_t core;
ocf_core_id_t core_id;
@@ -565,12 +570,15 @@ static int ocf_metadata_init_fixed_size(struct ocf_cache *cache,
/* Set partition metadata */
part_config = METADATA_MEM_POOL(ctrl, metadata_segment_part_config);
part_runtime = METADATA_MEM_POOL(ctrl, metadata_segment_part_runtime);
part_runtime_meta = METADATA_MEM_POOL(ctrl,
metadata_segment_part_runtime);
for (i = 0; i < OCF_IO_CLASS_MAX + 1; i++) {
for (i = 0; i < OCF_USER_IO_CLASS_MAX + 1; i++) {
cache->user_parts[i].config = &part_config[i];
cache->user_parts[i].runtime = &part_runtime[i];
cache->user_parts[i].id = i;
cache->user_parts[i].clean_pol = &part_runtime_meta[i].clean_pol;
cache->user_parts[i].part.runtime =
&part_runtime_meta[i].runtime;
cache->user_parts[i].part.id = i;
}
/* Set core metadata */

View File

@@ -58,7 +58,7 @@ int ocf_metadata_actor(struct ocf_cache *cache,
end_line = ocf_bytes_2_lines(cache, end_byte);
if (part_id != PARTITION_INVALID) {
for (i = cache->user_parts[part_id].runtime->head;
for (i = cache->user_parts[part_id].part.runtime->head;
i != cache->device->collision_table_entries;
i = next_i) {
next_i = ocf_metadata_get_partition_next(cache, i);

View File

@@ -6,7 +6,7 @@
#include "ocf/ocf.h"
#include "metadata.h"
#include "metadata_internal.h"
#include "../utils/utils_part.h"
#include "../utils/utils_user_part.h"
void ocf_metadata_get_partition_info(struct ocf_cache *cache,
ocf_cache_line_t line, ocf_part_id_t *part_id,
@@ -92,7 +92,7 @@ void ocf_metadata_set_partition_info(struct ocf_cache *cache,
static void update_partition_head(struct ocf_cache *cache,
ocf_part_id_t part_id, ocf_cache_line_t line)
{
struct ocf_user_part *part = &cache->user_parts[part_id];
struct ocf_part *part = &cache->user_parts[part_id].part;
part->runtime->head = line;
}
@@ -103,7 +103,8 @@ void ocf_metadata_add_to_partition(struct ocf_cache *cache,
{
ocf_cache_line_t line_head;
ocf_cache_line_t line_entries = cache->device->collision_table_entries;
struct ocf_user_part *part = &cache->user_parts[part_id];
struct ocf_user_part *user_part = &cache->user_parts[part_id];
struct ocf_part *part = &user_part->part;
ENV_BUG_ON(!(line < line_entries));
@@ -116,11 +117,11 @@ void ocf_metadata_add_to_partition(struct ocf_cache *cache,
ocf_metadata_set_partition_info(cache, line, part_id,
line_entries, line_entries);
if (!ocf_part_is_valid(part)) {
if (!ocf_user_part_is_valid(user_part)) {
/* Partition becomes empty, and is not valid
* update list of partitions
*/
ocf_part_sort(cache);
ocf_user_part_sort(cache);
}
} else {
@@ -149,7 +150,8 @@ void ocf_metadata_remove_from_partition(struct ocf_cache *cache,
int is_head, is_tail;
ocf_cache_line_t prev_line, next_line;
uint32_t line_entries = cache->device->collision_table_entries;
struct ocf_user_part *part = &cache->user_parts[part_id];
struct ocf_user_part *user_part = &cache->user_parts[part_id];
struct ocf_part *part = &user_part->part;
ENV_BUG_ON(!(line < line_entries));
@@ -172,11 +174,11 @@ void ocf_metadata_remove_from_partition(struct ocf_cache *cache,
update_partition_head(cache, part_id, line_entries);
if (!ocf_part_is_valid(part)) {
if (!ocf_user_part_is_valid(user_part)) {
/* Partition becomes not empty, and is not valid
* update list of partitions
*/
ocf_part_sort(cache);
ocf_user_part_sort(cache);
}
} else if (is_head) {

View File

@@ -26,11 +26,10 @@ struct ocf_user_part_config {
ocf_cache_mode_t cache_mode;
};
struct ocf_user_part_runtime {
struct ocf_part_runtime {
uint32_t curr_size;
uint32_t head;
struct eviction_policy eviction[OCF_NUM_EVICTION_LISTS];
struct cleaning_policy cleaning;
};
typedef bool ( *_lru_hash_locked_pfn)(struct ocf_request *req,
@@ -45,7 +44,7 @@ struct ocf_lru_iter
/* cache object */
ocf_cache_t cache;
/* target partition */
struct ocf_user_part *part;
struct ocf_part *part;
/* available (non-empty) eviction list bitmap rotated so that current
@evp is on the most significant bit */
unsigned long long next_avail_evp;
@@ -72,10 +71,18 @@ struct ocf_part_cleaning_ctx {
ocf_cache_line_t cline[OCF_EVICTION_CLEAN_SIZE];
};
/* common partition data for both user-deined partitions as
* well as freelist
*/
struct ocf_part {
struct ocf_part_runtime *runtime;
ocf_part_id_t id;
};
struct ocf_user_part {
struct ocf_user_part_config *config;
struct ocf_user_part_runtime *runtime;
ocf_part_id_t id;
struct cleaning_policy *clean_pol;
struct ocf_part part;
struct ocf_part_cleaning_ctx cleaning;
struct ocf_lst_entry lst_valid;
};

View File

@@ -56,7 +56,7 @@ struct ocf_metadata_lock
struct ocf_metadata_global_lock global[OCF_NUM_GLOBAL_META_LOCKS];
/*!< global metadata lock (GML) */
env_rwlock eviction[OCF_NUM_EVICTION_LISTS]; /*!< Fast lock for eviction policy */
env_spinlock partition[OCF_IO_CLASS_MAX]; /* partition lock */
env_spinlock partition[OCF_USER_IO_CLASS_MAX]; /* partition lock */
env_rwsem *hash; /*!< Hash bucket locks */
env_rwsem *collision_pages; /*!< Collision table page locks */
ocf_cache_t cache; /*!< Parent cache object */

View File

@@ -161,7 +161,7 @@ static void ocf_metadata_load_superblock_post(ocf_pipeline_t pipeline,
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_INVAL);
}
if (sb_config->valid_parts_no > OCF_IO_CLASS_MAX) {
if (sb_config->valid_parts_no > OCF_USER_IO_CLASS_MAX) {
ocf_cache_log(cache, log_err,
"Loading cache state ERROR, invalid partition count\n");
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_INVAL);