Merge pull request #11 from robertbaldyga/remove-legacy-io-completion

Remove legacy io completion
This commit is contained in:
Jan Musiał 2018-12-12 13:30:48 +01:00 committed by GitHub
commit 131148adac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 198 additions and 275 deletions

View File

@ -16,16 +16,6 @@
struct ocf_io;
/**
* @brief OCF IO legacy completion
*
* @note This type of completion is for legacy completion type
*
* @param[in] private_data Private data for completion function
* @param[in] error Completion status code
*/
typedef void (*ocf_end_t)(void *private_data, int error);
/**
* @brief OCF IO start
*
@ -248,40 +238,6 @@ static inline void ocf_io_set_handle(struct ocf_io *io, ocf_handle_io_t fn)
io->handle = fn;
}
/**
* @brief Call default completion function
*
* @note It is helper function for legacy completion functions
*
* @param[in] io OCF IO
* @param[in] error Completion status code
*/
static inline void ocf_io_end_default(struct ocf_io *io, int error)
{
ocf_end_t end = io->priv2;
end(io->priv1, error);
ocf_io_put(io);
}
/**
* @brief Set OCF IO default completion function
*
* @note This type of completion is for legacy completion type
*
* @param[in] io OCF IO
* @param[in] context Context for completion function
* @param[in] fn Completion function
*/
static inline void ocf_io_set_default_cmpl(struct ocf_io *io, void *context,
ocf_end_t fn)
{
io->priv1 = context;
io->priv2 = fn;
io->end = ocf_io_end_default;
}
/**
* @brief Set up data vector in OCF IO
*

View File

@ -37,9 +37,8 @@ static inline void backfill_queue_inc_block(struct ocf_cache *cache)
env_atomic_set(&cache->pending_read_misses_list_blocked, 1);
}
static void _ocf_backfill_do_io(void *private_data, int error)
static void _ocf_backfill_do_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = (struct ocf_request *)private_data;
struct ocf_cache *cache = rq->cache;
if (error)
@ -88,7 +87,7 @@ static int _ocf_backfill_do(struct ocf_request *rq)
rq->data = rq->cp_data;
ocf_submit_cache_reqs(rq->cache, rq->map, rq, OCF_WRITE, reqs_to_issue,
_ocf_backfill_do_io, rq);
_ocf_backfill_do_io);
return 0;
}

View File

@ -14,58 +14,54 @@
#define OCF_ENGINE_DEBUG_IO_NAME "d2c"
#include "engine_debug.h"
static void _ocf_d2c_completion(void *private_data, int error)
static void _ocf_d2c_completion(struct ocf_request *req, int error)
{
struct ocf_request *rq = private_data;
ocf_core_t core = &req->cache->core_obj[req->core_id];
req->error = error;
rq->error = error;
OCF_DEBUG_RQ(req, "Completion");
OCF_DEBUG_RQ(rq, "Completion");
if (rq->error) {
rq->info.core_error = 1;
if (rq->rw == OCF_READ) {
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
core_errors.read);
} else {
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
core_errors.write);
}
if (req->error) {
req->info.core_error = 1;
if (req->rw == OCF_READ)
env_atomic_inc(&core->counters->core_errors.read);
else
env_atomic_inc(&core->counters->core_errors.write);
}
/* Complete request */
rq->complete(rq, rq->error);
req->complete(req, req->error);
/* Release OCF request */
ocf_rq_put(rq);
ocf_rq_put(req);
}
int ocf_io_d2c(struct ocf_request *rq)
int ocf_io_d2c(struct ocf_request *req)
{
struct ocf_cache *cache = rq->cache;
ocf_cache_t cache = req->cache;
ocf_core_t core = &cache->core_obj[req->core_id];
OCF_DEBUG_TRACE(rq->cache);
OCF_DEBUG_TRACE(req->cache);
ocf_io_start(rq->io);
ocf_io_start(req->io);
/* Get OCF request - increase reference counter */
ocf_rq_get(rq);
ocf_rq_get(req);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, rq->rw,
_ocf_d2c_completion, rq);
ocf_submit_obj_req(&core->obj, req, _ocf_d2c_completion);
ocf_engine_update_block_stats(rq);
ocf_engine_update_block_stats(req);
if (rq->rw == OCF_READ) {
env_atomic64_inc(&cache->core_obj[rq->core_id].counters->
part_counters[rq->part_id].read_reqs.pass_through);
if (req->rw == OCF_READ) {
env_atomic64_inc(&core->counters->
part_counters[req->part_id].read_reqs.pass_through);
} else {
env_atomic64_inc(&cache->core_obj[rq->core_id].counters->
part_counters[rq->part_id].write_reqs.pass_through);
env_atomic64_inc(&core->counters->
part_counters[req->part_id].write_reqs.pass_through);
}
/* Put OCF request - decrease reference counter */
ocf_rq_put(rq);
ocf_rq_put(req);
return 0;

View File

@ -43,35 +43,47 @@ static const struct ocf_io_if _io_if_discard_core = {
.write = _ocf_discard_core
};
static void _ocf_discard_complete_rq(struct ocf_request *rq, int error)
static void _ocf_discard_complete_rq(struct ocf_request *req, int error)
{
rq->complete(rq, error);
req->complete(req, error);
ocf_rq_put(rq);
ocf_rq_put(req);
}
static void _ocf_discard_core_io(void *private_data, int error)
static void _ocf_discard_core_io(struct ocf_io *io, int error)
{
struct ocf_request *rq = private_data;
struct ocf_request *rq = io->priv1;
OCF_DEBUG_RQ(rq, "Core DISCARD Completion");
_ocf_discard_complete_rq(rq, error);
}
static int _ocf_discard_core(struct ocf_request *rq)
static int _ocf_discard_core(struct ocf_request *req)
{
struct ocf_cache *cache = rq->cache;
struct ocf_cache *cache = req->cache;
struct ocf_io *io;
ocf_submit_obj_discard(&cache->core_obj[rq->core_id].obj, rq,
_ocf_discard_core_io, rq);
io = ocf_dobj_new_io(&cache->core_obj[req->core_id].obj);
if (!io) {
_ocf_discard_complete_rq(req, -ENOMEM);
return -ENOMEM;
}
ocf_io_configure(io, SECTORS_TO_BYTES(req->discard.sector),
SECTORS_TO_BYTES(req->discard.nr_sects),
OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, req, NULL, _ocf_discard_core_io);
ocf_io_set_data(io, req->data, 0);
ocf_dobj_submit_discard(io);
return 0;
}
static void _ocf_discard_cache_flush_io_cmpl(void *priv, int error)
static void _ocf_discard_cache_flush_io_cmpl(struct ocf_io *io, int error)
{
struct ocf_request *rq = priv;
struct ocf_request *rq = io->priv1;
if (error) {
ocf_metadata_error(rq->cache);
@ -83,10 +95,21 @@ static void _ocf_discard_cache_flush_io_cmpl(void *priv, int error)
ocf_engine_push_rq_front(rq, true);
}
static int _ocf_discard_flush_cache(struct ocf_request *rq)
static int _ocf_discard_flush_cache(struct ocf_request *req)
{
ocf_submit_obj_flush(&rq->cache->device->obj,
_ocf_discard_cache_flush_io_cmpl, rq);
struct ocf_io *io;
io = ocf_dobj_new_io(&req->cache->device->obj);
if (!io) {
ocf_metadata_error(req->cache);
_ocf_discard_complete_rq(req, -ENOMEM);
return -ENOMEM;
}
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, req, NULL, _ocf_discard_cache_flush_io_cmpl);
ocf_dobj_submit_flush(io);
return 0;
}
@ -105,10 +128,8 @@ static void _ocf_discard_finish_step(struct ocf_request *rq)
ocf_engine_push_rq_front(rq, true);
}
static void _ocf_discard_step_io(void *private_data, int error)
static void _ocf_discard_step_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error)
rq->error |= error;

