Skip to content

Commit

Permalink
Refactor resolving fast path
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Halaf <[email protected]>
Signed-off-by: Robert Baldyga <[email protected]>
Signed-off-by: Michal Mielewczyk <[email protected]>
  • Loading branch information
Avi Halaf authored and mmichal10 committed Sep 10, 2024
1 parent d24e7ba commit bd06b1c
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions src/ocf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,41 +218,48 @@ static void ocf_req_complete(struct ocf_request *req, int error)
ocf_io_put(&req->ioi.io);
}

static inline ocf_req_cache_mode_t _ocf_core_req_resolve_fast_mode(
ocf_cache_t cache, struct ocf_request *req)
{
switch (req->cache_mode) {
case ocf_req_cache_mode_wb:
case ocf_req_cache_mode_wo:
return ocf_req_cache_mode_fast;
default:
break;
}

if (!cache->use_submit_io_fast)
return ocf_req_cache_mode_max;

return ocf_req_cache_mode_fast;
}

static int ocf_core_submit_io_fast(struct ocf_io *io, struct ocf_request *req,
ocf_core_t core, ocf_cache_t cache)
ocf_cache_t cache)
{
ocf_req_cache_mode_t original_cache_mode;
int fast;
ocf_req_cache_mode_t original_mode, resolved_mode;
int ret;

if (req->d2c) {
return -OCF_ERR_IO;
return OCF_FAST_PATH_NO;
}

original_cache_mode = req->cache_mode;

switch (req->cache_mode) {
case ocf_req_cache_mode_pt:
return -OCF_ERR_IO;
case ocf_req_cache_mode_wb:
case ocf_req_cache_mode_wo:
req->cache_mode = ocf_req_cache_mode_fast;
break;
default:
if (cache->use_submit_io_fast)
break;
if (req->cache_mode == ocf_req_cache_mode_pt)
return OCF_FAST_PATH_NO;

if (io->dir == OCF_WRITE)
return -OCF_ERR_IO;
resolved_mode = _ocf_core_req_resolve_fast_mode(cache, req);
if (resolved_mode == ocf_req_cache_mode_max)
return OCF_FAST_PATH_NO;

req->cache_mode = ocf_req_cache_mode_fast;
}
original_mode = req->cache_mode;
req->cache_mode = resolved_mode;

fast = ocf_engine_hndl_fast_req(req);
if (fast != OCF_FAST_PATH_NO)
return 0;
ret = ocf_engine_hndl_fast_req(req);
if (ret == OCF_FAST_PATH_NO)
req->cache_mode = original_mode;

req->cache_mode = original_cache_mode;
return -OCF_ERR_IO;
return ret;
}

static void ocf_core_volume_submit_io(struct ocf_io *io)
Expand Down Expand Up @@ -297,7 +304,7 @@ static void ocf_core_volume_submit_io(struct ocf_io *io)
/* Prevent race condition */
ocf_req_get(req);

if (!ocf_core_submit_io_fast(io, req, core, cache)) {
if (ocf_core_submit_io_fast(io, req, cache) == OCF_FAST_PATH_YES) {
ocf_core_seq_cutoff_update(core, req);
ocf_req_put(req);
return;
Expand Down

0 comments on commit bd06b1c

Please sign in to comment.