Merge pull request #11 from robertbaldyga/remove-legacy-io-completion
Remove legacy io completion
This commit is contained in:
commit
131148adac
44
inc/ocf_io.h
44
inc/ocf_io.h
@ -16,16 +16,6 @@
|
|||||||
|
|
||||||
struct ocf_io;
|
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
|
* @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;
|
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
|
* @brief Set up data vector in OCF IO
|
||||||
*
|
*
|
||||||
|
@ -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);
|
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;
|
struct ocf_cache *cache = rq->cache;
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
@ -88,7 +87,7 @@ static int _ocf_backfill_do(struct ocf_request *rq)
|
|||||||
rq->data = rq->cp_data;
|
rq->data = rq->cp_data;
|
||||||
|
|
||||||
ocf_submit_cache_reqs(rq->cache, rq->map, rq, OCF_WRITE, reqs_to_issue,
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -14,58 +14,54 @@
|
|||||||
#define OCF_ENGINE_DEBUG_IO_NAME "d2c"
|
#define OCF_ENGINE_DEBUG_IO_NAME "d2c"
|
||||||
#include "engine_debug.h"
|
#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 (req->error) {
|
||||||
|
req->info.core_error = 1;
|
||||||
if (rq->error) {
|
if (req->rw == OCF_READ)
|
||||||
rq->info.core_error = 1;
|
env_atomic_inc(&core->counters->core_errors.read);
|
||||||
if (rq->rw == OCF_READ) {
|
else
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
env_atomic_inc(&core->counters->core_errors.write);
|
||||||
core_errors.read);
|
|
||||||
} else {
|
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
|
||||||
core_errors.write);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Complete request */
|
/* Complete request */
|
||||||
rq->complete(rq, rq->error);
|
req->complete(req, req->error);
|
||||||
|
|
||||||
/* Release OCF request */
|
/* 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 */
|
/* 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_submit_obj_req(&core->obj, req, _ocf_d2c_completion);
|
||||||
_ocf_d2c_completion, rq);
|
|
||||||
|
|
||||||
ocf_engine_update_block_stats(rq);
|
ocf_engine_update_block_stats(req);
|
||||||
|
|
||||||
if (rq->rw == OCF_READ) {
|
if (req->rw == OCF_READ) {
|
||||||
env_atomic64_inc(&cache->core_obj[rq->core_id].counters->
|
env_atomic64_inc(&core->counters->
|
||||||
part_counters[rq->part_id].read_reqs.pass_through);
|
part_counters[req->part_id].read_reqs.pass_through);
|
||||||
} else {
|
} else {
|
||||||
env_atomic64_inc(&cache->core_obj[rq->core_id].counters->
|
env_atomic64_inc(&core->counters->
|
||||||
part_counters[rq->part_id].write_reqs.pass_through);
|
part_counters[req->part_id].write_reqs.pass_through);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put OCF request - decrease reference counter */
|
/* Put OCF request - decrease reference counter */
|
||||||
ocf_rq_put(rq);
|
ocf_rq_put(req);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -43,35 +43,47 @@ static const struct ocf_io_if _io_if_discard_core = {
|
|||||||
.write = _ocf_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(struct ocf_io *io, int error)
|
||||||
static void _ocf_discard_core_io(void *private_data, int error)
|
|
||||||
{
|
{
|
||||||
struct ocf_request *rq = private_data;
|
struct ocf_request *rq = io->priv1;
|
||||||
|
|
||||||
OCF_DEBUG_RQ(rq, "Core DISCARD Completion");
|
OCF_DEBUG_RQ(rq, "Core DISCARD Completion");
|
||||||
|
|
||||||
_ocf_discard_complete_rq(rq, error);
|
_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,
|
io = ocf_dobj_new_io(&cache->core_obj[req->core_id].obj);
|
||||||
_ocf_discard_core_io, rq);
|
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;
|
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) {
|
if (error) {
|
||||||
ocf_metadata_error(rq->cache);
|
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);
|
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,
|
struct ocf_io *io;
|
||||||
_ocf_discard_cache_flush_io_cmpl, rq);
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -105,10 +128,8 @@ static void _ocf_discard_finish_step(struct ocf_request *rq)
|
|||||||
ocf_engine_push_rq_front(rq, true);
|
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)
|
if (error)
|
||||||
rq->error |= error;
|
rq->error |= error;
|
||||||
|
|
||||||
|
@ -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)
|
if (error)
|
||||||
rq->error |= error;
|
rq->error |= error;
|
||||||
|
|
||||||
@ -91,7 +89,7 @@ static int _ocf_read_fast_do(struct ocf_request *rq)
|
|||||||
OCF_DEBUG_RQ(rq, "Submit");
|
OCF_DEBUG_RQ(rq, "Submit");
|
||||||
env_atomic_set(&rq->req_remaining, ocf_engine_io_count(rq));
|
env_atomic_set(&rq->req_remaining, ocf_engine_io_count(rq));
|
||||||
ocf_submit_cache_reqs(rq->cache, rq->map, rq, OCF_READ,
|
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 */
|
/* Updata statistics */
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
#define OCF_ENGINE_DEBUG_IO_NAME "inv"
|
#define OCF_ENGINE_DEBUG_IO_NAME "inv"
|
||||||
#include "engine_debug.h"
|
#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) {
|
if (error) {
|
||||||
rq->error = error;
|
rq->error = error;
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
||||||
|
@ -13,10 +13,8 @@
|
|||||||
#define OCF_ENGINE_DEBUG_IO_NAME "ops"
|
#define OCF_ENGINE_DEBUG_IO_NAME "ops"
|
||||||
#include "engine_debug.h"
|
#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)
|
if (error)
|
||||||
rq->error |= error;
|
rq->error |= error;
|
||||||
|
|
||||||
@ -50,11 +48,11 @@ int ocf_engine_ops(struct ocf_request *rq)
|
|||||||
env_atomic_set(&rq->req_remaining, 2);
|
env_atomic_set(&rq->req_remaining, 2);
|
||||||
|
|
||||||
/* Submit operation into core device */
|
/* Submit operation into core device */
|
||||||
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, rq->rw,
|
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
|
||||||
_ocf_engine_ops_io, rq);
|
_ocf_engine_ops_io);
|
||||||
|
|
||||||
ocf_submit_cache_reqs(cache, rq->map, rq, rq->rw,
|
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 */
|
/* Put OCF request - decrease reference counter */
|
||||||
ocf_rq_put(rq);
|
ocf_rq_put(rq);
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
#define OCF_ENGINE_DEBUG_IO_NAME "pt"
|
#define OCF_ENGINE_DEBUG_IO_NAME "pt"
|
||||||
#include "engine_debug.h"
|
#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)
|
if (error)
|
||||||
rq->error |= error;
|
rq->error |= error;
|
||||||
|
|
||||||
@ -52,8 +50,8 @@ static inline void _ocf_read_pt_submit(struct ocf_request *rq)
|
|||||||
OCF_DEBUG_RQ(rq, "Submit");
|
OCF_DEBUG_RQ(rq, "Submit");
|
||||||
|
|
||||||
/* Core read */
|
/* Core read */
|
||||||
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_READ,
|
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
|
||||||
_ocf_read_pt_io, rq);
|
_ocf_read_pt_io);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_read_pt_do(struct ocf_request *rq)
|
int ocf_read_pt_do(struct ocf_request *rq)
|
||||||
|
@ -22,10 +22,8 @@
|
|||||||
#define OCF_ENGINE_DEBUG_IO_NAME "rd"
|
#define OCF_ENGINE_DEBUG_IO_NAME "rd"
|
||||||
#include "engine_debug.h"
|
#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)
|
if (error)
|
||||||
rq->error |= 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;
|
struct ocf_cache *cache = rq->cache;
|
||||||
|
|
||||||
if (error)
|
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));
|
env_atomic_set(&rq->req_remaining, ocf_engine_io_count(rq));
|
||||||
|
|
||||||
ocf_submit_cache_reqs(rq->cache, rq->map, rq, OCF_READ,
|
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)
|
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;
|
goto err_alloc;
|
||||||
|
|
||||||
/* Submit read request to core device. */
|
/* Submit read request to core device. */
|
||||||
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_READ,
|
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
|
||||||
_ocf_read_generic_miss_io, rq);
|
_ocf_read_generic_miss_io);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -14,10 +14,8 @@
|
|||||||
#define OCF_ENGINE_DEBUG_IO_NAME "wa"
|
#define OCF_ENGINE_DEBUG_IO_NAME "wa"
|
||||||
#include "engine_debug.h"
|
#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)
|
if (error)
|
||||||
rq->error |= error;
|
rq->error |= error;
|
||||||
|
|
||||||
@ -75,7 +73,7 @@ int ocf_write_wa(struct ocf_request *rq)
|
|||||||
/* Submit write IO to the core */
|
/* Submit write IO to the core */
|
||||||
env_atomic_set(&rq->req_remaining, 1);
|
env_atomic_set(&rq->req_remaining, 1);
|
||||||
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
|
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 */
|
/* Update statistics */
|
||||||
ocf_engine_update_block_stats(rq);
|
ocf_engine_update_block_stats(rq);
|
||||||
|
@ -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)
|
if (error)
|
||||||
rq->error = 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,
|
.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) {
|
if (error) {
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
||||||
cache_errors.write);
|
cache_errors.write);
|
||||||
@ -146,7 +142,7 @@ static inline void _ocf_write_wb_submit(struct ocf_request *rq)
|
|||||||
|
|
||||||
/* Data IO */
|
/* Data IO */
|
||||||
ocf_submit_cache_reqs(cache, rq->map, rq, OCF_WRITE,
|
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)
|
int ocf_write_wb_do(struct ocf_request *rq)
|
||||||
|
@ -23,10 +23,8 @@ static const struct ocf_io_if _io_if_wi_flush_metadata = {
|
|||||||
.write = ocf_write_wi_update_and_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) {
|
if (error) {
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
||||||
cache_errors.write);
|
cache_errors.write);
|
||||||
@ -75,10 +73,8 @@ static int ocf_write_wi_update_and_flush_metadata(struct ocf_request *rq)
|
|||||||
return 0;
|
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) {
|
if (error) {
|
||||||
rq->error = error;
|
rq->error = error;
|
||||||
rq->info.core_error = 1;
|
rq->info.core_error = 1;
|
||||||
@ -115,8 +111,8 @@ static int _ocf_write_wi_do(struct ocf_request *rq)
|
|||||||
OCF_DEBUG_RQ(rq, "Submit");
|
OCF_DEBUG_RQ(rq, "Submit");
|
||||||
|
|
||||||
/* Submit write IO to the core */
|
/* Submit write IO to the core */
|
||||||
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_WRITE,
|
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
|
||||||
_ocf_write_wi_core_io, rq);
|
_ocf_write_wi_core_io);
|
||||||
|
|
||||||
/* Update statistics */
|
/* Update statistics */
|
||||||
ocf_engine_update_block_stats(rq);
|
ocf_engine_update_block_stats(rq);
|
||||||
|
@ -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) {
|
if (error) {
|
||||||
rq->error = rq->error ?: error;
|
rq->error = rq->error ?: error;
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
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);
|
_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) {
|
if (error) {
|
||||||
rq->error = error;
|
rq->error = error;
|
||||||
rq->info.core_error = 1;
|
rq->info.core_error = 1;
|
||||||
@ -94,11 +90,11 @@ static inline void _ocf_write_wt_submit(struct ocf_request *rq)
|
|||||||
|
|
||||||
/* To cache */
|
/* To cache */
|
||||||
ocf_submit_cache_reqs(cache, rq->map, rq, OCF_WRITE,
|
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 */
|
/* To core */
|
||||||
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq, OCF_WRITE,
|
ocf_submit_obj_req(&cache->core_obj[rq->core_id].obj, rq,
|
||||||
_ocf_write_wt_core_io, rq);
|
_ocf_write_wt_core_io);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ocf_write_wt_update_bits(struct ocf_request *rq)
|
static void _ocf_write_wt_update_bits(struct ocf_request *rq)
|
||||||
|
@ -47,10 +47,8 @@ static const struct ocf_io_if _io_if_zero_purge = {
|
|||||||
.write = ocf_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) {
|
if (error) {
|
||||||
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
env_atomic_inc(&rq->cache->core_obj[rq->core_id].counters->
|
||||||
cache_errors.write);
|
cache_errors.write);
|
||||||
|
@ -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,
|
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);
|
cache->metadata.iface.flush_do_asynch(cache, rq, complete);
|
||||||
}
|
}
|
||||||
|
@ -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
|
* @param context - context that will be passed into callback
|
||||||
*/
|
*/
|
||||||
void ocf_metadata_flush_do_asynch(struct ocf_cache *cache,
|
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
|
* @brief Load metadata
|
||||||
|
@ -1231,7 +1231,7 @@ static void ocf_metadata_hash_flush_mark(struct ocf_cache *cache,
|
|||||||
* Flush specified cache lines asynchronously
|
* Flush specified cache lines asynchronously
|
||||||
*/
|
*/
|
||||||
static void ocf_metadata_hash_flush_do_asynch(struct ocf_cache *cache,
|
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;
|
int result = 0;
|
||||||
struct ocf_metadata_hash_ctrl *ctrl = NULL;
|
struct ocf_metadata_hash_ctrl *ctrl = NULL;
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
#define OCF_DEBUG_PARAM(cache, format, ...)
|
#define OCF_DEBUG_PARAM(cache, format, ...)
|
||||||
#endif
|
#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 int ocf_restart_meta_io(struct ocf_request *req);
|
||||||
|
|
||||||
static struct ocf_io_if meta_restart_if = {
|
static struct ocf_io_if meta_restart_if = {
|
||||||
@ -146,6 +147,13 @@ int metadata_io_read_i_atomic(struct ocf_cache *cache,
|
|||||||
return result;
|
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)
|
static int ocf_restart_meta_io(struct ocf_request *req)
|
||||||
{
|
{
|
||||||
struct ocf_io *io;
|
struct ocf_io *io;
|
||||||
@ -168,7 +176,7 @@ static int ocf_restart_meta_io(struct ocf_request *req)
|
|||||||
|
|
||||||
io = ocf_new_cache_io(cache);
|
io = ocf_new_cache_io(cache);
|
||||||
if (!io) {
|
if (!io) {
|
||||||
metadata_io_write_i_end_asynch(meta_io_req, -ENOMEM);
|
metadata_io_write_i_asynch_end(meta_io_req, -ENOMEM);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,12 +186,11 @@ static int ocf_restart_meta_io(struct ocf_request *req)
|
|||||||
PAGES_TO_BYTES(meta_io_req->count),
|
PAGES_TO_BYTES(meta_io_req->count),
|
||||||
OCF_WRITE, 0, 0);
|
OCF_WRITE, 0, 0);
|
||||||
|
|
||||||
ocf_io_set_default_cmpl(io, meta_io_req,
|
ocf_io_set_cmpl(io, meta_io_req, NULL, metadata_io_write_i_asynch_cmpl);
|
||||||
metadata_io_write_i_end_asynch);
|
|
||||||
ret = ocf_io_set_data(io, meta_io_req->data, 0);
|
ret = ocf_io_set_data(io, meta_io_req->data, 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ocf_io_put(io);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
ocf_dobj_submit_io(io);
|
ocf_dobj_submit_io(io);
|
||||||
@ -193,9 +200,9 @@ static int ocf_restart_meta_io(struct ocf_request *req)
|
|||||||
/*
|
/*
|
||||||
* Iterative asynchronous write callback
|
* 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 metadata_io_request_asynch *a_req;
|
||||||
struct ocf_cache *cache;
|
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),
|
PAGES_TO_BYTES(a_req->reqs[i].count),
|
||||||
OCF_WRITE, 0, 0);
|
OCF_WRITE, 0, 0);
|
||||||
|
|
||||||
ocf_io_set_default_cmpl(io, &a_req->reqs[i],
|
ocf_io_set_cmpl(io, &a_req->reqs[i], NULL,
|
||||||
metadata_io_write_i_end_asynch);
|
metadata_io_write_i_asynch_cmpl);
|
||||||
error = ocf_io_set_data(io, a_req->reqs[i].data, 0);
|
error = ocf_io_set_data(io, a_req->reqs[i].data, 0);
|
||||||
if (error) {
|
if (error) {
|
||||||
ocf_io_put(io);
|
ocf_io_put(io);
|
||||||
|
@ -306,7 +306,7 @@ static void _raw_ram_flush_mark(struct ocf_cache *cache,
|
|||||||
struct _raw_ram_flush_ctx {
|
struct _raw_ram_flush_ctx {
|
||||||
struct ocf_metadata_raw *raw;
|
struct ocf_metadata_raw *raw;
|
||||||
struct ocf_request *rq;
|
struct ocf_request *rq;
|
||||||
ocf_metadata_asynch_flush_hndl complete;
|
ocf_req_end_t complete;
|
||||||
env_atomic flush_req_cnt;
|
env_atomic flush_req_cnt;
|
||||||
int error;
|
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,
|
static int _raw_ram_flush_do_asynch(struct ocf_cache *cache,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
||||||
ocf_end_t complete)
|
ocf_req_end_t complete)
|
||||||
{
|
{
|
||||||
int result = 0, i;
|
int result = 0, i;
|
||||||
uint32_t __pages_tab[MAX_STACK_TAB_SIZE];
|
uint32_t __pages_tab[MAX_STACK_TAB_SIZE];
|
||||||
|
@ -136,7 +136,7 @@ struct raw_iface {
|
|||||||
|
|
||||||
int (*flush_do_asynch)(struct ocf_cache *cache, struct ocf_request *rq,
|
int (*flush_do_asynch)(struct ocf_cache *cache, struct ocf_request *rq,
|
||||||
struct ocf_metadata_raw *raw,
|
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,
|
static inline int ocf_metadata_raw_flush_do_asynch(struct ocf_cache *cache,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
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);
|
return raw->iface->flush_do_asynch(cache, rq, raw, complete);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
struct _raw_atomic_flush_ctx {
|
struct _raw_atomic_flush_ctx {
|
||||||
struct ocf_request *rq;
|
struct ocf_request *rq;
|
||||||
ocf_metadata_asynch_flush_hndl complete;
|
ocf_req_end_t complete;
|
||||||
env_atomic flush_req_cnt;
|
env_atomic flush_req_cnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,9 +135,8 @@ static int _raw_atomic_flush_do_asynch_sec(struct ocf_cache *cache,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int raw_atomic_flush_do_asynch(struct ocf_cache *cache,
|
int raw_atomic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_metadata_raw *raw, ocf_req_end_t complete)
|
||||||
ocf_end_t complete)
|
|
||||||
{
|
{
|
||||||
int result = 0, i;
|
int result = 0, i;
|
||||||
uint32_t __clines_tab[MAX_STACK_TAB_SIZE];
|
uint32_t __clines_tab[MAX_STACK_TAB_SIZE];
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
void raw_atomic_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
|
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);
|
uint32_t map_idx, int to_state, uint8_t start, uint8_t stop);
|
||||||
|
|
||||||
int raw_atomic_flush_do_asynch(struct ocf_cache *cache,
|
int raw_atomic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_metadata_raw *raw, ocf_req_end_t complete);
|
||||||
ocf_end_t complete);
|
|
||||||
|
|
||||||
#endif /* __METADATA_RAW_ATOMIC_H__ */
|
#endif /* __METADATA_RAW_ATOMIC_H__ */
|
||||||
|
@ -437,9 +437,8 @@ void raw_dynamic_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
|
|||||||
/*
|
/*
|
||||||
* RAM DYNAMIC Implementation - Do flushing asynchronously
|
* RAM DYNAMIC Implementation - Do flushing asynchronously
|
||||||
*/
|
*/
|
||||||
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache,
|
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_metadata_raw *raw, ocf_req_end_t complete)
|
||||||
ocf_end_t complete)
|
|
||||||
{
|
{
|
||||||
ENV_BUG();
|
ENV_BUG();
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
@ -98,9 +98,8 @@ void raw_dynamic_flush_mark(struct ocf_cache *cache, struct ocf_request *rq,
|
|||||||
/*
|
/*
|
||||||
* DYNAMIC Implementation - Do Flush Asynchronously
|
* DYNAMIC Implementation - Do Flush Asynchronously
|
||||||
*/
|
*/
|
||||||
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache,
|
int raw_dynamic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *rq,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_metadata_raw *raw, ocf_req_end_t complete);
|
||||||
ocf_end_t complete);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* METADATA_RAW_H_ */
|
#endif /* METADATA_RAW_H_ */
|
||||||
|
@ -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,
|
int raw_volatile_flush_do_asynch(struct ocf_cache *cache,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
||||||
ocf_end_t complete)
|
ocf_req_end_t complete)
|
||||||
{
|
{
|
||||||
complete(rq, 0);
|
complete(rq, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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,
|
int raw_volatile_flush_do_asynch(struct ocf_cache *cache,
|
||||||
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
struct ocf_request *rq, struct ocf_metadata_raw *raw,
|
||||||
ocf_end_t complete);
|
ocf_req_end_t complete);
|
||||||
|
|
||||||
#endif /* __METADATA_RAW_VOLATILE_H__ */
|
#endif /* __METADATA_RAW_VOLATILE_H__ */
|
||||||
|
@ -24,19 +24,6 @@ enum ocf_metadata_shutdown_status {
|
|||||||
ocf_metadata_detached = 2, /*!< Cache device detached */
|
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
|
* Metadata cache line location on pages interface
|
||||||
*/
|
*/
|
||||||
@ -222,7 +209,7 @@ struct ocf_metadata_iface {
|
|||||||
* @param context - context that will be passed into callback
|
* @param context - context that will be passed into callback
|
||||||
*/
|
*/
|
||||||
void (*flush_do_asynch)(struct ocf_cache *cache,
|
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 */
|
/* TODO Provide documentation below */
|
||||||
|
@ -199,4 +199,6 @@ struct ocf_request {
|
|||||||
struct ocf_map_info __map[];
|
struct ocf_map_info __map[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*ocf_req_end_t)(struct ocf_request *rq, int error);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -176,7 +176,7 @@ static void _ocf_cleaner_set_error(struct ocf_request *rq)
|
|||||||
static void _ocf_cleaner_complete_rq(struct ocf_request *rq)
|
static void _ocf_cleaner_complete_rq(struct ocf_request *rq)
|
||||||
{
|
{
|
||||||
struct ocf_request *master = NULL;
|
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) {
|
if (ocf_cleaner_rq_type_master == rq->master_io_req_type) {
|
||||||
OCF_DEBUG_MSG(rq->cache, "Master completion");
|
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);
|
_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) {
|
if (error) {
|
||||||
ocf_metadata_error(rq->cache);
|
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)
|
static int _ocf_cleaner_fire_flush_cache(struct ocf_request *rq)
|
||||||
{
|
{
|
||||||
|
struct ocf_io *io;
|
||||||
|
|
||||||
OCF_DEBUG_TRACE(rq->cache);
|
OCF_DEBUG_TRACE(rq->cache);
|
||||||
|
|
||||||
ocf_submit_obj_flush(&rq->cache->device->obj,
|
io = ocf_dobj_new_io(&rq->cache->device->obj);
|
||||||
_ocf_cleaner_flush_cache_io_end, rq);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -284,10 +295,8 @@ static const struct ocf_io_if _io_if_flush_cache = {
|
|||||||
.write = _ocf_cleaner_fire_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) {
|
if (error) {
|
||||||
ocf_metadata_error(rq->cache);
|
ocf_metadata_error(rq->cache);
|
||||||
rq->error = error;
|
rq->error = error;
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#ifndef UTILS_CLEANER_H_
|
#ifndef UTILS_CLEANER_H_
|
||||||
#define UTILS_CLEANER_H_
|
#define UTILS_CLEANER_H_
|
||||||
|
|
||||||
|
#include "../ocf_request.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Getter for next cache line to be cleaned
|
* @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 */
|
uint32_t count; /*!< max number of cache lines to be cleaned */
|
||||||
|
|
||||||
void *cmpl_context; /*!< Completion context of cleaning requester */
|
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;
|
ocf_cleaner_get_item getter;
|
||||||
/*!< Getter for collecting cache lines which will be cleaned */
|
/*!< Getter for collecting cache lines which will be cleaned */
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ocf/ocf.h"
|
#include "ocf/ocf.h"
|
||||||
|
#include "../ocf_priv.h"
|
||||||
#include "../ocf_cache_priv.h"
|
#include "../ocf_cache_priv.h"
|
||||||
#include "../ocf_data_obj_priv.h"
|
#include "../ocf_data_obj_priv.h"
|
||||||
#include "../ocf_request.h"
|
#include "../ocf_request.h"
|
||||||
@ -26,25 +27,9 @@ struct discard_io_request {
|
|||||||
int error;
|
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;
|
struct ocf_submit_io_wait_context *cntx = io->priv1;
|
||||||
|
|
||||||
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;
|
|
||||||
cntx->error = err;
|
cntx->error = err;
|
||||||
env_completion_complete(&cntx->complete);
|
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)
|
int ocf_submit_obj_flush_wait(ocf_data_obj_t obj)
|
||||||
{
|
{
|
||||||
struct ocf_submit_io_wait_context cntx = { };
|
struct ocf_submit_io_wait_context cntx = { };
|
||||||
|
struct ocf_io *io;
|
||||||
|
|
||||||
env_atomic_set(&cntx.rq_remaining, 1);
|
env_atomic_set(&cntx.rq_remaining, 1);
|
||||||
env_completion_init(&cntx.complete);
|
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);
|
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)
|
uint64_t length)
|
||||||
{
|
{
|
||||||
struct ocf_submit_io_wait_context cntx = { };
|
struct ocf_submit_io_wait_context cntx = { };
|
||||||
uint32_t bytes;
|
uint64_t bytes;
|
||||||
uint32_t max_length = ~0;
|
uint64_t max_length = (uint32_t)~0;
|
||||||
|
|
||||||
ENV_BUG_ON(env_memset(&cntx, sizeof(cntx), 0));
|
ENV_BUG_ON(env_memset(&cntx, sizeof(cntx), 0));
|
||||||
env_atomic_set(&cntx.rq_remaining, 1);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > max_length)
|
bytes = min(length, max_length);
|
||||||
bytes = max_length;
|
|
||||||
else
|
|
||||||
bytes = length;
|
|
||||||
|
|
||||||
env_atomic_inc(&cntx.rq_remaining);
|
env_atomic_inc(&cntx.rq_remaining);
|
||||||
|
|
||||||
@ -208,28 +199,17 @@ end:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_obj_discard(ocf_data_obj_t obj, struct ocf_request *req,
|
static void ocf_submit_obj_req_cmpl(struct ocf_io *io, int error)
|
||||||
ocf_end_t callback, void *ctx)
|
|
||||||
{
|
{
|
||||||
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(rq, error);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||||
struct ocf_map_info *map_info, struct ocf_request *req, int dir,
|
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;
|
struct ocf_counters_block *cache_stats;
|
||||||
uint64_t flags = req->io ? req->io->flags : 0;
|
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) {
|
if (reqs == 1) {
|
||||||
io = ocf_new_cache_io(cache);
|
io = ocf_new_cache_io(cache);
|
||||||
if (!io) {
|
if (!io) {
|
||||||
callback(ctx, -ENOMEM);
|
callback(req, -ENOMEM);
|
||||||
goto update_stats;
|
goto update_stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,12 +237,12 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
|||||||
bytes = req->byte_length;
|
bytes = req->byte_length;
|
||||||
|
|
||||||
ocf_io_configure(io, addr, bytes, dir, class, flags);
|
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);
|
err = ocf_io_set_data(io, req->data, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
ocf_io_put(io);
|
ocf_io_put(io);
|
||||||
callback(ctx, err);
|
callback(req, err);
|
||||||
goto update_stats;
|
goto update_stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +259,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
|||||||
if (!io) {
|
if (!io) {
|
||||||
/* Finish all IOs which left with ERROR */
|
/* Finish all IOs which left with ERROR */
|
||||||
for (; i < reqs; i++)
|
for (; i < reqs; i++)
|
||||||
callback(ctx, -ENOMEM);
|
callback(req, -ENOMEM);
|
||||||
goto update_stats;
|
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_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);
|
err = ocf_io_set_data(io, req->data, total_bytes);
|
||||||
if (err) {
|
if (err) {
|
||||||
ocf_io_put(io);
|
ocf_io_put(io);
|
||||||
/* Finish all IOs which left with ERROR */
|
/* Finish all IOs which left with ERROR */
|
||||||
for (; i < reqs; i++)
|
for (; i < reqs; i++)
|
||||||
callback(ctx, err);
|
callback(req, err);
|
||||||
goto update_stats;
|
goto update_stats;
|
||||||
}
|
}
|
||||||
ocf_dobj_submit_io(io);
|
ocf_dobj_submit_io(io);
|
||||||
@ -325,36 +305,37 @@ update_stats:
|
|||||||
env_atomic64_add(total_bytes, &cache_stats->read_bytes);
|
env_atomic64_add(total_bytes, &cache_stats->read_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *rq,
|
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)
|
||||||
{
|
{
|
||||||
struct ocf_cache *cache = rq->cache;
|
struct ocf_cache *cache = req->cache;
|
||||||
struct ocf_counters_block *core_stats;
|
struct ocf_counters_block *core_stats;
|
||||||
uint64_t flags = rq->io ? rq->io->flags : 0;
|
uint64_t flags = req->io ? req->io->flags : 0;
|
||||||
uint32_t class = rq->io ? rq->io->class : 0;
|
uint32_t class = req->io ? req->io->class : 0;
|
||||||
|
int dir = req->rw;
|
||||||
struct ocf_io *io;
|
struct ocf_io *io;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
core_stats = &cache->core_obj[rq->core_id].
|
core_stats = &cache->core_obj[req->core_id].
|
||||||
counters->core_blocks;
|
counters->core_blocks;
|
||||||
if (dir == OCF_WRITE)
|
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)
|
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);
|
io = ocf_dobj_new_io(obj);
|
||||||
if (!io) {
|
if (!io) {
|
||||||
callback(ctx, -ENOMEM);
|
callback(req, -ENOMEM);
|
||||||
return;
|
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);
|
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, rq->data, 0);
|
err = ocf_io_set_data(io, req->data, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
ocf_io_put(io);
|
ocf_io_put(io);
|
||||||
callback(ctx, err);
|
callback(req, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ocf_dobj_submit_io(io);
|
ocf_dobj_submit_io(io);
|
||||||
|
@ -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);
|
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_flush_wait(ocf_data_obj_t obj);
|
||||||
|
|
||||||
int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
|
int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
|
||||||
uint64_t length);
|
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,
|
int ocf_submit_write_zeroes_wait(ocf_data_obj_t obj, uint64_t addr,
|
||||||
uint64_t length);
|
uint64_t length);
|
||||||
|
|
||||||
@ -63,12 +57,12 @@ int ocf_submit_cache_page(struct ocf_cache *cache, uint64_t addr,
|
|||||||
int dir, void *buffer);
|
int dir, void *buffer);
|
||||||
|
|
||||||
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
|
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,
|
void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||||
struct ocf_map_info *map_info, struct ocf_request *req, int dir,
|
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)
|
static inline struct ocf_io *ocf_new_cache_io(struct ocf_cache *cache)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user