View File

@ -28,10 +28,8 @@
* |_| \_\___|\__,_|\__,_| |_| \__,_|___/\__| |_| \__,_|\__|_| |_|
*/
static void _ocf_read_fast_io(void *private_data, int error)
static void _ocf_read_fast_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error)
rq->error |= error;
@ -91,7 +89,7 @@ static int _ocf_read_fast_do(struct ocf_request *rq)
OCF_DEBUG_RQ(rq, "Submit");
env_atomic_set(&rq->req_remaining, ocf_engine_io_count(rq));
ocf_submit_cache_reqs(rq->cache, rq->map, rq, OCF_READ,
ocf_engine_io_count(rq), _ocf_read_fast_io, rq);
ocf_engine_io_count(rq), _ocf_read_fast_io);
/* Updata statistics */

View File

@ -16,10 +16,8 @@
#define OCF_ENGINE_DEBUG_IO_NAME "inv"
#include "engine_debug.h"
static void _ocf_invalidate_rq(void *private_data, int error)
static void _ocf_invalidate_rq(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error) {
rq->error = error;
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->

View File

@ -13,10 +13,8 @@
#define OCF_ENGINE_DEBUG_IO_NAME "ops"
#include "engine_debug.h"
static void _ocf_engine_ops_io(void *private_data, int error)
static void _ocf_engine_ops_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error)
rq->error |= error;
@ -50,11 +48,11 @@ int ocf_engine_ops(struct ocf_request *rq)
env_atomic_set(&rq->req_remaining, 2);
/* Submit operation into core device */
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, rq->rw,
_ocf_engine_ops_io, rq);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
_ocf_engine_ops_io);
ocf_submit_cache_reqs(cache, rq->map, rq, rq->rw,
1, _ocf_engine_ops_io, rq);
1, _ocf_engine_ops_io);
/* Put OCF request - decrease reference counter */
ocf_rq_put(rq);

