diff --git a/src/engine/cache_engine.c b/src/engine/cache_engine.c index c52ee53..1dac735 100644 --- a/src/engine/cache_engine.c +++ b/src/engine/cache_engine.c @@ -144,11 +144,6 @@ struct ocf_request *ocf_engine_pop_req(ocf_queue_t q) OCF_CHECK_NULL(req); - if (ocf_req_alloc_map(req)) { - req->complete(req, req->error); - return NULL; - } - return req; } diff --git a/src/ocf_core.c b/src/ocf_core.c index 3d3f551..38a3884 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -227,23 +227,16 @@ static int ocf_core_submit_io_fast(struct ocf_io *io, struct ocf_request *req, struct ocf_event_io trace_event; ocf_req_cache_mode_t original_cache_mode; int fast; - int ret; if (req->d2c) { return -OCF_ERR_IO; } - ret = ocf_req_alloc_map(req); - if (ret) { - return -OCF_ERR_IO; - } - original_cache_mode = req->cache_mode; switch (req->cache_mode) { case ocf_req_cache_mode_pt: - ret = -OCF_ERR_IO; - goto map_allocated; + return -OCF_ERR_IO; case ocf_req_cache_mode_wb: case ocf_req_cache_mode_wo: req->cache_mode = ocf_req_cache_mode_fast; @@ -253,10 +246,7 @@ static int ocf_core_submit_io_fast(struct ocf_io *io, struct ocf_request *req, break; if (io->dir == OCF_WRITE) - { - ret = -OCF_ERR_IO; - goto map_allocated; - } + return -OCF_ERR_IO; req->cache_mode = ocf_req_cache_mode_fast; } @@ -275,10 +265,7 @@ static int ocf_core_submit_io_fast(struct ocf_io *io, struct ocf_request *req, } req->cache_mode = original_cache_mode; - ret = -OCF_ERR_IO; -map_allocated: - ocf_req_dealloc_map(req); - return ret; + return -OCF_ERR_IO; } void ocf_core_volume_submit_io(struct ocf_io *io) @@ -308,6 +295,12 @@ void ocf_core_volume_submit_io(struct ocf_io *io) return; } + ret = ocf_req_alloc_map(req); + if (ret) { + ocf_io_end(io, ret); + return; + } + req->part_id = ocf_user_part_class2id(cache, io->io_class); req->core = core; req->complete = ocf_req_complete; @@ -323,6 +316,7 @@ void ocf_core_volume_submit_io(struct ocf_io *io) return; } + ocf_req_clear_map(req); ocf_core_seq_cutoff_update(core, req); if (io->dir == OCF_WRITE) diff --git a/src/ocf_request.c b/src/ocf_request.c index 2217ad2..5b55245 100644 --- a/src/ocf_request.c +++ b/src/ocf_request.c @@ -153,15 +153,6 @@ int ocf_req_alloc_map(struct ocf_request *req) return 0; } -void ocf_req_dealloc_map(struct ocf_request *req) -{ - if (req->map && req->map != req->__map) - { - env_free(req->map); - req->map = NULL; - } -} - int ocf_req_alloc_map_discard(struct ocf_request *req) { ENV_BUILD_BUG_ON(MAX_TRIM_RQ_SIZE / ocf_cache_line_size_4 * diff --git a/src/ocf_request.h b/src/ocf_request.h index 4a512d1..a624487 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -271,13 +271,6 @@ struct ocf_request *ocf_req_new(ocf_queue_t queue, ocf_core_t core, */ int ocf_req_alloc_map(struct ocf_request *req); -/** - * @brief Deallocate OCF request map, if it wasn't allocated from mpool - * - * @param req OCF request - */ -void ocf_req_dealloc_map(struct ocf_request *req); - /** * @brief Allocate OCF request map for discard request *