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:
@@ -30,7 +30,7 @@
|
||||
#include "alru.h"
|
||||
#include "../metadata/metadata.h"
|
||||
#include "../utils/utils_cleaner.h"
|
||||
#include "../utils/utils_part.h"
|
||||
#include "../utils/utils_user_part.h"
|
||||
#include "../utils/utils_realloc.h"
|
||||
#include "../concurrency/ocf_cache_line_concurrency.h"
|
||||
#include "../ocf_def_priv.h"
|
||||
@@ -49,7 +49,9 @@ static void cleaning_policy_alru_initialize_test01(void **state)
|
||||
print_test_description("Check if all variables are set correctly");
|
||||
|
||||
cache = test_malloc(sizeof(*cache));
|
||||
cache->user_parts[part_id].runtime = test_malloc(sizeof(struct ocf_user_part_runtime));
|
||||
cache->user_parts[part_id].part.runtime = test_malloc(sizeof(struct ocf_part_runtime));
|
||||
cache->user_parts[part_id].clean_pol = test_malloc(sizeof(*cache->user_parts[part_id].clean_pol));
|
||||
cache->user_parts[part_id].part.id = part_id;
|
||||
cache->device = test_malloc(sizeof(struct ocf_cache_device));
|
||||
cache->device->runtime_meta = test_malloc(sizeof(struct ocf_superblock_runtime));
|
||||
|
||||
@@ -59,15 +61,16 @@ static void cleaning_policy_alru_initialize_test01(void **state)
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
|
||||
assert_int_equal(env_atomic_read(&cache->user_parts[part_id].runtime->cleaning.policy.alru.size), 0);
|
||||
assert_int_equal(cache->user_parts[part_id].runtime->cleaning.policy.alru.lru_head, collision_table_entries);
|
||||
assert_int_equal(cache->user_parts[part_id].runtime->cleaning.policy.alru.lru_tail, collision_table_entries);
|
||||
assert_int_equal(env_atomic_read(&cache->user_parts[part_id].clean_pol->policy.alru.size), 0);
|
||||
assert_int_equal(cache->user_parts[part_id].clean_pol->policy.alru.lru_head, collision_table_entries);
|
||||
assert_int_equal(cache->user_parts[part_id].clean_pol->policy.alru.lru_tail, collision_table_entries);
|
||||
|
||||
assert_int_equal(cache->device->runtime_meta->cleaning_thread_access, 0);
|
||||
|
||||
test_free(cache->device->runtime_meta);
|
||||
test_free(cache->device);
|
||||
test_free(cache->user_parts[part_id].runtime);
|
||||
test_free(cache->user_parts[part_id].clean_pol);
|
||||
test_free(cache->user_parts[part_id].part.runtime);
|
||||
test_free(cache);
|
||||
}
|
||||
|
||||
@@ -82,27 +85,29 @@ static void cleaning_policy_alru_initialize_test02(void **state)
|
||||
print_test_description("Check if only appropirate variables are changed");
|
||||
|
||||
cache = test_malloc(sizeof(*cache));
|
||||
cache->user_parts[part_id].runtime = test_malloc(sizeof(struct ocf_user_part_runtime));
|
||||
cache->user_parts[part_id].part.runtime = test_malloc(sizeof(struct ocf_part_runtime));
|
||||
cache->user_parts[part_id].clean_pol = test_malloc(sizeof(*cache->user_parts[part_id].clean_pol));
|
||||
cache->device = test_malloc(sizeof(struct ocf_cache_device));
|
||||
cache->device->runtime_meta = test_malloc(sizeof(struct ocf_superblock_runtime));
|
||||
|
||||
env_atomic_set(&cache->user_parts[part_id].runtime->cleaning.policy.alru.size, 1);
|
||||
cache->user_parts[part_id].runtime->cleaning.policy.alru.lru_head = -collision_table_entries;
|
||||
cache->user_parts[part_id].runtime->cleaning.policy.alru.lru_tail = -collision_table_entries;
|
||||
env_atomic_set(&cache->user_parts[part_id].clean_pol->policy.alru.size, 1);
|
||||
cache->user_parts[part_id].clean_pol->policy.alru.lru_head = -collision_table_entries;
|
||||
cache->user_parts[part_id].clean_pol->policy.alru.lru_tail = -collision_table_entries;
|
||||
|
||||
result = cleaning_policy_alru_initialize_part(cache, cache->user_parts[part_id], 0, 0);
|
||||
result = cleaning_policy_alru_initialize_part(cache, &cache->user_parts[part_id], 0, 0);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
|
||||
assert_int_equal(env_atomic_read(&cache->user_parts[part_id].runtime->cleaning.policy.alru.size), 1);
|
||||
assert_int_equal(cache->user_parts[part_id].runtime->cleaning.policy.alru.lru_head, -collision_table_entries);
|
||||
assert_int_equal(cache->user_parts[part_id].runtime->cleaning.policy.alru.lru_tail, -collision_table_entries);
|
||||
assert_int_equal(env_atomic_read(&cache->user_parts[part_id].clean_pol->policy.alru.size), 1);
|
||||
assert_int_equal(cache->user_parts[part_id].clean_pol->policy.alru.lru_head, -collision_table_entries);
|
||||
assert_int_equal(cache->user_parts[part_id].clean_pol->policy.alru.lru_tail, -collision_table_entries);
|
||||
|
||||
assert_int_equal(cache->device->runtime_meta->cleaning_thread_access, 0);
|
||||
|
||||
test_free(cache->device->runtime_meta);
|
||||
test_free(cache->device);
|
||||
test_free(cache->user_parts[part_id].runtime);
|
||||
test_free(cache->user_parts[part_id].clean_pol);
|
||||
test_free(cache->user_parts[part_id].part.runtime);
|
||||
test_free(cache);
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "../utils/utils_cache_line.h"
|
||||
#include "../ocf_request.h"
|
||||
#include "../utils/utils_cleaner.h"
|
||||
#include "../utils/utils_part.h"
|
||||
#include "../utils/utils_user_part.h"
|
||||
#include "../metadata/metadata.h"
|
||||
#include "../eviction/eviction.h"
|
||||
#include "../promotion/promotion.h"
|
||||
@@ -49,7 +49,7 @@ void __wrap_ocf_req_hash_unlock_wr(struct ocf_request *req)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t __wrap_ocf_part_has_space(struct ocf_request *req)
|
||||
uint32_t __wrap_ocf_user_part_has_space(struct ocf_request *req)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
@@ -71,7 +71,7 @@ void __wrap_ocf_metadata_end_exclusive_access(
|
||||
{
|
||||
}
|
||||
|
||||
bool __wrap_ocf_part_is_enabled(struct ocf_user_part *target_part)
|
||||
bool __wrap_ocf_user_part_is_enabled(struct ocf_user_part *target_part)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
@@ -107,7 +107,7 @@ static void ocf_prepare_clines_miss_test01(void **state)
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
print_test_description("Target part is disabled and empty\n");
|
||||
will_return(__wrap_ocf_part_is_enabled, false);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, false);
|
||||
expect_function_call(__wrap_ocf_req_set_mapping_error);
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), -OCF_ERR_NO_LOCK);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ static void ocf_prepare_clines_miss_test02(void **state)
|
||||
print_test_description("Target part is disabled but has cachelines assigned.\n");
|
||||
print_test_description("\tMark mapping error\n");
|
||||
|
||||
will_return(__wrap_ocf_part_is_enabled, false);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, false);
|
||||
expect_function_call(__wrap_ocf_req_set_mapping_error);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), -OCF_ERR_NO_LOCK);
|
||||
@@ -134,8 +134,8 @@ static void ocf_prepare_clines_miss_test03(void **state)
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("\tEviction is ok and cachelines lock is acquired.\n");
|
||||
|
||||
will_return(__wrap_ocf_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_part_has_space, false);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return_always(__wrap_space_managment_evict_do, LOOKUP_INSERTED);
|
||||
|
||||
@@ -155,8 +155,8 @@ static void ocf_prepare_clines_miss_test04(void **state)
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("\tEviction failed\n");
|
||||
|
||||
will_return(__wrap_ocf_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_part_has_space, false);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
|
||||
@@ -174,12 +174,12 @@ static void ocf_prepare_clines_miss_test06(void **state)
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("Eviction and mapping were ok, but failed to lock cachelines.\n");
|
||||
|
||||
will_return_always(__wrap_ocf_part_has_space, false);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return(__wrap_space_managment_evict_do, LOOKUP_HIT);
|
||||
|
||||
will_return(__wrap_ocf_part_is_enabled, true);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
||||
expect_function_call(__wrap_lock_clines);
|
||||
@@ -198,12 +198,12 @@ static void ocf_prepare_clines_miss_test07(void **state)
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("Eviction and mapping were ok, lock not acquired.\n");
|
||||
|
||||
will_return_always(__wrap_ocf_part_has_space, false);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return(__wrap_space_managment_evict_do, LOOKUP_HIT);
|
||||
|
||||
will_return(__wrap_ocf_part_is_enabled, true);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
||||
@@ -221,8 +221,8 @@ static void ocf_prepare_clines_miss_test08(void **state)
|
||||
print_test_description("Target part is enabled has enough space.\n");
|
||||
print_test_description("\tMapping and cacheline lock are both ok\n");
|
||||
|
||||
will_return(__wrap_ocf_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_part_has_space, true);
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, true);
|
||||
|
||||
expect_function_call(__wrap_ocf_engine_map);
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* <tested_file_path>src/eviction/eviction.c</tested_file_path>
|
||||
* <tested_function>ocf_evict_do</tested_function>
|
||||
* <functions_to_leave>
|
||||
ocf_evict_partitions
|
||||
ocf_evict_user_partitions
|
||||
* </functions_to_leave>
|
||||
*/
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
|
||||
#include "eviction.h"
|
||||
#include "ops.h"
|
||||
#include "../utils/utils_part.h"
|
||||
#include "../utils/utils_user_part.h"
|
||||
|
||||
#include "eviction/eviction.c/eviction_generated_wraps.c"
|
||||
|
||||
struct test_cache
|
||||
{
|
||||
struct ocf_cache cache;
|
||||
struct ocf_user_part_config part[OCF_IO_CLASS_MAX];
|
||||
uint32_t overflow[OCF_IO_CLASS_MAX];
|
||||
uint32_t evictable[OCF_IO_CLASS_MAX];
|
||||
struct ocf_user_part_config part[OCF_USER_IO_CLASS_MAX];
|
||||
uint32_t overflow[OCF_USER_IO_CLASS_MAX];
|
||||
uint32_t evictable[OCF_USER_IO_CLASS_MAX];
|
||||
uint32_t req_unmapped;
|
||||
};
|
||||
|
||||
@@ -37,24 +37,24 @@ bool __wrap_ocf_eviction_can_evict(ocf_cache_t cache)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t __wrap_ocf_part_overflow_size(struct ocf_cache *cache,
|
||||
struct ocf_user_part *part)
|
||||
uint32_t __wrap_ocf_user_part_overflow_size(struct ocf_cache *cache,
|
||||
struct ocf_user_part *user_part)
|
||||
{
|
||||
struct test_cache* tcache = cache;
|
||||
|
||||
return tcache->overflow[part->id];
|
||||
return tcache->overflow[user_part->part.id];
|
||||
}
|
||||
|
||||
uint32_t __wrap_ocf_evict_calculate(ocf_cache_t cache,
|
||||
struct ocf_user_part *part, uint32_t to_evict, bool roundup)
|
||||
struct ocf_user_part *user_part, uint32_t to_evict, bool roundup)
|
||||
{
|
||||
struct test_cache* tcache = cache;
|
||||
|
||||
return min(tcache->evictable[part->id], to_evict);
|
||||
return min(tcache->evictable[user_part->part.id], to_evict);
|
||||
}
|
||||
|
||||
uint32_t __wrap_ocf_eviction_need_space(struct ocf_cache *cache,
|
||||
ocf_queue_t io_queue, struct ocf_user_part *part,
|
||||
ocf_queue_t io_queue, struct ocf_part *part,
|
||||
uint32_t clines)
|
||||
{
|
||||
struct test_cache *tcache = (struct test_cache *)cache;
|
||||
@@ -94,7 +94,7 @@ bool ocf_cache_is_device_attached(ocf_cache_t cache)
|
||||
|
||||
|
||||
/* FIXME: copy-pasted from OCF */
|
||||
int ocf_part_lst_cmp_valid(struct ocf_cache *cache,
|
||||
int ocf_user_part_lst_cmp_valid(struct ocf_cache *cache,
|
||||
struct ocf_lst_entry *e1, struct ocf_lst_entry *e2)
|
||||
{
|
||||
struct ocf_user_part *p1 = container_of(e1, struct ocf_user_part,
|
||||
@@ -102,10 +102,9 @@ int ocf_part_lst_cmp_valid(struct ocf_cache *cache,
|
||||
struct ocf_user_part *p2 = container_of(e2, struct ocf_user_part,
|
||||
lst_valid);
|
||||
size_t p1_size = ocf_cache_is_device_attached(cache) ?
|
||||
p1->runtime->curr_size : 0;
|
||||
p1->part.runtime->curr_size : 0;
|
||||
size_t p2_size = ocf_cache_is_device_attached(cache) ?
|
||||
p2->runtime->curr_size : 0;
|
||||
|
||||
p2->part.runtime->curr_size : 0;
|
||||
int v1 = p1->config->priority;
|
||||
int v2 = p2->config->priority;
|
||||
|
||||
@@ -154,6 +153,7 @@ int ocf_part_lst_cmp_valid(struct ocf_cache *cache,
|
||||
return v2 - v1;
|
||||
}
|
||||
|
||||
|
||||
static struct ocf_lst_entry *_list_getter(
|
||||
struct ocf_cache *cache, ocf_cache_line_t idx)
|
||||
{
|
||||
@@ -166,18 +166,18 @@ static void init_part_list(struct test_cache *tcache)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
tcache->cache.user_parts[i].id = i;
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
tcache->cache.user_parts[i].part.id = i;
|
||||
tcache->cache.user_parts[i].config = &tcache->part[i];
|
||||
tcache->cache.user_parts[i].config->priority = i+1;
|
||||
tcache->cache.user_parts[i].config->flags.eviction = 1;
|
||||
}
|
||||
|
||||
ocf_lst_init((ocf_cache_t)tcache, &tcache->cache.lst_part, OCF_IO_CLASS_MAX,
|
||||
_list_getter, ocf_part_lst_cmp_valid);
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
ocf_lst_init_entry(&tcache->cache.lst_part, &tcache->cache.user_parts[i].lst_valid);
|
||||
ocf_lst_add_tail(&tcache->cache.lst_part, i);
|
||||
ocf_lst_init((ocf_cache_t)tcache, &tcache->cache.user_part_list, OCF_USER_IO_CLASS_MAX,
|
||||
_list_getter, ocf_user_part_lst_cmp_valid);
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
ocf_lst_init_entry(&tcache->cache.user_part_list, &tcache->cache.user_parts[i].lst_valid);
|
||||
ocf_lst_add_tail(&tcache->cache.user_part_list, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ uint32_t __wrap_ocf_engine_unmapped_count(struct ocf_request *req)
|
||||
|
||||
#define _expect_evict_call(tcache, part_id, req_count, ret_count) \
|
||||
do { \
|
||||
expect_value(__wrap_ocf_eviction_need_space, part, &tcache.cache.user_parts[part_id]); \
|
||||
expect_value(__wrap_ocf_eviction_need_space, part, &tcache.cache.user_parts[part_id].part); \
|
||||
expect_value(__wrap_ocf_eviction_need_space, clines, req_count); \
|
||||
expect_function_call(__wrap_ocf_eviction_need_space); \
|
||||
will_return(__wrap_ocf_eviction_need_space, ret_count); \
|
||||
|
@@ -199,7 +199,7 @@ unsigned current_case;
|
||||
|
||||
struct ocf_lru_list list;
|
||||
|
||||
struct ocf_lru_list *__wrap_evp_lru_get_list(struct ocf_user_part *part,
|
||||
struct ocf_lru_list *__wrap_evp_lru_get_list(struct ocf_user_part *user_part,
|
||||
uint32_t evp, bool clean)
|
||||
{
|
||||
unsigned i = 0;
|
||||
|
@@ -30,7 +30,7 @@ ocf_mngt_cache_mode_has_lazy_write
|
||||
#include "../ocf_queue_priv.h"
|
||||
#include "../metadata/metadata.h"
|
||||
#include "../engine/cache_engine.h"
|
||||
#include "../utils/utils_part.h"
|
||||
#include "../utils/utils_user_part.h"
|
||||
#include "../utils/utils_cache_line.h"
|
||||
#include "../utils/utils_io.h"
|
||||
#include "../utils/utils_cache_line.h"
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include "../ocf_queue_priv.h"
|
||||
#include "../metadata/metadata.h"
|
||||
#include "../engine/cache_engine.h"
|
||||
#include "../utils/utils_part.h"
|
||||
#include "../utils/utils_user_part.h"
|
||||
#include "../utils/utils_cache_line.h"
|
||||
#include "../utils/utils_io.h"
|
||||
#include "../utils/utils_cache_line.h"
|
||||
|
@@ -31,14 +31,14 @@
|
||||
#include "../ocf_priv.h"
|
||||
#include "../metadata/metadata.h"
|
||||
#include "../engine/cache_engine.h"
|
||||
#include "../utils/utils_part.h"
|
||||
#include "../utils/utils_user_part.h"
|
||||
#include "../eviction/ops.h"
|
||||
#include "ocf_env.h"
|
||||
|
||||
#include "mngt/ocf_mngt_io_class.c/ocf_mngt_io_class_generated_wraps.c"
|
||||
|
||||
/* Functions mocked for testing purposes */
|
||||
bool __wrap_ocf_part_is_added(struct ocf_user_part *part)
|
||||
bool __wrap_ocf_user_part_is_added(struct ocf_user_part *user_part)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
@@ -51,20 +51,20 @@ int __wrap__ocf_mngt_set_partition_size(struct ocf_cache *cache,
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_ocf_part_set_prio(struct ocf_cache *cache,
|
||||
struct ocf_user_part *part, int16_t prio)
|
||||
void __wrap_ocf_user_part_set_prio(struct ocf_cache *cache,
|
||||
struct ocf_user_part *user_part, int16_t prio)
|
||||
{
|
||||
function_called();
|
||||
}
|
||||
|
||||
bool __wrap_ocf_part_is_valid(struct ocf_user_part *part)
|
||||
bool __wrap_ocf_user_part_is_valid(struct ocf_user_part *user_part)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
}
|
||||
|
||||
|
||||
void __wrap_ocf_part_set_valid(struct ocf_cache *cache, ocf_part_id_t id,
|
||||
void __wrap_ocf_user_part_set_valid(struct ocf_cache *cache, ocf_part_id_t id,
|
||||
bool valid)
|
||||
{
|
||||
function_called();
|
||||
@@ -79,7 +79,7 @@ int __wrap__ocf_mngt_io_class_validate_cfg(ocf_cache_t cache,
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_ocf_part_sort(struct ocf_cache *cache)
|
||||
void __wrap_ocf_user_part_sort(struct ocf_cache *cache)
|
||||
{
|
||||
function_called();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ static inline void setup_valid_config(struct ocf_mngt_io_class_config *cfg,
|
||||
bool remove)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
cfg[i].class_id = i;
|
||||
cfg[i].name = remove ? NULL : i == 0 ? "unclassified" :"test_io_class_name" ;
|
||||
cfg[i].prio = i;
|
||||
@@ -112,7 +112,7 @@ static void ocf_mngt_io_classes_configure_test03(void **state)
|
||||
|
||||
cache = test_malloc(sizeof(*cache));
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
cache->user_parts[i].config =
|
||||
test_malloc(sizeof(struct ocf_user_part_config));
|
||||
}
|
||||
@@ -120,30 +120,30 @@ static void ocf_mngt_io_classes_configure_test03(void **state)
|
||||
|
||||
setup_valid_config(cfg.config, true);
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
expect_function_call(__wrap__ocf_mngt_io_class_validate_cfg);
|
||||
will_return(__wrap__ocf_mngt_io_class_validate_cfg, 0);
|
||||
}
|
||||
|
||||
/* Removing default io_class is not allowed */
|
||||
for (i = 1; i < OCF_IO_CLASS_MAX; i++) {
|
||||
expect_function_call(__wrap_ocf_part_is_valid);
|
||||
will_return(__wrap_ocf_part_is_valid, 1);
|
||||
for (i = 1; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
expect_function_call(__wrap_ocf_user_part_is_valid);
|
||||
will_return(__wrap_ocf_user_part_is_valid, 1);
|
||||
|
||||
expect_function_call(__wrap_ocf_part_set_valid);
|
||||
expect_function_call(__wrap_ocf_user_part_set_valid);
|
||||
/* Test assumes default partition has id equal 0 */
|
||||
expect_in_range(__wrap_ocf_part_set_valid, id, OCF_IO_CLASS_ID_MIN + 1,
|
||||
expect_in_range(__wrap_ocf_user_part_set_valid, id, OCF_IO_CLASS_ID_MIN + 1,
|
||||
OCF_IO_CLASS_ID_MAX);
|
||||
expect_value(__wrap_ocf_part_set_valid, valid, false);
|
||||
expect_value(__wrap_ocf_user_part_set_valid, valid, false);
|
||||
}
|
||||
|
||||
expect_function_call(__wrap_ocf_part_sort);
|
||||
expect_function_call(__wrap_ocf_user_part_sort);
|
||||
|
||||
result = ocf_mngt_cache_io_classes_configure(cache, &cfg);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++)
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++)
|
||||
test_free(cache->user_parts[i].config);
|
||||
|
||||
test_free(cache);
|
||||
@@ -157,7 +157,7 @@ static void ocf_mngt_io_classes_configure_test02(void **state)
|
||||
|
||||
cache = test_malloc(sizeof(*cache));
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
cache->user_parts[i].config =
|
||||
test_malloc(sizeof(struct ocf_user_part_config));
|
||||
}
|
||||
@@ -169,46 +169,46 @@ static void ocf_mngt_io_classes_configure_test02(void **state)
|
||||
|
||||
print_test_description("Configure all possible io classes");
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
expect_function_call(__wrap__ocf_mngt_io_class_validate_cfg);
|
||||
will_return(__wrap__ocf_mngt_io_class_validate_cfg, 0);
|
||||
}
|
||||
|
||||
/* Configure default io_class */
|
||||
expect_function_call(__wrap_ocf_part_is_added);
|
||||
will_return(__wrap_ocf_part_is_added, 1);
|
||||
expect_function_call(__wrap_ocf_user_part_is_added);
|
||||
will_return(__wrap_ocf_user_part_is_added, 1);
|
||||
|
||||
expect_function_call(__wrap__ocf_mngt_set_partition_size);
|
||||
will_return(__wrap__ocf_mngt_set_partition_size, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_part_set_prio);
|
||||
expect_function_call(__wrap_ocf_user_part_set_prio);
|
||||
|
||||
/* Configure custom io_classes */
|
||||
for (i = 1; i < OCF_IO_CLASS_MAX; i++) {
|
||||
expect_function_call(__wrap_ocf_part_is_added);
|
||||
will_return(__wrap_ocf_part_is_added, 1);
|
||||
for (i = 1; i < OCF_USER_IO_CLASS_MAX; i++) {
|
||||
expect_function_call(__wrap_ocf_user_part_is_added);
|
||||
will_return(__wrap_ocf_user_part_is_added, 1);
|
||||
|
||||
expect_function_call(__wrap__ocf_mngt_set_partition_size);
|
||||
will_return(__wrap__ocf_mngt_set_partition_size, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_part_is_valid);
|
||||
will_return(__wrap_ocf_part_is_valid, 0);
|
||||
expect_function_call(__wrap_ocf_user_part_is_valid);
|
||||
will_return(__wrap_ocf_user_part_is_valid, 0);
|
||||
|
||||
expect_function_call(__wrap_ocf_part_set_valid);
|
||||
expect_in_range(__wrap_ocf_part_set_valid, id, OCF_IO_CLASS_ID_MIN,
|
||||
expect_function_call(__wrap_ocf_user_part_set_valid);
|
||||
expect_in_range(__wrap_ocf_user_part_set_valid, id, OCF_IO_CLASS_ID_MIN,
|
||||
OCF_IO_CLASS_ID_MAX);
|
||||
expect_value(__wrap_ocf_part_set_valid, valid, true);
|
||||
expect_value(__wrap_ocf_user_part_set_valid, valid, true);
|
||||
|
||||
expect_function_call(__wrap_ocf_part_set_prio);
|
||||
expect_function_call(__wrap_ocf_user_part_set_prio);
|
||||
}
|
||||
|
||||
expect_function_call(__wrap_ocf_part_sort);
|
||||
expect_function_call(__wrap_ocf_user_part_sort);
|
||||
|
||||
result = ocf_mngt_cache_io_classes_configure(cache, &cfg);
|
||||
|
||||
assert_int_equal(result, 0);
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++)
|
||||
for (i = 0; i < OCF_USER_IO_CLASS_MAX; i++)
|
||||
test_free(cache->user_parts[i].config);
|
||||
|
||||
test_free(cache);
|
||||
@@ -217,7 +217,7 @@ static void ocf_mngt_io_classes_configure_test02(void **state)
|
||||
static void ocf_mngt_io_classes_configure_test01(void **state)
|
||||
{
|
||||
struct ocf_cache *cache;
|
||||
struct ocf_mngt_io_classes_config cfg[OCF_IO_CLASS_MAX];
|
||||
struct ocf_mngt_io_classes_config cfg[OCF_USER_IO_CLASS_MAX];
|
||||
int error_code = -OCF_ERR_INVAL;
|
||||
int result;
|
||||
|
||||
|
Reference in New Issue
Block a user