]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/ocf/src/engine/engine_wi.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / ocf / src / engine / engine_wi.c
index 2a0193da60fe09239cc0f90cfb350382f0329f83..ff947e43b476d2bada0bfc2c75bb830b216f3607 100644 (file)
@@ -8,7 +8,7 @@
 #include "engine_wi.h"
 #include "engine_common.h"
 #include "../concurrency/ocf_concurrency.h"
-#include "../utils/utils_req.h"
+#include "../ocf_request.h"
 #include "../utils/utils_cache_line.h"
 #include "../utils/utils_io.h"
 #include "../metadata/metadata.h"
@@ -26,8 +26,7 @@ static const struct ocf_io_if _io_if_wi_flush_metadata = {
 static void _ocf_write_wi_io_flush_metadata(struct ocf_request *req, int error)
 {
        if (error) {
-               env_atomic_inc(&req->cache->core[req->core_id].counters->
-                               cache_errors.write);
+               ocf_core_stats_cache_error_update(req->core, OCF_WRITE);
                req->error |= error;
        }
 
@@ -53,12 +52,12 @@ static int ocf_write_wi_update_and_flush_metadata(struct ocf_request *req)
        if (ocf_engine_mapped_count(req)) {
                /* There are mapped cache line, need to remove them */
 
-               OCF_METADATA_LOCK_WR(); /*- Metadata WR access ---------------*/
+               ocf_req_hash_lock_wr(req); /*- Metadata WR access ---------------*/
 
                /* Remove mapped cache lines from metadata */
                ocf_purge_map_info(req);
 
-               OCF_METADATA_UNLOCK_WR(); /*- END Metadata WR access ---------*/
+               ocf_req_hash_unlock_wr(req); /*- END Metadata WR access ---------*/
 
                if (req->info.flush_metadata) {
                        /* Request was dirty and need to flush metadata */
@@ -78,8 +77,7 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
        if (error) {
                req->error = error;
                req->info.core_error = 1;
-               env_atomic_inc(&req->cache->core[req->core_id].counters->
-                               core_errors.write);
+               ocf_core_stats_core_error_update(req->core, OCF_WRITE);
        }
 
        if (env_atomic_dec_return(&req->req_remaining))
@@ -101,8 +99,6 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
 
 static int _ocf_write_wi_do(struct ocf_request *req)
 {
-       struct ocf_cache *cache = req->cache;
-
        /* Get OCF request - increase reference counter */
        ocf_req_get(req);
 
@@ -111,13 +107,13 @@ static int _ocf_write_wi_do(struct ocf_request *req)
        OCF_DEBUG_RQ(req, "Submit");
 
        /* Submit write IO to the core */
-       ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
+       ocf_submit_volume_req(&req->core->volume, req,
                           _ocf_write_wi_core_complete);
 
        /* Update statistics */
        ocf_engine_update_block_stats(req);
-       env_atomic64_inc(&cache->core[req->core_id].counters->
-                       part_counters[req->part_id].write_reqs.pass_through);
+       ocf_core_stats_request_pt_update(req->core, req->part_id, req->rw,
+                       req->info.hit_no, req->core_line_count);
 
        /* Put OCF request - decrease reference counter */
        ocf_req_put(req);
@@ -139,32 +135,31 @@ static const struct ocf_io_if _io_if_wi_resume = {
 int ocf_write_wi(struct ocf_request *req)
 {
        int lock = OCF_LOCK_NOT_ACQUIRED;
-       struct ocf_cache *cache = req->cache;
 
        OCF_DEBUG_TRACE(req->cache);
 
-       ocf_io_start(req->io);
+       ocf_io_start(&req->ioi.io);
 
        /* Get OCF request - increase reference counter */
        ocf_req_get(req);
 
-       /* Set resume call backs */
-       req->resume = _ocf_write_wi_on_resume;
+       /* Set resume io_if */
        req->io_if = &_io_if_wi_resume;
 
-       OCF_METADATA_LOCK_RD(); /*- Metadata READ access, No eviction --------*/
+       ocf_req_hash(req);
+       ocf_req_hash_lock_rd(req); /*- Metadata READ access, No eviction --------*/
 
        /* Travers to check if request is mapped fully */
        ocf_engine_traverse(req);
 
        if (ocf_engine_mapped_count(req)) {
                /* Some cache line are mapped, lock request for WRITE access */
-               lock = ocf_req_trylock_wr(req);
+               lock = ocf_req_async_lock_wr(req, _ocf_write_wi_on_resume);
        } else {
                lock = OCF_LOCK_ACQUIRED;
        }
 
-       OCF_METADATA_UNLOCK_RD(); /*- END Metadata READ access----------------*/
+       ocf_req_hash_unlock_rd(req); /*- END Metadata READ access----------------*/
 
        if (lock >= 0) {
                if (lock == OCF_LOCK_ACQUIRED) {