View File

@ -16,10 +16,8 @@
#define OCF_ENGINE_DEBUG_IO_NAME "pt"
#include "engine_debug.h"
static void _ocf_read_pt_io(void *private_data, int error)
static void _ocf_read_pt_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error)
rq->error |= error;
@ -52,8 +50,8 @@ static inline void _ocf_read_pt_submit(struct ocf_request *rq)
OCF_DEBUG_RQ(rq, "Submit");
/* Core read */
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_READ,
_ocf_read_pt_io, rq);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
_ocf_read_pt_io);
}
int ocf_read_pt_do(struct ocf_request *rq)

View File

@ -22,10 +22,8 @@
#define OCF_ENGINE_DEBUG_IO_NAME "rd"
#include "engine_debug.h"
static void _ocf_read_generic_hit_io(void *private_data, int error)
static void _ocf_read_generic_hit_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error)
rq->error |= error;
@ -58,9 +56,8 @@ static void _ocf_read_generic_hit_io(void *private_data, int error)
}
}
static void _ocf_read_generic_miss_io(void *private_data, int error)
static void _ocf_read_generic_miss_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
struct ocf_cache *cache = rq->cache;
if (error)
@ -111,7 +108,7 @@ static inline void _ocf_read_generic_submit_hit(struct ocf_request *rq)
env_atomic_set(&rq->req_remaining, ocf_engine_io_count(rq));
ocf_submit_cache_reqs(rq->cache, rq->map, rq, OCF_READ,
ocf_engine_io_count(rq), _ocf_read_generic_hit_io, rq);
ocf_engine_io_count(rq), _ocf_read_generic_hit_io);
}
static inline void _ocf_read_generic_submit_miss(struct ocf_request *rq)
@ -131,8 +128,8 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *rq)
goto err_alloc;
/* Submit read request to core device. */
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_READ,
_ocf_read_generic_miss_io, rq);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
_ocf_read_generic_miss_io);
return;

View File

@ -14,10 +14,8 @@
#define OCF_ENGINE_DEBUG_IO_NAME "wa"
#include "engine_debug.h"
static void _ocf_read_wa_io(void *private_data, int error)
static void _ocf_read_wa_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error)
rq->error |= error;
@ -75,7 +73,7 @@ int ocf_write_wa(struct ocf_request *rq)
/* Submit write IO to the core */
env_atomic_set(&rq->req_remaining, 1);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
OCF_WRITE, _ocf_read_wa_io, rq);
_ocf_read_wa_io);
/* Update statistics */
ocf_engine_update_block_stats(rq);

View File

@ -45,10 +45,8 @@ static void _ocf_write_wb_update_bits(struct ocf_request *rq)
}
}
static void _ocf_write_wb_io_flush_metadata(void *private_data, int error)
static void _ocf_write_wb_io_flush_metadata(struct ocf_request *rq, int error)
{
struct ocf_request *rq = (struct ocf_request *) private_data;
if (error)
rq->error = error;
@ -87,10 +85,8 @@ static const struct ocf_io_if _io_if_wb_flush_metadata = {
.write = ocf_write_wb_do_flush_metadata,
};
static void _ocf_write_wb_io(void *private_data, int error)
static void _ocf_write_wb_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = (struct ocf_request *) private_data;
if (error) {
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
cache_errors.write);
@ -146,7 +142,7 @@ static inline void _ocf_write_wb_submit(struct ocf_request *rq)
/* Data IO */
ocf_submit_cache_reqs(cache, rq->map, rq, OCF_WRITE,
ocf_engine_io_count(rq), _ocf_write_wb_io, rq);
ocf_engine_io_count(rq), _ocf_write_wb_io);
}
int ocf_write_wb_do(struct ocf_request *rq)

