]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/ocf/src/engine/engine_fast.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / ocf / src / engine / engine_fast.c
index 2fd350be952a87b56e0cd005dd1b1c9d014f70c5..8cfe96c43c71858571afb22cd961f726fb01719a 100644 (file)
@@ -9,7 +9,7 @@
 #include "engine_common.h"
 #include "engine_pt.h"
 #include "engine_wb.h"
-#include "../utils/utils_req.h"
+#include "../ocf_request.h"
 #include "../utils/utils_part.h"
 #include "../utils/utils_io.h"
 #include "../concurrency/ocf_concurrency.h"
@@ -43,8 +43,7 @@ static void _ocf_read_fast_complete(struct ocf_request *req, int error)
        if (req->error) {
                OCF_DEBUG_RQ(req, "ERROR");
 
-               env_atomic_inc(&req->cache->core[req->core_id].counters->
-                               cache_errors.read);
+               ocf_core_stats_cache_error_update(req->core, OCF_READ);
                ocf_engine_push_req_front_pt(req);
        } else {
                ocf_req_unlock(req);
@@ -59,8 +58,6 @@ static void _ocf_read_fast_complete(struct ocf_request *req, int error)
 
 static int _ocf_read_fast_do(struct ocf_request *req)
 {
-       struct ocf_cache *cache = req->cache;
-
        if (ocf_engine_is_miss(req)) {
                /* It seams that after resume, now request is MISS, do PT */
                OCF_DEBUG_RQ(req, "Switching to read PT");
@@ -75,24 +72,24 @@ static int _ocf_read_fast_do(struct ocf_request *req)
        if (req->info.re_part) {
                OCF_DEBUG_RQ(req, "Re-Part");
 
-               OCF_METADATA_LOCK_WR();
+               ocf_req_hash_lock_wr(req);
 
                /* Probably some cache lines are assigned into wrong
                 * partition. Need to move it to new one
                 */
                ocf_part_move(req);
 
-               OCF_METADATA_UNLOCK_WR();
+               ocf_req_hash_unlock_wr(req);
        }
 
        /* Submit IO */
        OCF_DEBUG_RQ(req, "Submit");
        env_atomic_set(&req->req_remaining, ocf_engine_io_count(req));
-       ocf_submit_cache_reqs(req->cache, req->map, req, OCF_READ,
+       ocf_submit_cache_reqs(req->cache, req, OCF_READ, 0, req->byte_length,
                ocf_engine_io_count(req), _ocf_read_fast_complete);
 
 
-       /* Updata statistics */
+       /* Update statistics */
        ocf_engine_update_request_stats(req);
        ocf_engine_update_block_stats(req);
 
@@ -103,37 +100,36 @@ static int _ocf_read_fast_do(struct ocf_request *req)
 }
 
 static const struct ocf_io_if _io_if_read_fast_resume = {
-               .read = _ocf_read_fast_do,
-               .write = _ocf_read_fast_do,
+       .read = _ocf_read_fast_do,
+       .write = _ocf_read_fast_do,
 };
 
 int ocf_read_fast(struct ocf_request *req)
 {
        bool hit;
        int lock = OCF_LOCK_NOT_ACQUIRED;
-       struct ocf_cache *cache = req->cache;
 
        /* Get OCF request - increase reference counter */
        ocf_req_get(req);
 
-       /* Set resume call backs */
-       req->resume = ocf_engine_on_resume;
+       /* Set resume io_if */
        req->io_if = &_io_if_read_fast_resume;
 
        /*- Metadata RD access -----------------------------------------------*/
 
-       OCF_METADATA_LOCK_RD();
+       ocf_req_hash(req);
+       ocf_req_hash_lock_rd(req);
 
        /* Traverse request to cache if there is hit */
        ocf_engine_traverse(req);
 
        hit = ocf_engine_is_hit(req);
        if (hit) {
-               ocf_io_start(req->io);
-               lock = ocf_req_trylock_rd(req);
+               ocf_io_start(&req->ioi.io);
+               lock = ocf_req_async_lock_rd(req, ocf_engine_on_resume);
        }
 
-       OCF_METADATA_UNLOCK_RD();
+       ocf_req_hash_unlock_rd(req);
 
        if (hit) {
                OCF_DEBUG_RQ(req, "Fast path success");
@@ -173,37 +169,36 @@ int ocf_read_fast(struct ocf_request *req)
  */
 
 static const struct ocf_io_if _io_if_write_fast_resume = {
-               .read = ocf_write_wb_do,
-               .write = ocf_write_wb_do,
+       .read = ocf_write_wb_do,
+       .write = ocf_write_wb_do,
 };
 
 int ocf_write_fast(struct ocf_request *req)
 {
        bool mapped;
        int lock = OCF_LOCK_NOT_ACQUIRED;
-       struct ocf_cache *cache = req->cache;
 
        /* Get OCF request - increase reference counter */
        ocf_req_get(req);
 
-       /* Set resume call backs */
-       req->resume = ocf_engine_on_resume;
+       /* Set resume io_if */
        req->io_if = &_io_if_write_fast_resume;
 
        /*- Metadata RD access -----------------------------------------------*/
 
-       OCF_METADATA_LOCK_RD();
+       ocf_req_hash(req);
+       ocf_req_hash_lock_rd(req);
 
        /* Traverse request to cache if there is hit */
        ocf_engine_traverse(req);
 
        mapped = ocf_engine_is_mapped(req);
        if (mapped) {
-               ocf_io_start(req->io);
-               lock = ocf_req_trylock_wr(req);
+               ocf_io_start(&req->ioi.io);
+               lock = ocf_req_async_lock_wr(req, ocf_engine_on_resume);
        }
 
-       OCF_METADATA_UNLOCK_RD();
+       ocf_req_hash_unlock_rd(req);
 
        if (mapped) {
                if (lock >= 0) {