Merge pull request #750 from robertbaldyga/remove-req-io-if

Get rid of req->io_if
This commit is contained in:
Robert Baldyga
2022-09-08 22:59:57 +02:00
committed by GitHub
25 changed files with 179 additions and 350 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -47,53 +47,73 @@ enum ocf_io_if_type {
static const struct ocf_io_if IO_IFS[OCF_IO_PRIV_MAX_IF] = {
[OCF_IO_WT_IF] = {
.read = ocf_read_generic,
.write = ocf_write_wt,
.cbs = {
[OCF_READ] = ocf_read_generic,
[OCF_WRITE] = ocf_write_wt,
},
.name = "Write Through"
},
[OCF_IO_WB_IF] = {
.read = ocf_read_generic,
.write = ocf_write_wb,
.cbs = {
[OCF_READ] = ocf_read_generic,
[OCF_WRITE] = ocf_write_wb,
},
.name = "Write Back"
},
[OCF_IO_WA_IF] = {
.read = ocf_read_generic,
.write = ocf_write_wa,
.cbs = {
[OCF_READ] = ocf_read_generic,
[OCF_WRITE] = ocf_write_wa,
},
.name = "Write Around"
},
[OCF_IO_WI_IF] = {
.read = ocf_read_generic,
.write = ocf_write_wi,
.cbs = {
[OCF_READ] = ocf_read_generic,
[OCF_WRITE] = ocf_write_wi,
},
.name = "Write Invalidate"
},
[OCF_IO_PT_IF] = {
.read = ocf_read_pt,
.write = ocf_write_wi,
.cbs = {
[OCF_READ] = ocf_read_pt,
[OCF_WRITE] = ocf_write_wi,
},
.name = "Pass Through",
},
[OCF_IO_WO_IF] = {
.read = ocf_read_wo,
.write = ocf_write_wb,
.cbs = {
[OCF_READ] = ocf_read_wo,
[OCF_WRITE] = ocf_write_wb,
},
.name = "Write Only",
},
[OCF_IO_FAST_IF] = {
.read = ocf_read_fast,
.write = ocf_write_fast,
.cbs = {
[OCF_READ] = ocf_read_fast,
[OCF_WRITE] = ocf_write_fast,
},
.name = "Fast",
},
[OCF_IO_DISCARD_IF] = {
.read = ocf_discard,
.write = ocf_discard,
.cbs = {
[OCF_READ] = ocf_discard,
[OCF_WRITE] = ocf_discard,
},
.name = "Discard",
},
[OCF_IO_D2C_IF] = {
.read = ocf_io_d2c,
.write = ocf_io_d2c,
.cbs = {
[OCF_READ] = ocf_io_d2c,
[OCF_WRITE] = ocf_io_d2c,
},
.name = "Direct to core",
},
[OCF_IO_OPS_IF] = {
.read = ocf_engine_ops,
.write = ocf_engine_ops,
.cbs = {
[OCF_READ] = ocf_engine_ops,
[OCF_WRITE] = ocf_engine_ops,
},
.name = "Ops engine",
},
};
@@ -109,11 +129,32 @@ static const struct ocf_io_if *cache_mode_io_if_map[ocf_req_cache_mode_max] = {
[ocf_req_cache_mode_d2c] = &IO_IFS[OCF_IO_D2C_IF],
};
const struct ocf_io_if *ocf_get_io_if(ocf_req_cache_mode_t req_cache_mode)
const char *ocf_get_io_iface_name(ocf_req_cache_mode_t cache_mode)
{
if (cache_mode == ocf_req_cache_mode_max)
return "Unknown";
return cache_mode_io_if_map[cache_mode]->name;
}
static ocf_engine_cb ocf_io_if_type_to_engine_cb(
enum ocf_io_if_type io_if_type, int rw)
{
if (unlikely(io_if_type == OCF_IO_MAX_IF ||
io_if_type == OCF_IO_PRIV_MAX_IF)) {
return NULL;
}
return IO_IFS[io_if_type].cbs[rw];
}
static ocf_engine_cb ocf_cache_mode_to_engine_cb(
ocf_req_cache_mode_t req_cache_mode, int rw)
{
if (req_cache_mode == ocf_req_cache_mode_max)
return NULL;
return cache_mode_io_if_map[req_cache_mode];
return cache_mode_io_if_map[req_cache_mode]->cbs[rw];
}
struct ocf_request *ocf_engine_pop_req(ocf_queue_t q)
@@ -205,8 +246,10 @@ int ocf_engine_hndl_req(struct ocf_request *req)
OCF_CHECK_NULL(cache);
req->io_if = ocf_get_io_if(req->cache_mode);
if (!req->io_if)
req->engine_handler = ocf_cache_mode_to_engine_cb(req->cache_mode,
req->rw);
if (!req->engine_handler)
return -OCF_ERR_INVAL;
ocf_req_get(req);
@@ -222,25 +265,16 @@ int ocf_engine_hndl_req(struct ocf_request *req)
int ocf_engine_hndl_fast_req(struct ocf_request *req)
{
const struct ocf_io_if *io_if;
ocf_engine_cb engine_cb;
int ret;
io_if = ocf_get_io_if(req->cache_mode);
if (!io_if)
engine_cb = ocf_cache_mode_to_engine_cb(req->cache_mode, req->rw);
if (!engine_cb)
return -OCF_ERR_INVAL;
ocf_req_get(req);
switch (req->rw) {
case OCF_READ:
ret = io_if->read(req);
break;
case OCF_WRITE:
ret = io_if->write(req);
break;
default:
ret = OCF_FAST_PATH_NO;
}
ret = engine_cb(req);
if (ret == OCF_FAST_PATH_NO)
ocf_req_put(req);
@@ -250,12 +284,7 @@ int ocf_engine_hndl_fast_req(struct ocf_request *req)
static void ocf_engine_hndl_2dc_req(struct ocf_request *req)
{
if (OCF_READ == req->rw)
IO_IFS[OCF_IO_D2C_IF].read(req);
else if (OCF_WRITE == req->rw)
IO_IFS[OCF_IO_D2C_IF].write(req);
else
ENV_BUG();
IO_IFS[OCF_IO_D2C_IF].cbs[req->rw](req);
}
void ocf_engine_hndl_discard_req(struct ocf_request *req)
@@ -267,22 +296,16 @@ void ocf_engine_hndl_discard_req(struct ocf_request *req)
return;
}
if (OCF_READ == req->rw)
IO_IFS[OCF_IO_DISCARD_IF].read(req);
else if (OCF_WRITE == req->rw)
IO_IFS[OCF_IO_DISCARD_IF].write(req);
else
ENV_BUG();
IO_IFS[OCF_IO_DISCARD_IF].cbs[req->rw](req);
}
void ocf_engine_hndl_ops_req(struct ocf_request *req)
{
ocf_req_get(req);
if (req->d2c)
req->io_if = &IO_IFS[OCF_IO_D2C_IF];
else
req->io_if = &IO_IFS[OCF_IO_OPS_IF];
req->engine_handler = (req->d2c) ?
ocf_io_if_type_to_engine_cb(OCF_IO_D2C_IF, req->rw) :
ocf_io_if_type_to_engine_cb(OCF_IO_OPS_IF, req->rw);
ocf_engine_push_req_back(req, true);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -32,10 +32,10 @@ typedef enum {
ocf_req_cache_mode_max,
} ocf_req_cache_mode_t;
struct ocf_io_if {
int (*read)(struct ocf_request *req);
typedef int (*ocf_engine_cb)(struct ocf_request *req);
int (*write)(struct ocf_request *req);
struct ocf_io_if {
ocf_engine_cb cbs[2]; /* READ and WRITE */
const char *name;
};
@@ -43,14 +43,7 @@ struct ocf_io_if {
void ocf_resolve_effective_cache_mode(ocf_cache_t cache,
ocf_core_t core, struct ocf_request *req);
const struct ocf_io_if *ocf_get_io_if(ocf_req_cache_mode_t cache_mode);
static inline const char *ocf_get_io_iface_name(ocf_cache_mode_t cache_mode)
{
const struct ocf_io_if *iface = ocf_get_io_if(cache_mode);
return iface ? iface->name : "Unknown";
}
const char *ocf_get_io_iface_name(ocf_req_cache_mode_t cache_mode);
bool ocf_req_cache_mode_has_lazy_write(ocf_req_cache_mode_t mode);

View File

@@ -91,13 +91,8 @@ static int _ocf_backfill_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_backfill = {
.read = _ocf_backfill_do,
.write = _ocf_backfill_do,
};
void ocf_engine_backfill(struct ocf_request *req)
{
backfill_queue_inc_block(req->cache);
ocf_engine_push_req_front_if(req, &_io_if_backfill, true);
ocf_engine_push_req_front_cb(req, _ocf_backfill_do, true);
}

View File

@@ -644,12 +644,12 @@ void ocf_engine_push_req_front(struct ocf_request *req, bool allow_sync)
ocf_queue_kick(q, allow_sync);
}
void ocf_engine_push_req_front_if(struct ocf_request *req,
const struct ocf_io_if *io_if,
void ocf_engine_push_req_front_cb(struct ocf_request *req,
ocf_engine_cb engine_cb,
bool allow_sync)
{
req->error = 0; /* Please explain why!!! */
req->io_if = io_if;
req->engine_handler = engine_cb;
ocf_engine_push_req_front(req, allow_sync);
}
@@ -681,16 +681,10 @@ static int _ocf_engine_refresh(struct ocf_request *req)
if (result == 0) {
/* Refresh successful, can process with original IO interface */
req->io_if = req->priv;
req->engine_handler = req->priv;
req->priv = NULL;
if (req->rw == OCF_READ)
req->io_if->read(req);
else if (req->rw == OCF_WRITE)
req->io_if->write(req);
else
ENV_BUG();
req->engine_handler(req);
} else {
ENV_WARN(true, "Inconsistent request");
req->error = -OCF_ERR_INVAL;
@@ -708,20 +702,15 @@ static int _ocf_engine_refresh(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_refresh = {
.read = _ocf_engine_refresh,
.write = _ocf_engine_refresh,
};
void ocf_engine_on_resume(struct ocf_request *req)
{
ENV_BUG_ON(req->priv);
OCF_CHECK_NULL(req->io_if);
OCF_CHECK_NULL(req->engine_handler);
/* Exchange IO interface */
req->priv = (void *)req->io_if;
/* Exchange engine handler */
req->priv = (void *)req->engine_handler;
OCF_DEBUG_RQ(req, "On resume");
ocf_engine_push_req_front_if(req, &_io_if_refresh, false);
ocf_engine_push_req_front_cb(req, _ocf_engine_refresh, false);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -304,12 +304,12 @@ void ocf_engine_push_req_front(struct ocf_request *req,
* @brief Set interface and push from request to the OCF thread worker queue
*
* @param req OCF request
* @param io_if IO interface
* @param engine_cb IO engine handler callback
* @param allow_sync caller allows for request from queue to be ran immediately
from push function in caller context
*/
void ocf_engine_push_req_front_if(struct ocf_request *req,
const struct ocf_io_if *io_if,
void ocf_engine_push_req_front_cb(struct ocf_request *req,
ocf_engine_cb engine_cb,
bool allow_sync);
void inc_fallback_pt_error_counter(ocf_cache_t cache);

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
@@ -18,31 +18,6 @@
#define OCF_ENGINE_DEBUG_IO_NAME "discard"
#include "engine_debug.h"
static int _ocf_discard_step_do(struct ocf_request *req);
static int _ocf_discard_step(struct ocf_request *req);
static int _ocf_discard_flush_cache(struct ocf_request *req);
static int _ocf_discard_core(struct ocf_request *req);
static const struct ocf_io_if _io_if_discard_step = {
.read = _ocf_discard_step,
.write = _ocf_discard_step,
};
static const struct ocf_io_if _io_if_discard_step_resume = {
.read = _ocf_discard_step_do,
.write = _ocf_discard_step_do,
};
static const struct ocf_io_if _io_if_discard_flush_cache = {
.read = _ocf_discard_flush_cache,
.write = _ocf_discard_flush_cache,
};
static const struct ocf_io_if _io_if_discard_core = {
.read = _ocf_discard_core,
.write = _ocf_discard_core,
};
static void _ocf_discard_complete_req(struct ocf_request *req, int error)
{
req->complete(req, error);
@@ -97,7 +72,7 @@ static void _ocf_discard_cache_flush_complete(struct ocf_io *io, int error)
return;
}
req->io_if = &_io_if_discard_core;
req->engine_handler = _ocf_discard_core;
ocf_engine_push_req_front(req, true);
ocf_io_put(io);
@@ -122,16 +97,18 @@ static int _ocf_discard_flush_cache(struct ocf_request *req)
return 0;
}
static int _ocf_discard_step(struct ocf_request *req);
static void _ocf_discard_finish_step(struct ocf_request *req)
{
req->discard.handled += BYTES_TO_SECTORS(req->byte_length);
if (req->discard.handled < req->discard.nr_sects)
req->io_if = &_io_if_discard_step;
req->engine_handler = _ocf_discard_step;
else if (!req->cache->metadata.is_volatile)
req->io_if = &_io_if_discard_flush_cache;
req->engine_handler = _ocf_discard_flush_cache;
else
req->io_if = &_io_if_discard_core;
req->engine_handler = _ocf_discard_core;
ocf_engine_push_req_front(req, true);
}
@@ -222,7 +199,7 @@ static int _ocf_discard_step(struct ocf_request *req)
req->core_line_last =
ocf_bytes_2_lines(cache, req->byte_position + req->byte_length - 1);
req->core_line_count = req->core_line_last - req->core_line_first + 1;
req->io_if = &_io_if_discard_step_resume;
req->engine_handler = _ocf_discard_step_do;
ENV_BUG_ON(env_memset(req->map, sizeof(*req->map) * req->core_line_count,
0));

View File

@@ -100,11 +100,6 @@ static int _ocf_read_fast_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_read_fast_resume = {
.read = _ocf_read_fast_do,
.write = _ocf_read_fast_do,
};
int ocf_read_fast(struct ocf_request *req)
{
bool hit;
@@ -114,8 +109,8 @@ int ocf_read_fast(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume io_if */
req->io_if = &_io_if_read_fast_resume;
/* Set resume handler */
req->engine_handler = _ocf_read_fast_do;
/*- Metadata RD access -----------------------------------------------*/
@@ -172,11 +167,6 @@ 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,
};
int ocf_write_fast(struct ocf_request *req)
{
bool mapped;
@@ -186,8 +176,8 @@ int ocf_write_fast(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume io_if */
req->io_if = &_io_if_write_fast_resume;
/* Set resume handler */
req->engine_handler = ocf_write_wb_do;
/*- Metadata RD access -----------------------------------------------*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -60,12 +60,7 @@ static int _ocf_invalidate_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_invalidate = {
.read = _ocf_invalidate_do,
.write = _ocf_invalidate_do,
};
void ocf_engine_invalidate(struct ocf_request *req)
{
ocf_engine_push_req_front_if(req, &_io_if_invalidate, true);
ocf_engine_push_req_front_cb(req, _ocf_invalidate_do, true);
}

View File

@@ -1,10 +1,11 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "engine_pt.h"
#include "engine_rd.h"
#include "engine_common.h"
#include "cache_engine.h"
#include "../ocf_request.h"
@@ -94,11 +95,6 @@ int ocf_read_pt_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_pt_resume = {
.read = ocf_read_pt_do,
.write = ocf_read_pt_do,
};
int ocf_read_pt(struct ocf_request *req)
{
bool use_cache = false;
@@ -111,8 +107,8 @@ int ocf_read_pt(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume io_if */
req->io_if = &_io_if_pt_resume;
/* Set resume handler */
req->engine_handler = ocf_read_pt_do;
ocf_req_hash(req);
ocf_hb_req_prot_lock_rd(req);
@@ -146,7 +142,7 @@ int ocf_read_pt(struct ocf_request *req)
* because of this force read data from cache
*/
ocf_req_clear(req);
ocf_get_io_if(ocf_cache_mode_wt)->read(req);
ocf_read_generic(req);
} else {
if (lock >= 0) {
if (lock == OCF_LOCK_ACQUIRED) {
@@ -171,6 +167,6 @@ int ocf_read_pt(struct ocf_request *req)
void ocf_engine_push_req_front_pt(struct ocf_request *req)
{
ocf_engine_push_req_front_if(req, &_io_if_pt_resume, true);
ocf_engine_push_req_front_cb(req, ocf_read_pt_do, true);
}

View File

@@ -204,11 +204,6 @@ static int _ocf_read_generic_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_read_generic_resume = {
.read = _ocf_read_generic_do,
.write = _ocf_read_generic_do,
};
static const struct ocf_engine_callbacks _rd_engine_callbacks =
{
.resume = ocf_engine_on_resume,
@@ -224,7 +219,7 @@ int ocf_read_generic(struct ocf_request *req)
if (env_atomic_read(&cache->pending_read_misses_list_blocked)) {
/* There are conditions to bypass IO */
req->force_pt = true;
ocf_get_io_if(ocf_cache_mode_pt)->read(req);
ocf_read_pt(req);
return 0;
}
@@ -232,7 +227,7 @@ int ocf_read_generic(struct ocf_request *req)
ocf_req_get(req);
/* Set resume call backs */
req->io_if = &_io_if_read_generic_resume;
req->engine_handler = _ocf_read_generic_do;
req->engine_cbs = &_rd_engine_callbacks;
lock = ocf_engine_prepare_clines(req);
@@ -254,7 +249,7 @@ int ocf_read_generic(struct ocf_request *req)
} else {
ocf_req_clear(req);
req->force_pt = true;
ocf_get_io_if(ocf_cache_mode_pt)->read(req);
ocf_read_pt(req);
}

View File

@@ -1,10 +1,12 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "engine_wa.h"
#include "engine_wt.h"
#include "engine_wi.h"
#include "engine_common.h"
#include "cache_engine.h"
#include "../ocf_request.h"
@@ -34,13 +36,13 @@ int ocf_write_wa(struct ocf_request *req)
ocf_req_clear(req);
/* There is HIT, do WT */
ocf_get_io_if(ocf_cache_mode_wt)->write(req);
ocf_write_wt(req);
} else {
ocf_req_clear(req);
/* MISS, do WI */
ocf_get_io_if(ocf_cache_mode_wi)->write(req);
ocf_write_wi(req);
}
/* Put OCF request - decrease reference counter */

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -8,6 +8,7 @@
#include "cache_engine.h"
#include "engine_common.h"
#include "engine_wb.h"
#include "engine_wi.h"
#include "engine_inv.h"
#include "../metadata/metadata.h"
#include "../ocf_request.h"
@@ -20,11 +21,6 @@
#define OCF_ENGINE_DEBUG_IO_NAME "wb"
#include "engine_debug.h"
static const struct ocf_io_if _io_if_wb_resume = {
.read = ocf_write_wb_do,
.write = ocf_write_wb_do,
};
static void _ocf_write_wb_update_bits(struct ocf_request *req)
{
bool miss = ocf_engine_is_miss(req);
@@ -87,11 +83,6 @@ static int ocf_write_wb_do_flush_metadata(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_wb_flush_metadata = {
.read = ocf_write_wb_do_flush_metadata,
.write = ocf_write_wb_do_flush_metadata,
};
static void _ocf_write_wb_complete(struct ocf_request *req, int error)
{
if (error) {
@@ -111,8 +102,8 @@ static void _ocf_write_wb_complete(struct ocf_request *req, int error)
ocf_engine_invalidate(req);
} else {
ocf_engine_push_req_front_if(req, &_io_if_wb_flush_metadata,
true);
ocf_engine_push_req_front_cb(req,
ocf_write_wb_do_flush_metadata, true);
}
}
@@ -181,8 +172,8 @@ int ocf_write_wb(struct ocf_request *req)
/* Not sure if we need this. */
ocf_req_get(req);
/* Set resume io_if */
req->io_if = &_io_if_wb_resume;
/* Set resume handler */
req->engine_handler = ocf_write_wb_do;
req->engine_cbs = &_wb_engine_callbacks;
/* TODO: Handle fits into dirty */
@@ -204,7 +195,7 @@ int ocf_write_wb(struct ocf_request *req)
}
} else {
ocf_req_clear(req);
ocf_get_io_if(ocf_cache_mode_pt)->write(req);
ocf_write_wi(req);
}
/* Put OCF request - decrease reference counter */

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -16,13 +16,6 @@
#define OCF_ENGINE_DEBUG_IO_NAME "wi"
#include "engine_debug.h"
static int ocf_write_wi_update_and_flush_metadata(struct ocf_request *req);
static const struct ocf_io_if _io_if_wi_update_metadata = {
.read = ocf_write_wi_update_and_flush_metadata,
.write = ocf_write_wi_update_and_flush_metadata,
};
int _ocf_write_wi_next_pass(struct ocf_request *req)
{
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);
@@ -50,11 +43,6 @@ int _ocf_write_wi_next_pass(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_wi_next_pass = {
.read = _ocf_write_wi_next_pass,
.write = _ocf_write_wi_next_pass,
};
static void _ocf_write_wi_io_flush_metadata(struct ocf_request *req, int error)
{
if (error) {
@@ -67,7 +55,7 @@ static void _ocf_write_wi_io_flush_metadata(struct ocf_request *req, int error)
if (!req->error && !req->wi_second_pass && ocf_engine_is_miss(req)) {
/* need another pass */
ocf_engine_push_req_front_if(req, &_io_if_wi_next_pass,
ocf_engine_push_req_front_cb(req, _ocf_write_wi_next_pass,
true);
return;
}
@@ -134,8 +122,8 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
ocf_req_put(req);
} else {
ocf_engine_push_req_front_if(req, &_io_if_wi_update_metadata,
true);
ocf_engine_push_req_front_cb(req,
ocf_write_wi_update_and_flush_metadata, true);
}
}
@@ -169,11 +157,6 @@ static void _ocf_write_wi_on_resume(struct ocf_request *req)
ocf_engine_push_req_front(req, true);
}
static const struct ocf_io_if _io_if_wi_core_write = {
.read = _ocf_write_wi_core_write,
.write = _ocf_write_wi_core_write,
};
int ocf_write_wi(struct ocf_request *req)
{
int lock = OCF_LOCK_NOT_ACQUIRED;
@@ -185,10 +168,10 @@ int ocf_write_wi(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume io_if */
req->io_if = req->wi_second_pass ?
&_io_if_wi_update_metadata :
&_io_if_wi_core_write;
/* Set resume handler */
req->engine_handler = req->wi_second_pass ?
ocf_write_wi_update_and_flush_metadata :
_ocf_write_wi_core_write;
ocf_req_hash(req);
ocf_hb_req_prot_lock_rd(req); /*- Metadata READ access, No eviction --------*/
@@ -209,7 +192,7 @@ int ocf_write_wi(struct ocf_request *req)
if (lock >= 0) {
if (lock == OCF_LOCK_ACQUIRED) {
req->io_if->write(req);
req->engine_handler(req);
} else {
/* WR lock was not acquired, need to wait for resume */
OCF_DEBUG_RQ(req, "NO LOCK");

View File

@@ -150,11 +150,6 @@ static int ocf_read_wo_cache_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_wo_cache_read = {
.read = ocf_read_wo_cache_do,
.write = ocf_read_wo_cache_do,
};
static void _ocf_read_wo_core_complete(struct ocf_request *req, int error)
{
if (error) {
@@ -173,7 +168,7 @@ static void _ocf_read_wo_core_complete(struct ocf_request *req, int error)
return;
}
req->io_if = &_io_if_wo_cache_read;
req->engine_handler = ocf_read_wo_cache_do;
ocf_engine_push_req_front(req, true);
}
@@ -206,11 +201,6 @@ int ocf_read_wo_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_wo_resume = {
.read = ocf_read_wo_do,
.write = ocf_read_wo_do,
};
int ocf_read_wo(struct ocf_request *req)
{
int lock = OCF_LOCK_ACQUIRED;
@@ -223,7 +213,7 @@ int ocf_read_wo(struct ocf_request *req)
ocf_req_get(req);
/* Set resume call backs */
req->io_if = &_io_if_wo_resume;
req->engine_handler = ocf_read_wo_do;
ocf_req_hash(req);
ocf_hb_req_prot_lock_rd(req); /*- Metadata RD access -----------------------*/

View File

@@ -1,11 +1,12 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "engine_wt.h"
#include "engine_wi.h"
#include "engine_inv.h"
#include "engine_common.h"
#include "../ocf_request.h"
@@ -91,11 +92,6 @@ static int ocf_write_wt_do_flush_metadata(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_wt_flush_metadata = {
.read = ocf_write_wt_do_flush_metadata,
.write = ocf_write_wt_do_flush_metadata,
};
static void _ocf_write_wt_req_complete(struct ocf_request *req)
{
if (env_atomic_dec_return(&req->req_remaining))
@@ -116,7 +112,8 @@ static void _ocf_write_wt_req_complete(struct ocf_request *req)
if (req->info.dirty_any) {
/* Some of the request's cachelines changed its state to clean */
ocf_engine_push_req_front_if(req, &_io_if_wt_flush_metadata, true);
ocf_engine_push_req_front_cb(req,
ocf_write_wt_do_flush_metadata, true);
} else {
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);
@@ -195,11 +192,6 @@ static int _ocf_write_wt_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_wt_resume = {
.read = _ocf_write_wt_do,
.write = _ocf_write_wt_do,
};
static const struct ocf_engine_callbacks _wt_engine_callbacks =
{
.resume = ocf_engine_on_resume,
@@ -214,8 +206,8 @@ int ocf_write_wt(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume io_if */
req->io_if = &_io_if_wt_resume;
/* Set resume handler */
req->engine_handler = _ocf_write_wt_do;
req->engine_cbs = &_wt_engine_callbacks;
lock = ocf_engine_prepare_clines(req);
@@ -235,7 +227,7 @@ int ocf_write_wt(struct ocf_request *req)
}
} else {
ocf_req_clear(req);
ocf_get_io_if(ocf_cache_mode_pt)->write(req);
ocf_write_wi(req);
}
/* Put OCF request - decrease reference counter */

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -40,11 +40,6 @@ static int ocf_zero_purge(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_zero_purge = {
.read = ocf_zero_purge,
.write = ocf_zero_purge,
};
static void _ocf_zero_io_flush_metadata(struct ocf_request *req, int error)
{
if (error) {
@@ -55,7 +50,7 @@ static void _ocf_zero_io_flush_metadata(struct ocf_request *req, int error)
if (env_atomic_dec_return(&req->req_remaining))
return;
ocf_engine_push_req_front_if(req, &_io_if_zero_purge, true);
ocf_engine_push_req_front_cb(req, ocf_zero_purge, true);
}
static inline void ocf_zero_map_info(struct ocf_request *req)
@@ -124,11 +119,6 @@ static int _ocf_zero_do(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_ocf_zero_do = {
.read = _ocf_zero_do,
.write = _ocf_zero_do,
};
/**
* @note
* - Caller has to have metadata write lock
@@ -149,7 +139,7 @@ void ocf_engine_zero_line(struct ocf_request *req)
ENV_BUG_ON(!ocf_engine_is_mapped(req));
req->io_if = &_io_if_ocf_zero_do;
req->engine_handler = _ocf_zero_do;
/* Some cache line are mapped, lock request for WRITE access */
lock = ocf_req_async_lock_wr(
@@ -158,7 +148,7 @@ void ocf_engine_zero_line(struct ocf_request *req)
if (lock >= 0) {
ENV_BUG_ON(lock != OCF_LOCK_ACQUIRED);
ocf_engine_push_req_front_if(req, &_io_if_ocf_zero_do, true);
ocf_engine_push_req_front_cb(req, _ocf_zero_do, true);
} else {
OCF_DEBUG_RQ(req, "LOCK ERROR %d", lock);
req->complete(req, lock);