View File

@ -23,10 +23,8 @@ static const struct ocf_io_if _io_if_wi_flush_metadata = {
.write = ocf_write_wi_update_and_flush_metadata,
};
static void _ocf_write_wi_io_flush_metadata(void *private_data, int error)
static void _ocf_write_wi_io_flush_metadata(struct ocf_request *rq, int error)
{
struct ocf_request *rq = (struct ocf_request *) private_data;
if (error) {
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
cache_errors.write);
@ -75,10 +73,8 @@ static int ocf_write_wi_update_and_flush_metadata(struct ocf_request *rq)
return 0;
}
static void _ocf_write_wi_core_io(void *private_data, int error)
static void _ocf_write_wi_core_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error) {
rq->error = error;
rq->info.core_error = 1;
@ -115,8 +111,8 @@ static int _ocf_write_wi_do(struct ocf_request *rq)
OCF_DEBUG_RQ(rq, "Submit");
/* Submit write IO to the core */
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_WRITE,
_ocf_write_wi_core_io, rq);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
_ocf_write_wi_core_io);
/* Update statistics */
ocf_engine_update_block_stats(rq);

View File

@ -44,10 +44,8 @@ static void _ocf_write_wt_io(struct ocf_request *rq)
}
}
static void _ocf_write_wt_cache_io(void *private_data, int error)
static void _ocf_write_wt_cache_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error) {
rq->error = rq->error ?: error;
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
@ -60,10 +58,8 @@ static void _ocf_write_wt_cache_io(void *private_data, int error)
_ocf_write_wt_io(rq);
}
static void _ocf_write_wt_core_io(void *private_data, int error)
static void _ocf_write_wt_core_io(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error) {
rq->error = error;
rq->info.core_error = 1;
@ -94,11 +90,11 @@ static inline void _ocf_write_wt_submit(struct ocf_request *rq)
/* To cache */
ocf_submit_cache_reqs(cache, rq->map, rq, OCF_WRITE,
ocf_engine_io_count(rq), _ocf_write_wt_cache_io, rq);
ocf_engine_io_count(rq), _ocf_write_wt_cache_io);
/* To core */
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_WRITE,
_ocf_write_wt_core_io, rq);
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
_ocf_write_wt_core_io);
}
static void _ocf_write_wt_update_bits(struct ocf_request *rq)

View File

@ -47,10 +47,8 @@ static const struct ocf_io_if _io_if_zero_purge = {
.write = ocf_zero_purge,
};
static void _ocf_zero_io_flush_metadata(void *private_data, int error)
static void _ocf_zero_io_flush_metadata(struct ocf_request *rq, int error)
{
struct ocf_request *rq = (struct ocf_request *) private_data;
if (error) {
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
cache_errors.write);

View File

@ -147,7 +147,7 @@ void ocf_metadata_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
}
void ocf_metadata_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, ocf_end_t complete)
struct ocf_request *rq, ocf_req_end_t complete)
{
cache->metadata.iface.flush_do_asynch(cache, rq, complete);
}

View File

