Refactor resolving fast path

Signed-off-by: Avi Halaf <avi.halaf@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
Avi Halaf 2023-08-30 13:26:38 +03:00 committed by Michal Mielewczyk
parent d24e7bac5d
commit bd06b1c9b8

View File

@ -218,41 +218,48 @@ static void ocf_req_complete(struct ocf_request *req, int error)
ocf_io_put(&req->ioi.io); ocf_io_put(&req->ioi.io);
} }
static int ocf_core_submit_io_fast(struct ocf_io *io, struct ocf_request *req, static inline ocf_req_cache_mode_t _ocf_core_req_resolve_fast_mode(
ocf_core_t core, ocf_cache_t cache) ocf_cache_t cache, struct ocf_request *req)
{ {
ocf_req_cache_mode_t original_cache_mode;
int fast;
if (req->d2c) {
return -OCF_ERR_IO;
}
original_cache_mode = req->cache_mode;
switch (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_wb:
case ocf_req_cache_mode_wo: case ocf_req_cache_mode_wo:
req->cache_mode = ocf_req_cache_mode_fast; return ocf_req_cache_mode_fast;
break;
default: default:
if (cache->use_submit_io_fast)
break; break;
if (io->dir == OCF_WRITE)
return -OCF_ERR_IO;
req->cache_mode = ocf_req_cache_mode_fast;
} }
fast = ocf_engine_hndl_fast_req(req); if (!cache->use_submit_io_fast)
if (fast != OCF_FAST_PATH_NO) return ocf_req_cache_mode_max;
return 0;
req->cache_mode = original_cache_mode; return ocf_req_cache_mode_fast;
return -OCF_ERR_IO; }
static int ocf_core_submit_io_fast(struct ocf_io *io, struct ocf_request *req,
ocf_cache_t cache)
{
ocf_req_cache_mode_t original_mode, resolved_mode;
int ret;
if (req->d2c) {
return OCF_FAST_PATH_NO;
}
if (req->cache_mode == ocf_req_cache_mode_pt)
return OCF_FAST_PATH_NO;
resolved_mode = _ocf_core_req_resolve_fast_mode(cache, req);
if (resolved_mode == ocf_req_cache_mode_max)
return OCF_FAST_PATH_NO;
original_mode = req->cache_mode;
req->cache_mode = resolved_mode;
ret = ocf_engine_hndl_fast_req(req);
if (ret == OCF_FAST_PATH_NO)
req->cache_mode = original_mode;
return ret;
} }
static void ocf_core_volume_submit_io(struct ocf_io *io) static void ocf_core_volume_submit_io(struct ocf_io *io)
@ -297,7 +304,7 @@ static void ocf_core_volume_submit_io(struct ocf_io *io)
/* Prevent race condition */ /* Prevent race condition */
ocf_req_get(req); 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_core_seq_cutoff_update(core, req);
ocf_req_put(req); ocf_req_put(req);
return; return;