Remove legacy io completion API

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2018-12-12 09:19:34 +01:00
parent c0079e4d77
commit d862778e2b
32 changed files with 195 additions and 269 deletions

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);