@ -257,7 +257,7 @@ void ocf_metadata_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
* @param context - context that will be passed into callback
*/
void ocf_metadata_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, ocf_end_t complete);
struct ocf_request *rq, ocf_req_end_t complete);
/**
* @brief Load metadata

View File

@ -1231,7 +1231,7 @@ static void ocf_metadata_hash_flush_mark(struct ocf_cache *cache,
* Flush specified cache lines asynchronously
*/
static void ocf_metadata_hash_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, ocf_metadata_asynch_flush_hndl complete)
struct ocf_request *rq, ocf_req_end_t complete)
{
int result = 0;
struct ocf_metadata_hash_ctrl *ctrl = NULL;

View File

@ -32,7 +32,8 @@
#define OCF_DEBUG_PARAM(cache, format, ...)
#endif
static void metadata_io_write_i_end_asynch(void *private_data, int error);
static void metadata_io_write_i_asynch_end(struct metadata_io_request *request,
int error);
static int ocf_restart_meta_io(struct ocf_request *req);
static struct ocf_io_if meta_restart_if = {
@ -146,6 +147,13 @@ int metadata_io_read_i_atomic(struct ocf_cache *cache,
return result;
}
static void metadata_io_write_i_asynch_cmpl(struct ocf_io *io, int error)
{
struct metadata_io_request *request = io->priv1;
metadata_io_write_i_asynch_end(request, error);
}
static int ocf_restart_meta_io(struct ocf_request *req)
{
struct ocf_io *io;
@ -168,7 +176,7 @@ static int ocf_restart_meta_io(struct ocf_request *req)
io = ocf_new_cache_io(cache);
if (!io) {
metadata_io_write_i_end_asynch(meta_io_req, -ENOMEM);
metadata_io_write_i_asynch_end(meta_io_req, -ENOMEM);
return 0;
}
@ -178,12 +186,11 @@ static int ocf_restart_meta_io(struct ocf_request *req)
PAGES_TO_BYTES(meta_io_req->count),
OCF_WRITE, 0, 0);
ocf_io_set_default_cmpl(io, meta_io_req,
metadata_io_write_i_end_asynch);
ocf_io_set_cmpl(io, meta_io_req, NULL, metadata_io_write_i_asynch_cmpl);
ret = ocf_io_set_data(io, meta_io_req->data, 0);
if (ret) {
ocf_io_put(io);
metadata_io_write_i_end_asynch(meta_io_req, ret);
metadata_io_write_i_asynch_end(meta_io_req, ret);
return ret;
}
ocf_dobj_submit_io(io);
@ -193,9 +200,9 @@ static int ocf_restart_meta_io(struct ocf_request *req)
/*
* Iterative asynchronous write callback
*/
static void metadata_io_write_i_end_asynch(void *private_data, int error)
static void metadata_io_write_i_asynch_end(struct metadata_io_request *request,
int error)
{
struct metadata_io_request *request = (private_data);
struct metadata_io_request_asynch *a_req;
struct ocf_cache *cache;
@ -359,8 +366,8 @@ int metadata_io_write_i_asynch(struct ocf_cache *cache, uint32_t queue,
PAGES_TO_BYTES(a_req->reqs[i].count),
OCF_WRITE, 0, 0);
ocf_io_set_default_cmpl(io, &a_req->reqs[i],
metadata_io_write_i_end_asynch);
ocf_io_set_cmpl(io, &a_req->reqs[i], NULL,
metadata_io_write_i_asynch_cmpl);
error = ocf_io_set_data(io, a_req->reqs[i].data, 0);
if (error) {
ocf_io_put(io);

View File

@ -306,7 +306,7 @@ static void _raw_ram_flush_mark(struct ocf_cache *cache,
struct _raw_ram_flush_ctx {
struct ocf_metadata_raw *raw;
struct ocf_request *rq;
ocf_metadata_asynch_flush_hndl complete;
ocf_req_end_t complete;
env_atomic flush_req_cnt;
int error;
};
@ -402,7 +402,7 @@ static void __raw_ram_flush_do_asynch_add_pages(struct ocf_request *rq,
static int _raw_ram_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete)
ocf_req_end_t complete)
{
int result = 0, i;
uint32_t __pages_tab[MAX_STACK_TAB_SIZE];

View File

@ -136,7 +136,7 @@ struct raw_iface {
int (*flush_do_asynch)(struct ocf_cache *cache, struct ocf_request *rq,
struct ocf_metadata_raw *raw,
ocf_metadata_asynch_flush_hndl complete);
ocf_req_end_t complete);
};
/**
@ -316,7 +316,7 @@ static inline void ocf_metadata_raw_flush_mark(struct ocf_cache *cache,
static inline int ocf_metadata_raw_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_metadata_asynch_flush_hndl complete)
ocf_req_end_t complete)
{
return raw->iface->flush_do_asynch(cache, rq, raw, complete);
}

View File

@ -33,7 +33,7 @@
struct _raw_atomic_flush_ctx {
struct ocf_request *rq;
ocf_metadata_asynch_flush_hndl complete;
ocf_req_end_t complete;
env_atomic flush_req_cnt;
};
@ -135,9 +135,8 @@ static int _raw_atomic_flush_do_asynch_sec(struct ocf_cache *cache,
return result;
}
int raw_atomic_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete)
int raw_atomic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
struct ocf_metadata_raw *raw, ocf_req_end_t complete)
{
int result = 0, i;
uint32_t __clines_tab[MAX_STACK_TAB_SIZE];

View File

@ -9,8 +9,7 @@
void raw_atomic_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
uint32_t map_idx, int to_state, uint8_t start, uint8_t stop);
int raw_atomic_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete);
int raw_atomic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
struct ocf_metadata_raw *raw, ocf_req_end_t complete);
#endif /* __METADATA_RAW_ATOMIC_H__ */
#endif /* __METADATA_RAW_ATOMIC_H__ */

View File

@ -437,9 +437,8 @@ void raw_dynamic_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
/*
* RAM DYNAMIC Implementation - Do flushing asynchronously
*/
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete)
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
struct ocf_metadata_raw *raw, ocf_req_end_t complete)
{
ENV_BUG();
return -ENOSYS;

View File

@ -98,9 +98,8 @@ void raw_dynamic_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
/*
* DYNAMIC Implementation - Do Flush Asynchronously
*/
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete);
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
struct ocf_metadata_raw *raw, ocf_req_end_t complete);
#endif /* METADATA_RAW_H_ */

View File

@ -67,7 +67,7 @@ void raw_volatile_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
*/
int raw_volatile_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete)
ocf_req_end_t complete)
{
complete(rq, 0);
return 0;

View File

@ -47,6 +47,6 @@ void raw_volatile_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
*/
int raw_volatile_flush_do_asynch(struct ocf_cache *cache,
struct ocf_request *rq, struct ocf_metadata_raw *raw,
ocf_end_t complete);
ocf_req_end_t complete);
#endif /* __METADATA_RAW_VOLATILE_H__ */

