Merge new_io and configure into one function
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -199,7 +199,8 @@ static int ocf_metadata_read_sb(ocf_ctx_t ctx, ocf_volume_t volume,
|
||||
context->priv2 = priv2;
|
||||
|
||||
/* Allocate resources for IO */
|
||||
io = ocf_volume_new_io(volume);
|
||||
io = ocf_volume_new_io(volume, NULL, 0, sb_pages * PAGE_SIZE,
|
||||
OCF_READ, 0, 0);
|
||||
if (!io) {
|
||||
ocf_log(ctx, log_err, "Memory allocation error");
|
||||
result = -OCF_ERR_NO_MEM;
|
||||
@@ -224,8 +225,6 @@ static int ocf_metadata_read_sb(ocf_ctx_t ctx, ocf_volume_t volume,
|
||||
goto err_set_data;
|
||||
}
|
||||
|
||||
ocf_io_configure(io, 0, sb_pages * PAGE_SIZE, OCF_READ, 0, 0);
|
||||
|
||||
ocf_io_set_cmpl(io, context, NULL, ocf_metadata_read_sb_complete);
|
||||
ocf_volume_submit_io(io);
|
||||
|
||||
|
@@ -711,18 +711,16 @@ static int ocf_metadata_query_cores_io(ocf_volume_t volume,
|
||||
env_atomic_inc(&context->count);
|
||||
|
||||
/* Allocate new IO */
|
||||
io = ocf_volume_new_io(volume);
|
||||
io = ocf_volume_new_io(volume, NULL,
|
||||
PAGES_TO_BYTES(page),
|
||||
PAGES_TO_BYTES(num_pages),
|
||||
OCF_READ, 0, 0);
|
||||
if (!io) {
|
||||
err = -OCF_ERR_NO_MEM;
|
||||
goto exit_error;
|
||||
}
|
||||
|
||||
/* Setup IO */
|
||||
ocf_io_configure(io,
|
||||
PAGES_TO_BYTES(page),
|
||||
PAGES_TO_BYTES(num_pages),
|
||||
OCF_READ, 0, 0);
|
||||
|
||||
ocf_io_set_cmpl(io, context, NULL,
|
||||
ocf_metadata_query_cores_end_io);
|
||||
err = ocf_io_set_data(io, data, PAGES_TO_BYTES(offset));
|
||||
|
@@ -99,18 +99,17 @@ int metadata_io_read_i_atomic_step(struct ocf_request *req)
|
||||
ctx_data_seek(cache->owner, context->data, ctx_data_seek_begin, 0);
|
||||
|
||||
/* Allocate new IO */
|
||||
io = ocf_new_cache_io(cache);
|
||||
io = ocf_new_cache_io(cache, req->io_queue,
|
||||
cache->device->metadata_offset +
|
||||
SECTORS_TO_BYTES(context->curr_offset),
|
||||
SECTORS_TO_BYTES(context->curr_count), OCF_READ, 0, 0);
|
||||
|
||||
if (!io) {
|
||||
metadata_io_read_i_atomic_complete(context, -OCF_ERR_NO_MEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Setup IO */
|
||||
ocf_io_configure(io, cache->device->metadata_offset +
|
||||
SECTORS_TO_BYTES(context->curr_offset),
|
||||
SECTORS_TO_BYTES(context->curr_count), OCF_READ, 0, 0);
|
||||
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
ocf_io_set_cmpl(io, context, NULL, metadata_io_read_i_atomic_step_end);
|
||||
result = ocf_io_set_data(io, context->data, 0);
|
||||
if (result) {
|
||||
@@ -231,19 +230,16 @@ static int ocf_restart_meta_io(struct ocf_request *req)
|
||||
metadata_io_req_fill(meta_io_req);
|
||||
OCF_METADATA_UNLOCK_RD();
|
||||
|
||||
io = ocf_new_cache_io(cache);
|
||||
io = ocf_new_cache_io(cache, req->io_queue,
|
||||
PAGES_TO_BYTES(meta_io_req->page),
|
||||
PAGES_TO_BYTES(meta_io_req->count),
|
||||
OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
metadata_io_i_asynch_end(meta_io_req, -OCF_ERR_NO_MEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Setup IO */
|
||||
ocf_io_configure(io,
|
||||
PAGES_TO_BYTES(meta_io_req->page),
|
||||
PAGES_TO_BYTES(meta_io_req->count),
|
||||
OCF_WRITE, 0, 0);
|
||||
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
ocf_io_set_cmpl(io, meta_io_req, NULL, metadata_io_i_asynch_cmpl);
|
||||
ret = ocf_io_set_data(io, meta_io_req->data, 0);
|
||||
if (ret) {
|
||||
@@ -415,7 +411,10 @@ static int metadata_io_i_asynch(ocf_cache_t cache, ocf_queue_t queue, int dir,
|
||||
ret = metadata_updater_check_overlaps(cache, &a_req->reqs[i]);
|
||||
if (ret == 0) {
|
||||
/* Allocate new IO */
|
||||
io = ocf_new_cache_io(cache);
|
||||
io = ocf_new_cache_io(cache, queue,
|
||||
PAGES_TO_BYTES(a_req->reqs[i].page),
|
||||
PAGES_TO_BYTES(a_req->reqs[i].count),
|
||||
dir, 0, 0);
|
||||
if (!io) {
|
||||
error = -OCF_ERR_NO_MEM;
|
||||
metadata_io_req_error(cache, a_req, i, error);
|
||||
@@ -426,12 +425,6 @@ static int metadata_io_i_asynch(ocf_cache_t cache, ocf_queue_t queue, int dir,
|
||||
metadata_io_req_fill(&a_req->reqs[i]);
|
||||
|
||||
/* Setup IO */
|
||||
ocf_io_configure(io,
|
||||
PAGES_TO_BYTES(a_req->reqs[i].page),
|
||||
PAGES_TO_BYTES(a_req->reqs[i].count),
|
||||
dir, 0, 0);
|
||||
|
||||
ocf_io_set_queue(io, queue);
|
||||
ocf_io_set_cmpl(io, &a_req->reqs[i], NULL,
|
||||
metadata_io_i_asynch_cmpl);
|
||||
error = ocf_io_set_data(io, a_req->reqs[i].data, 0);
|
||||
|
@@ -70,8 +70,9 @@ static int _raw_atomic_io_discard_do(struct ocf_cache *cache, void *context,
|
||||
uint64_t start_addr, uint32_t len, struct _raw_atomic_flush_ctx *ctx)
|
||||
{
|
||||
struct ocf_request *req = context;
|
||||
struct ocf_io *io = ocf_new_cache_io(cache);
|
||||
struct ocf_io *io;
|
||||
|
||||
io = ocf_new_cache_io(cache, NULL, start_addr, len, OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
req->error = -OCF_ERR_NO_MEM;
|
||||
return req->error;
|
||||
@@ -82,7 +83,6 @@ static int _raw_atomic_io_discard_do(struct ocf_cache *cache, void *context,
|
||||
|
||||
env_atomic_inc(&ctx->flush_req_cnt);
|
||||
|
||||
ocf_io_configure(io, start_addr, len, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, ctx, NULL, _raw_atomic_io_discard_end);
|
||||
|
||||
if (cache->device->volume.features.discard_zeroes)
|
||||
|
@@ -336,7 +336,10 @@ static int raw_dynamic_load_all_read(struct ocf_request *req)
|
||||
count = OCF_MIN(RAW_DYNAMIC_LOAD_PAGES, raw->ssd_pages - context->i);
|
||||
|
||||
/* Allocate IO */
|
||||
context->io = ocf_new_cache_io(context->cache);
|
||||
context->io = ocf_new_cache_io(context->cache, req->io_queue,
|
||||
PAGES_TO_BYTES(raw->ssd_pages_offset + context->i),
|
||||
PAGES_TO_BYTES(count), OCF_READ, 0, 0);
|
||||
|
||||
if (!context->io) {
|
||||
raw_dynamic_load_all_complete(context, -OCF_ERR_NO_MEM);
|
||||
return 0;
|
||||
@@ -349,11 +352,6 @@ static int raw_dynamic_load_all_read(struct ocf_request *req)
|
||||
raw_dynamic_load_all_complete(context, result);
|
||||
return 0;
|
||||
}
|
||||
ocf_io_configure(context->io,
|
||||
PAGES_TO_BYTES(raw->ssd_pages_offset + context->i),
|
||||
PAGES_TO_BYTES(count), OCF_READ, 0, 0);
|
||||
|
||||
ocf_io_set_queue(context->io, req->io_queue);
|
||||
ocf_io_set_cmpl(context->io, context, NULL,
|
||||
raw_dynamic_load_all_read_end);
|
||||
|
||||
|
Reference in New Issue
Block a user