Single map alloc location

Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com>
This commit is contained in:
Kozlowski Mateusz 2021-07-20 11:55:19 +02:00
parent af1f3d73c2
commit bd7a89c819
4 changed files with 10 additions and 37 deletions

View File

@ -144,11 +144,6 @@ struct ocf_request *ocf_engine_pop_req(ocf_queue_t q)
OCF_CHECK_NULL(req); OCF_CHECK_NULL(req);
if (ocf_req_alloc_map(req)) {
req->complete(req, req->error);
return NULL;
}
return req; return req;
} }

View File

@ -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; struct ocf_event_io trace_event;
ocf_req_cache_mode_t original_cache_mode; ocf_req_cache_mode_t original_cache_mode;
int fast; int fast;
int ret;
if (req->d2c) { if (req->d2c) {
return -OCF_ERR_IO; return -OCF_ERR_IO;
} }
ret = ocf_req_alloc_map(req);
if (ret) {
return -OCF_ERR_IO;
}
original_cache_mode = req->cache_mode; original_cache_mode = req->cache_mode;
switch (req->cache_mode) { switch (req->cache_mode) {
case ocf_req_cache_mode_pt: case ocf_req_cache_mode_pt:
ret = -OCF_ERR_IO; return -OCF_ERR_IO;
goto map_allocated;
case ocf_req_cache_mode_wb: case ocf_req_cache_mode_wb:
case ocf_req_cache_mode_wo: case ocf_req_cache_mode_wo:
req->cache_mode = ocf_req_cache_mode_fast; 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; break;
if (io->dir == OCF_WRITE) if (io->dir == OCF_WRITE)
{ return -OCF_ERR_IO;
ret = -OCF_ERR_IO;
goto map_allocated;
}
req->cache_mode = ocf_req_cache_mode_fast; 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; req->cache_mode = original_cache_mode;
ret = -OCF_ERR_IO; return -OCF_ERR_IO;
map_allocated:
ocf_req_dealloc_map(req);
return ret;
} }
void ocf_core_volume_submit_io(struct ocf_io *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; 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->part_id = ocf_user_part_class2id(cache, io->io_class);
req->core = core; req->core = core;
req->complete = ocf_req_complete; req->complete = ocf_req_complete;
@ -323,6 +316,7 @@ void ocf_core_volume_submit_io(struct ocf_io *io)
return; return;
} }
ocf_req_clear_map(req);
ocf_core_seq_cutoff_update(core, req); ocf_core_seq_cutoff_update(core, req);
if (io->dir == OCF_WRITE) if (io->dir == OCF_WRITE)

View File

@ -153,15 +153,6 @@ int ocf_req_alloc_map(struct ocf_request *req)
return 0; 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) int ocf_req_alloc_map_discard(struct ocf_request *req)
{ {
ENV_BUILD_BUG_ON(MAX_TRIM_RQ_SIZE / ocf_cache_line_size_4 * ENV_BUILD_BUG_ON(MAX_TRIM_RQ_SIZE / ocf_cache_line_size_4 *

View File

@ -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); 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 * @brief Allocate OCF request map for discard request
* *