Merge pull request #216 from robertbaldyga/io-and-req-in-single-allocation
Allocate io and req in single allocation
This commit is contained in:
@@ -254,6 +254,8 @@ int ocf_engine_hndl_req(struct ocf_request *req,
|
||||
if (!req->io_if)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
ocf_req_get(req);
|
||||
|
||||
/* Till OCF engine is not synchronous fully need to push OCF request
|
||||
* to into OCF workers
|
||||
*/
|
||||
@@ -273,6 +275,8 @@ int ocf_engine_hndl_fast_req(struct ocf_request *req,
|
||||
if (!io_if)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
ocf_req_get(req);
|
||||
|
||||
switch (req->rw) {
|
||||
case OCF_READ:
|
||||
ret = io_if->read(req);
|
||||
@@ -281,9 +285,12 @@ int ocf_engine_hndl_fast_req(struct ocf_request *req,
|
||||
ret = io_if->write(req);
|
||||
break;
|
||||
default:
|
||||
return OCF_FAST_PATH_NO;
|
||||
ret = OCF_FAST_PATH_NO;
|
||||
}
|
||||
|
||||
if (ret == OCF_FAST_PATH_NO)
|
||||
ocf_req_put(req);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -299,6 +306,8 @@ static void ocf_engine_hndl_2dc_req(struct ocf_request *req)
|
||||
|
||||
void ocf_engine_hndl_discard_req(struct ocf_request *req)
|
||||
{
|
||||
ocf_req_get(req);
|
||||
|
||||
if (req->d2c) {
|
||||
ocf_engine_hndl_2dc_req(req);
|
||||
return;
|
||||
@@ -314,6 +323,8 @@ void ocf_engine_hndl_discard_req(struct ocf_request *req)
|
||||
|
||||
void ocf_engine_hndl_ops_req(struct ocf_request *req)
|
||||
{
|
||||
ocf_req_get(req);
|
||||
|
||||
if (req->d2c)
|
||||
req->io_if = &IO_IFS[OCF_IO_D2C_IF];
|
||||
else
|
||||
|
@@ -42,7 +42,7 @@ int ocf_io_d2c(struct ocf_request *req)
|
||||
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Get OCF request - increase reference counter */
|
||||
ocf_req_get(req);
|
||||
|
@@ -71,19 +71,17 @@ static int _ocf_discard_core(struct ocf_request *req)
|
||||
{
|
||||
struct ocf_io *io;
|
||||
|
||||
io = ocf_volume_new_io(&req->core->volume);
|
||||
io = ocf_volume_new_io(&req->core->volume, req->io_queue,
|
||||
SECTORS_TO_BYTES(req->discard.sector),
|
||||
SECTORS_TO_BYTES(req->discard.nr_sects),
|
||||
OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
_ocf_discard_complete_req(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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_complete);
|
||||
ocf_io_set_data(io, req->data, 0);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
|
||||
ocf_volume_submit_discard(io);
|
||||
|
||||
@@ -111,16 +109,15 @@ static int _ocf_discard_flush_cache(struct ocf_request *req)
|
||||
{
|
||||
struct ocf_io *io;
|
||||
|
||||
io = ocf_volume_new_io(&req->cache->device->volume);
|
||||
io = ocf_volume_new_io(&req->cache->device->volume, req->io_queue,
|
||||
0, 0, OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
ocf_metadata_error(req->cache);
|
||||
_ocf_discard_complete_req(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, req, NULL, _ocf_discard_cache_flush_complete);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
|
||||
ocf_volume_submit_flush(io);
|
||||
|
||||
@@ -260,7 +257,7 @@ int ocf_discard(struct ocf_request *req)
|
||||
{
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
if (req->rw == OCF_READ) {
|
||||
req->complete(req, -OCF_ERR_INVAL);
|
||||
|
@@ -128,7 +128,7 @@ int ocf_read_fast(struct ocf_request *req)
|
||||
|
||||
hit = ocf_engine_is_hit(req);
|
||||
if (hit) {
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
lock = ocf_req_trylock_rd(req);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ int ocf_write_fast(struct ocf_request *req)
|
||||
|
||||
mapped = ocf_engine_is_mapped(req);
|
||||
if (mapped) {
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
lock = ocf_req_trylock_wr(req);
|
||||
}
|
||||
|
||||
|
@@ -110,7 +110,7 @@ int ocf_read_pt(struct ocf_request *req)
|
||||
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Get OCF request - increase reference counter */
|
||||
ocf_req_get(req);
|
||||
|
@@ -217,7 +217,7 @@ int ocf_read_generic(struct ocf_request *req)
|
||||
int lock = OCF_LOCK_NOT_ACQUIRED;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
if (env_atomic_read(&cache->pending_read_misses_list_blocked)) {
|
||||
/* There are conditions to bypass IO */
|
||||
|
@@ -40,7 +40,7 @@ int ocf_write_wa(struct ocf_request *req)
|
||||
{
|
||||
struct ocf_cache *cache = req->cache;
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Get OCF request - increase reference counter */
|
||||
ocf_req_get(req);
|
||||
|
@@ -172,7 +172,7 @@ int ocf_write_wb(struct ocf_request *req)
|
||||
int lock = OCF_LOCK_NOT_ACQUIRED;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Not sure if we need this. */
|
||||
ocf_req_get(req);
|
||||
|
@@ -140,7 +140,7 @@ int ocf_write_wi(struct ocf_request *req)
|
||||
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Get OCF request - increase reference counter */
|
||||
ocf_req_get(req);
|
||||
|
@@ -207,7 +207,7 @@ int ocf_read_wo(struct ocf_request *req)
|
||||
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Get OCF request - increase reference counter */
|
||||
ocf_req_get(req);
|
||||
|
@@ -167,7 +167,7 @@ int ocf_write_wt(struct ocf_request *req)
|
||||
int lock = OCF_LOCK_NOT_ACQUIRED;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
|
||||
ocf_io_start(req->io);
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
/* Get OCF request - increase reference counter */
|
||||
ocf_req_get(req);
|
||||
|
Reference in New Issue
Block a user