diff --git a/src/engine/engine_common.c b/src/engine/engine_common.c
index 6eb5083..0af7597 100644
--- a/src/engine/engine_common.c
+++ b/src/engine/engine_common.c
@@ -425,61 +425,6 @@ static int lock_clines(struct ocf_request *req,
}
}
-static inline int ocf_prepare_clines_hit(struct ocf_request *req,
- const struct ocf_engine_callbacks *engine_cbs)
-{
- int lock_status = -OCF_ERR_NO_LOCK;
- struct ocf_metadata_lock *metadata_lock = &req->cache->metadata.lock;
- uint32_t clines_to_evict;
- int res;
-
- /* Cachelines are mapped in correct partition */
- if (ocf_part_is_enabled(&req->cache->user_parts[req->part_id]) &&
- !ocf_engine_needs_repart(req)) {
- lock_status = lock_clines(req, engine_cbs);
- ocf_req_hash_unlock_rd(req);
- return lock_status;
- }
-
- res = ocf_part_check_space(req, &clines_to_evict);
-
- if (res == OCF_PART_HAS_SPACE)
- lock_status = lock_clines(req, engine_cbs);
-
- /* Since target part is empty and disabled, request should be submited in
- * pass-through */
- if (res == OCF_PART_IS_DISABLED)
- ocf_req_set_mapping_error(req);
-
- ocf_req_hash_unlock_rd(req);
-
- if (res != OCF_PART_IS_FULL)
- return lock_status;
-
- ocf_metadata_start_exclusive_access(metadata_lock);
- ocf_part_check_space(req, &clines_to_evict);
-
- if (space_managment_evict_do(req->cache, req, clines_to_evict) ==
- LOOKUP_MISS) {
- ocf_req_set_mapping_error(req);
- goto unlock;
- }
-
- if (!ocf_part_is_enabled(&req->cache->user_parts[req->part_id])) {
- /* Target part is disabled but had some cachelines assigned. Submit
- * request in pass-through after eviction has been made */
- ocf_req_set_mapping_error(req);
- goto unlock;
- }
-
- lock_status = lock_clines(req, engine_cbs);
-
-unlock:
- ocf_metadata_end_exclusive_access(metadata_lock);
-
- return lock_status;
-}
-
static inline int ocf_prepare_clines_miss(struct ocf_request *req,
const struct ocf_engine_callbacks *engine_cbs)
{
@@ -571,8 +516,11 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
ocf_engine_traverse(req);
mapped = ocf_engine_is_mapped(req);
- if (mapped)
- return ocf_prepare_clines_hit(req, engine_cbs);
+ if (mapped) {
+ lock = lock_clines(req, engine_cbs);
+ ocf_req_hash_unlock_rd(req);
+ return lock;
+ }
/* check if request should promote cachelines */
promote = ocf_promotion_req_should_promote(
diff --git a/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c b/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c
deleted file mode 100644
index d66bc8a..0000000
--- a/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * src/engine/engine_common.c
- * ocf_prepare_clines_hit
- *
- * INSERT HERE LIST OF FUNCTIONS YOU WANT TO LEAVE
- * ONE FUNCTION PER LINE
- *
- */
-
-#undef static
-
-#undef inline
-
-
-#include
-#include
-#include
-#include
-#include "print_desc.h"
-
-#include "ocf/ocf.h"
-#include "../ocf_priv.h"
-#include "../ocf_cache_priv.h"
-#include "../ocf_queue_priv.h"
-#include "../ocf_freelist.h"
-#include "engine_common.h"
-#include "engine_debug.h"
-#include "../utils/utils_cache_line.h"
-#include "../ocf_request.h"
-#include "../utils/utils_cleaner.h"
-#include "../utils/utils_part.h"
-#include "../metadata/metadata.h"
-#include "../eviction/eviction.h"
-#include "../promotion/promotion.h"
-#include "../concurrency/ocf_concurrency.h"
-
-#include "engine/engine_common.c/prepare_clines_miss_generated_wraps.c"
-
-void __wrap_ocf_req_hash_unlock_rd(struct ocf_request *req)
-{
-}
-
-uint32_t __wrap_ocf_part_check_space(struct ocf_request *req,
- uint32_t *to_evict)
-{
- return mock();
-}
-
-int __wrap_lock_clines(struct ocf_request *req,
- const struct ocf_engine_callbacks *engine_cbs)
-{
- function_called();
- return mock();
-}
-
-void __wrap_ocf_metadata_start_exclusive_access(
- struct ocf_metadata_lock *metadata_lock)
-{
-}
-
-void __wrap_ocf_metadata_end_exclusive_access(
- struct ocf_metadata_lock *metadata_lock)
-{
-}
-
-int __wrap_space_managment_evict_do(struct ocf_cache *cache,
- struct ocf_request *req, uint32_t evict_cline_no)
-{
- return mock();
-}
-
-bool __wrap_ocf_part_is_enabled(struct ocf_user_part *target_part)
-{
- return mock();
-}
-
-bool __wrap_ocf_engine_needs_repart(struct ocf_request *req)
-{
- return mock();
-}
-
-void __wrap_ocf_req_set_mapping_error(struct ocf_request *req)
-{
- function_called();
-}
-
-static void ocf_prepare_clines_hit_test01(void **state)
-{
- struct ocf_request req = {};
- print_test_description("Request is hit and part is enabled\n");
- will_return(__wrap_ocf_part_is_enabled, true);
- will_return(__wrap_ocf_engine_needs_repart, false);
-
- will_return(__wrap_lock_clines, 0);
- expect_function_call(__wrap_lock_clines);
-
- assert_int_equal(ocf_prepare_clines_hit(&req, NULL), 0);
-}
-
-static void ocf_prepare_clines_hit_test02(void **state)
-{
- struct ocf_request req = {};
- print_test_description("Request is hit but part is disabled - tigger eviction\n");
- will_return(__wrap_ocf_part_is_enabled, false);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_DISABLED);
-
- expect_function_call(__wrap_ocf_req_set_mapping_error);
-
- assert_int_equal(ocf_prepare_clines_hit(&req, NULL), -OCF_ERR_NO_LOCK);
-}
-
-static void ocf_prepare_clines_hit_test03(void **state)
-{
- struct ocf_request req = {};
- print_test_description("Request needs repart, part has enough of a free space\n");
- will_return(__wrap_ocf_part_is_enabled, true);
- will_return(__wrap_ocf_engine_needs_repart, true);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_HAS_SPACE);
-
- expect_function_call(__wrap_lock_clines);
- will_return(__wrap_lock_clines, 0);
-
- assert_int_equal(ocf_prepare_clines_hit(&req, NULL), 0);
-}
-
-static void ocf_prepare_clines_hit_test04(void **state)
-{
- struct ocf_request req = {};
- print_test_description("Request needs repart, eviction fails\n");
- will_return(__wrap_ocf_part_is_enabled, true);
- will_return(__wrap_ocf_engine_needs_repart, true);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_FULL);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_FULL);
- will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
- expect_function_call(__wrap_ocf_req_set_mapping_error);
-
- assert_int_equal(ocf_prepare_clines_hit(&req, NULL), -OCF_ERR_NO_LOCK);
-}
-
-static void ocf_prepare_clines_hit_test05(void **state)
-{
- struct ocf_request req = {};
- print_test_description("Request needs repart, eviction passed, no lock\n");
-
- will_return(__wrap_ocf_part_is_enabled, true);
- will_return(__wrap_ocf_engine_needs_repart, true);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_FULL);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_FULL);
- will_return(__wrap_space_managment_evict_do, LOOKUP_HIT);
-
- expect_function_call(__wrap_lock_clines);
- will_return(__wrap_lock_clines, OCF_ERR_NO_LOCK);
-
- will_return(__wrap_ocf_part_is_enabled, true);
-
- assert_int_equal(ocf_prepare_clines_hit(&req, NULL), OCF_ERR_NO_LOCK);
-}
-
-static void ocf_prepare_clines_hit_test06(void **state)
-{
- struct ocf_request req = {};
- print_test_description("Partition is disabled, but has some cachelines assigned.\n");
- print_test_description("Trigger eviction and but don't lock cachelines\n");
-
- will_return(__wrap_ocf_part_is_enabled, false);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_FULL);
-
- will_return(__wrap_ocf_part_check_space, OCF_PART_IS_FULL);
- will_return(__wrap_space_managment_evict_do, LOOKUP_HIT);
-
- will_return(__wrap_ocf_part_is_enabled, false);
- expect_function_call(__wrap_ocf_req_set_mapping_error);
-
- assert_int_equal(ocf_prepare_clines_hit(&req, NULL), -OCF_ERR_NO_LOCK);
-}
-
-int main(void)
-{
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(ocf_prepare_clines_hit_test01),
- cmocka_unit_test(ocf_prepare_clines_hit_test02),
- cmocka_unit_test(ocf_prepare_clines_hit_test03),
- cmocka_unit_test(ocf_prepare_clines_hit_test04),
- cmocka_unit_test(ocf_prepare_clines_hit_test05),
- cmocka_unit_test(ocf_prepare_clines_hit_test06)
- };
-
- print_message("Unit test for ocf_prepare_clines_hit\n");
-
- return cmocka_run_group_tests(tests, NULL, NULL);
-}