View File

@ -24,19 +24,6 @@ enum ocf_metadata_shutdown_status {
ocf_metadata_detached = 2, /*!< Cache device detached */
};
/**
* @brief Asynchronous metadata request completed
*
* @param cache - Cache instance
* @param error - Indicates operation result, 0 - Finished successfully
* @param line - cache line for which completion is signaled
* @param context - Context of metadata request
*/
typedef void (*ocf_metadata_asynch_hndl)(struct ocf_cache *cache,
int error, ocf_cache_line_t line, void *context);
typedef void (*ocf_metadata_asynch_flush_hndl)(void *context, int error);
/*
* Metadata cache line location on pages interface
*/
@ -222,7 +209,7 @@ struct ocf_metadata_iface {
* @param context - context that will be passed into callback
*/
void (*flush_do_asynch)(struct ocf_cache *cache,
struct ocf_request *rq, ocf_end_t complete);
struct ocf_request *rq, ocf_req_end_t complete);
/* TODO Provide documentation below */

View File

@ -199,4 +199,6 @@ struct ocf_request {
struct ocf_map_info __map[];
};
typedef void (*ocf_req_end_t)(struct ocf_request *rq, int error);
#endif

View File

@ -176,7 +176,7 @@ static void _ocf_cleaner_set_error(struct ocf_request *rq)
static void _ocf_cleaner_complete_rq(struct ocf_request *rq)
{
struct ocf_request *master = NULL;
ocf_end_t cmpl;
ocf_req_end_t cmpl;
if (ocf_cleaner_rq_type_master == rq->master_io_req_type) {
OCF_DEBUG_MSG(rq->cache, "Master completion");
@ -255,9 +255,9 @@ static void _ocf_cleaner_finish_rq(struct ocf_request *rq)
_ocf_cleaner_dealloc_rq(rq);
}
static void _ocf_cleaner_flush_cache_io_end(void *priv, int error)
static void _ocf_cleaner_flush_cache_io_end(struct ocf_io *io, int error)
{
struct ocf_request *rq = priv;
struct ocf_request *rq = io->priv1;
if (error) {
ocf_metadata_error(rq->cache);
@ -271,10 +271,21 @@ static void _ocf_cleaner_flush_cache_io_end(void *priv, int error)
static int _ocf_cleaner_fire_flush_cache(struct ocf_request *rq)
{
struct ocf_io *io;
OCF_DEBUG_TRACE(rq->cache);
ocf_submit_obj_flush(&rq->cache->device->obj,
_ocf_cleaner_flush_cache_io_end, rq);
io = ocf_dobj_new_io(&rq->cache->device->obj);
if (!io) {
ocf_metadata_error(rq->cache);
rq->error = -ENOMEM;
return -ENOMEM;
}
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, rq, NULL, _ocf_cleaner_flush_cache_io_end);
ocf_dobj_submit_flush(io);
return 0;
}
@ -284,10 +295,8 @@ static const struct ocf_io_if _io_if_flush_cache = {
.write = _ocf_cleaner_fire_flush_cache,
};
static void _ocf_cleaner_metadata_io_end(void *private_data, int error)
static void _ocf_cleaner_metadata_io_end(struct ocf_request *rq, int error)
{
struct ocf_request *rq = private_data;
if (error) {
ocf_metadata_error(rq->cache);
rq->error = error;

View File

@ -6,6 +6,8 @@
#ifndef UTILS_CLEANER_H_
#define UTILS_CLEANER_H_
#include "../ocf_request.h"
/**
* @brief Getter for next cache line to be cleaned
*
@ -32,7 +34,7 @@ struct ocf_cleaner_attribs {
uint32_t count; /*!< max number of cache lines to be cleaned */
void *cmpl_context; /*!< Completion context of cleaning requester */
ocf_end_t cmpl_fn; /*!< Completion function of requester */
void (*cmpl_fn)(void *priv, int error); /*!< Completion function of requester */
ocf_cleaner_get_item getter;
/*!< Getter for collecting cache lines which will be cleaned */

View File

@ -4,6 +4,7 @@
*/
#include "ocf/ocf.h"
#include "../ocf_priv.h"
#include "../ocf_cache_priv.h"
#include "../ocf_data_obj_priv.h"
#include "../ocf_request.h"
@ -26,25 +27,9 @@ struct discard_io_request {
int error;
};
void ocf_submit_obj_flush(ocf_data_obj_t obj, ocf_end_t callback, void *ctx)
static void _ocf_obj_flush_end(struct ocf_io *io, int err)
{
struct ocf_io *io;
io = ocf_dobj_new_io(obj);
if (!io) {
callback(ctx, -ENOMEM);
return;
}
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_default_cmpl(io, ctx, callback);
ocf_dobj_submit_flush(io);
}
static void _ocf_obj_flush_end(void *_cntx, int err)
{
struct ocf_submit_io_wait_context *cntx = _cntx;
struct ocf_submit_io_wait_context *cntx = io->priv1;
cntx->error = err;
env_completion_complete(&cntx->complete);
}
@ -52,10 +37,19 @@ static void _ocf_obj_flush_end(void *_cntx, int err)
int ocf_submit_obj_flush_wait(ocf_data_obj_t obj)
{
struct ocf_submit_io_wait_context cntx = { };
struct ocf_io *io;
env_atomic_set(&cntx.rq_remaining, 1);
env_completion_init(&cntx.complete);
ocf_submit_obj_flush(obj, _ocf_obj_flush_end, &cntx);
io = ocf_dobj_new_io(obj);
if (!io)
return -ENOMEM;
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, &cntx, NULL, _ocf_obj_flush_end);
ocf_dobj_submit_flush(io);
env_completion_wait(&cntx.complete);
@ -83,8 +77,8 @@ int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
uint64_t length)
{
struct ocf_submit_io_wait_context cntx = { };
uint32_t bytes;
uint32_t max_length = ~0;
uint64_t bytes;
uint64_t max_length = (uint32_t)~0;
ENV_BUG_ON(env_memset(&cntx, sizeof(cntx), 0));
env_atomic_set(&cntx.rq_remaining, 1);
@ -98,10 +92,7 @@ int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
break;
}
if (length > max_length)
bytes = max_length;
else
bytes = length;
bytes = min(length, max_length);
env_atomic_inc(&cntx.rq_remaining);
@ -208,28 +199,17 @@ end:
return result;
}
void ocf_submit_obj_discard(ocf_data_obj_t obj, struct ocf_request *req,
ocf_end_t callback, void *ctx)
static void ocf_submit_obj_req_cmpl(struct ocf_io *io, int error)
{
struct ocf_io *io = ocf_dobj_new_io(obj);
struct ocf_request *rq = io->priv1;
ocf_req_end_t callback = io->priv2;
if (!io) {
callback(ctx, -ENOMEM);
return;
}
ocf_io_configure(io, SECTORS_TO_BYTES(req->discard.sector),
SECTORS_TO_BYTES(req->discard.nr_sects),
OCF_WRITE, 0, 0);
ocf_io_set_default_cmpl(io, ctx, callback);
ocf_io_set_data(io, req->data, 0);
ocf_dobj_submit_discard(io);
callback(rq, error);
}
void ocf_submit_cache_reqs(struct ocf_cache *cache,
struct ocf_map_info *map_info, struct ocf_request *req, int dir,
unsigned int reqs, ocf_end_t callback, void *ctx)
unsigned int reqs, ocf_req_end_t callback)
{
struct ocf_counters_block *cache_stats;
uint64_t flags = req->io ? req->io->flags : 0;
@ -245,7 +225,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
if (reqs == 1) {
io = ocf_new_cache_io(cache);
if (!io) {
callback(ctx, -ENOMEM);
callback(req, -ENOMEM);
goto update_stats;
}
@ -257,12 +237,12 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
bytes = req->byte_length;
ocf_io_configure(io, addr, bytes, dir, class, flags);
ocf_io_set_default_cmpl(io, ctx, callback);
ocf_io_set_cmpl(io, req, callback, ocf_submit_obj_req_cmpl);
err = ocf_io_set_data(io, req->data, 0);
if (err) {
ocf_io_put(io);
callback(ctx, err);
callback(req, err);
goto update_stats;
}
@ -279,7 +259,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
if (!io) {
/* Finish all IOs which left with ERROR */
for (; i < reqs; i++)
callback(ctx, -ENOMEM);
callback(req, -ENOMEM);
goto update_stats;
}
@ -304,14 +284,14 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
}
ocf_io_configure(io, addr, bytes, dir, class, flags);
ocf_io_set_default_cmpl(io, ctx, callback);
ocf_io_set_cmpl(io, req, callback, ocf_submit_obj_req_cmpl);
err = ocf_io_set_data(io, req->data, total_bytes);
if (err) {
ocf_io_put(io);
/* Finish all IOs which left with ERROR */
for (; i < reqs; i++)
callback(ctx, err);
callback(req, err);
goto update_stats;
}
ocf_dobj_submit_io(io);
@ -325,36 +305,37 @@ update_stats:
env_atomic64_add(total_bytes, &cache_stats->read_bytes);
}
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *rq,
int dir, ocf_end_t callback, void *ctx)
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
ocf_req_end_t callback)
{
struct ocf_cache *cache = rq->cache;
struct ocf_cache *cache = req->cache;
struct ocf_counters_block *core_stats;
uint64_t flags = rq->io ? rq->io->flags : 0;
uint32_t class = rq->io ? rq->io->class : 0;
uint64_t flags = req->io ? req->io->flags : 0;
uint32_t class = req->io ? req->io->class : 0;
int dir = req->rw;
struct ocf_io *io;
int err;
core_stats = &cache->core_obj[rq->core_id].
core_stats = &cache->core_obj[req->core_id].
counters->core_blocks;
if (dir == OCF_WRITE)
env_atomic64_add(rq->byte_length, &core_stats->write_bytes);
env_atomic64_add(req->byte_length, &core_stats->write_bytes);
else if (dir == OCF_READ)
env_atomic64_add(rq->byte_length, &core_stats->read_bytes);
env_atomic64_add(req->byte_length, &core_stats->read_bytes);
io = ocf_dobj_new_io(obj);
if (!io) {
callback(ctx, -ENOMEM);
callback(req, -ENOMEM);
return;
}
ocf_io_configure(io, rq->byte_position, rq->byte_length, dir,
ocf_io_configure(io, req->byte_position, req->byte_length, dir,
class, flags);
ocf_io_set_default_cmpl(io, ctx, callback);
err = ocf_io_set_data(io, rq->data, 0);
ocf_io_set_cmpl(io, req, callback, ocf_submit_obj_req_cmpl);
err = ocf_io_set_data(io, req->data, 0);
if (err) {
ocf_io_put(io);
callback(ctx, err);
callback(req, err);
return;
}
ocf_dobj_submit_io(io);

View File

@ -45,17 +45,11 @@ static inline int ocf_io_overlaps(uint32_t start1, uint32_t count1,
int ocf_submit_io_wait(struct ocf_io *io);
void ocf_submit_obj_flush(ocf_data_obj_t obj, ocf_end_t callback,
void *context);
int ocf_submit_obj_flush_wait(ocf_data_obj_t obj);
int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
uint64_t length);
void ocf_submit_obj_discard(ocf_data_obj_t obj, struct ocf_request *req,
ocf_end_t callback, void *ctx);
int ocf_submit_write_zeroes_wait(ocf_data_obj_t obj, uint64_t addr,
uint64_t length);
@ -63,12 +57,12 @@ int ocf_submit_cache_page(struct ocf_cache *cache, uint64_t addr,
int dir, void *buffer);
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
int dir, ocf_end_t callback, void *ctx);
ocf_req_end_t callback);
void ocf_submit_cache_reqs(struct ocf_cache *cache,
struct ocf_map_info *map_info, struct ocf_request *req, int dir,
unsigned int reqs, ocf_end_t callback, void *ctx);
unsigned int reqs, ocf_req_end_t callback);
static inline struct ocf_io *ocf_new_cache_io(struct ocf_cache *cache)
{