Merge new_io and configure into one function
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -270,16 +270,14 @@ static int _ocf_cleaner_fire_flush_cache(struct ocf_request *req)
|
||||
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
|
||||
io = ocf_volume_new_io(&req->cache->device->volume);
|
||||
io = ocf_new_cache_io(req->cache, req->io_queue, 0, 0, OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
ocf_metadata_error(req->cache);
|
||||
req->error = -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_cleaner_flush_cache_io_end);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
|
||||
ocf_volume_submit_flush(io);
|
||||
|
||||
@@ -395,6 +393,7 @@ static int _ocf_cleaner_fire_flush_cores(struct ocf_request *req)
|
||||
ocf_core_id_t core_id = OCF_CORE_MAX;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
struct ocf_map_info *iter = req->map;
|
||||
ocf_core_t core;
|
||||
struct ocf_io *io;
|
||||
|
||||
OCF_DEBUG_TRACE(req->cache);
|
||||
@@ -419,15 +418,15 @@ static int _ocf_cleaner_fire_flush_cores(struct ocf_request *req)
|
||||
|
||||
env_atomic_inc(&req->req_remaining);
|
||||
|
||||
io = ocf_new_core_io(cache, core_id);
|
||||
core = ocf_cache_get_core(cache, core_id);
|
||||
io = ocf_new_core_io(core, req->io_queue, 0, 0,
|
||||
OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
_ocf_cleaner_flush_cores_io_end(iter, req, -OCF_ERR_NO_MEM);
|
||||
continue;
|
||||
}
|
||||
|
||||
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, iter, req, _ocf_cleaner_flush_cores_io_cmpl);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
|
||||
ocf_volume_submit_flush(io);
|
||||
}
|
||||
@@ -480,25 +479,24 @@ static void _ocf_cleaner_core_io_for_dirty_range(struct ocf_request *req,
|
||||
{
|
||||
uint64_t addr, offset;
|
||||
int err;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
ocf_cache_t cache = req->cache;
|
||||
ocf_core_t core = ocf_cache_get_core(cache, iter->core_id);
|
||||
struct ocf_io *io;
|
||||
struct ocf_counters_block *core_stats =
|
||||
&cache->core[iter->core_id].counters->core_blocks;
|
||||
ocf_part_id_t part_id = ocf_metadata_get_partition_id(cache,
|
||||
iter->coll_idx);
|
||||
|
||||
io = ocf_new_core_io(cache, iter->core_id);
|
||||
if (!io)
|
||||
goto error;
|
||||
|
||||
addr = (ocf_line_size(cache) * iter->core_line)
|
||||
+ SECTORS_TO_BYTES(begin);
|
||||
offset = (ocf_line_size(cache) * iter->hash_key)
|
||||
+ SECTORS_TO_BYTES(begin);
|
||||
|
||||
ocf_io_configure(io, addr, SECTORS_TO_BYTES(end - begin), OCF_WRITE,
|
||||
part_id, 0);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
io = ocf_new_core_io(core, req->io_queue, addr,
|
||||
SECTORS_TO_BYTES(end - begin), OCF_WRITE, part_id, 0);
|
||||
if (!io)
|
||||
goto error;
|
||||
|
||||
err = ocf_io_set_data(io, req->data, offset);
|
||||
if (err) {
|
||||
ocf_io_put(io);
|
||||
@@ -660,7 +658,9 @@ static int _ocf_cleaner_fire_cache(struct ocf_request *req)
|
||||
cache_stats = &cache->core[iter->core_id].
|
||||
counters->cache_blocks;
|
||||
|
||||
io = ocf_new_cache_io(cache);
|
||||
io = ocf_new_cache_io(cache, req->io_queue,
|
||||
addr, ocf_line_size(cache),
|
||||
OCF_READ, part_id, 0);
|
||||
if (!io) {
|
||||
/* Allocation error */
|
||||
iter->invalid = true;
|
||||
@@ -681,9 +681,6 @@ static int _ocf_cleaner_fire_cache(struct ocf_request *req)
|
||||
part_id = ocf_metadata_get_partition_id(cache, iter->coll_idx);
|
||||
|
||||
ocf_io_set_cmpl(io, iter, req, _ocf_cleaner_cache_io_cmpl);
|
||||
ocf_io_configure(io, addr, ocf_line_size(cache), OCF_READ,
|
||||
part_id, 0);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
err = ocf_io_set_data(io, req->data, offset);
|
||||
if (err) {
|
||||
ocf_io_put(io);
|
||||
|
@@ -31,11 +31,10 @@ void ocf_submit_volume_flush(ocf_volume_t volume,
|
||||
{
|
||||
struct ocf_io *io;
|
||||
|
||||
io = ocf_volume_new_io(volume);
|
||||
io = ocf_volume_new_io(volume, NULL, 0, 0, OCF_WRITE, 0, 0);
|
||||
if (!io)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, cmpl, priv, _ocf_volume_flush_end);
|
||||
|
||||
ocf_volume_submit_flush(io);
|
||||
@@ -74,7 +73,10 @@ void ocf_submit_volume_discard(ocf_volume_t volume, uint64_t addr,
|
||||
context->priv = priv;
|
||||
|
||||
while (length) {
|
||||
io = ocf_volume_new_io(volume);
|
||||
bytes = OCF_MIN(length, max_length);
|
||||
|
||||
io = ocf_volume_new_io(volume, NULL, addr, bytes,
|
||||
OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
context->error = -OCF_ERR_NO_MEM;
|
||||
break;
|
||||
@@ -82,9 +84,6 @@ void ocf_submit_volume_discard(ocf_volume_t volume, uint64_t addr,
|
||||
|
||||
env_atomic_inc(&context->req_remaining);
|
||||
|
||||
bytes = OCF_MIN(length, max_length);
|
||||
|
||||
ocf_io_configure(io, addr, bytes, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, context, NULL, ocf_submit_volume_end);
|
||||
ocf_volume_submit_discard(io);
|
||||
|
||||
@@ -116,7 +115,10 @@ void ocf_submit_write_zeros(ocf_volume_t volume, uint64_t addr,
|
||||
context->priv = priv;
|
||||
|
||||
while (length) {
|
||||
io = ocf_volume_new_io(volume);
|
||||
bytes = OCF_MIN(length, max_length);
|
||||
|
||||
io = ocf_volume_new_io(volume, NULL, addr, bytes,
|
||||
OCF_WRITE, 0, 0);
|
||||
if (!io) {
|
||||
context->error = -OCF_ERR_NO_MEM;
|
||||
break;
|
||||
@@ -124,9 +126,6 @@ void ocf_submit_write_zeros(ocf_volume_t volume, uint64_t addr,
|
||||
|
||||
env_atomic_inc(&context->req_remaining);
|
||||
|
||||
bytes = OCF_MIN(length, max_length);
|
||||
|
||||
ocf_io_configure(io, addr, bytes, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, context, NULL, ocf_submit_volume_end);
|
||||
ocf_volume_submit_write_zeroes(io);
|
||||
|
||||
@@ -181,7 +180,7 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
||||
context->cmpl = cmpl;
|
||||
context->priv = priv;
|
||||
|
||||
io = ocf_volume_new_io(&cache->device->volume);
|
||||
io = ocf_new_cache_io(cache, NULL, addr, PAGE_SIZE, dir, 0, 0);
|
||||
if (!io) {
|
||||
result = -OCF_ERR_NO_MEM;
|
||||
goto err_io;
|
||||
@@ -200,7 +199,6 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
||||
if (result)
|
||||
goto err_set_data;
|
||||
|
||||
ocf_io_configure(io, addr, PAGE_SIZE, dir, 0, 0);
|
||||
ocf_io_set_cmpl(io, context, NULL, ocf_submit_cache_page_end);
|
||||
|
||||
ocf_volume_submit_io(io);
|
||||
@@ -245,12 +243,6 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
cache_stats = &req->core->counters->cache_blocks;
|
||||
|
||||
if (reqs == 1) {
|
||||
io = ocf_new_cache_io(cache);
|
||||
if (!io) {
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
goto update_stats;
|
||||
}
|
||||
|
||||
addr = ocf_metadata_map_lg2phy(cache,
|
||||
req->map[first_cl].coll_idx);
|
||||
addr *= ocf_line_size(cache);
|
||||
@@ -258,8 +250,13 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
addr += ((req->byte_position + offset) % ocf_line_size(cache));
|
||||
bytes = size;
|
||||
|
||||
ocf_io_configure(io, addr, bytes, dir, class, flags);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
io = ocf_new_cache_io(cache, req->io_queue,
|
||||
addr, bytes, dir, class, flags);
|
||||
if (!io) {
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
goto update_stats;
|
||||
}
|
||||
|
||||
ocf_io_set_cmpl(io, req, callback, ocf_submit_volume_req_cmpl);
|
||||
|
||||
err = ocf_io_set_data(io, req->data, offset);
|
||||
@@ -277,15 +274,6 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
|
||||
/* Issue requests to cache. */
|
||||
for (i = 0; i < reqs; i++) {
|
||||
io = ocf_new_cache_io(cache);
|
||||
|
||||
if (!io) {
|
||||
/* Finish all IOs which left with ERROR */
|
||||
for (; i < reqs; i++)
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
goto update_stats;
|
||||
}
|
||||
|
||||
addr = ocf_metadata_map_lg2phy(cache,
|
||||
req->map[first_cl + i].coll_idx);
|
||||
addr *= ocf_line_size(cache);
|
||||
@@ -309,8 +297,15 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
bytes = OCF_MIN(bytes, size - total_bytes);
|
||||
ENV_BUG_ON(bytes == 0);
|
||||
|
||||
ocf_io_configure(io, addr, bytes, dir, class, flags);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
io = ocf_new_cache_io(cache, req->io_queue,
|
||||
addr, bytes, dir, class, flags);
|
||||
if (!io) {
|
||||
/* Finish all IOs which left with ERROR */
|
||||
for (; i < reqs; i++)
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
goto update_stats;
|
||||
}
|
||||
|
||||
ocf_io_set_cmpl(io, req, callback, ocf_submit_volume_req_cmpl);
|
||||
|
||||
err = ocf_io_set_data(io, req->data, offset + total_bytes);
|
||||
@@ -350,15 +345,13 @@ void ocf_submit_volume_req(ocf_volume_t volume, struct ocf_request *req,
|
||||
else if (dir == OCF_READ)
|
||||
env_atomic64_add(req->byte_length, &core_stats->read_bytes);
|
||||
|
||||
io = ocf_volume_new_io(volume);
|
||||
io = ocf_volume_new_io(volume, req->io_queue, req->byte_position,
|
||||
req->byte_length, dir, class, flags);
|
||||
if (!io) {
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
|
||||
ocf_io_configure(io, req->byte_position, req->byte_length, dir,
|
||||
class, flags);
|
||||
ocf_io_set_queue(io, req->io_queue);
|
||||
ocf_io_set_cmpl(io, req, callback, ocf_submit_volume_req_cmpl);
|
||||
err = ocf_io_set_data(io, req->data, 0);
|
||||
if (err) {
|
||||
|
@@ -64,17 +64,21 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
struct ocf_request *req, int dir, uint64_t offset,
|
||||
uint64_t size, unsigned int reqs, ocf_req_end_t callback);
|
||||
|
||||
static inline struct ocf_io *ocf_new_cache_io(struct ocf_cache *cache)
|
||||
static inline struct ocf_io *ocf_new_cache_io(ocf_cache_t cache,
|
||||
ocf_queue_t queue, uint64_t addr, uint32_t bytes,
|
||||
uint32_t dir, uint32_t io_class, uint64_t flags)
|
||||
|
||||
{
|
||||
return ocf_volume_new_io(&cache->device->volume);
|
||||
return ocf_volume_new_io(ocf_cache_get_volume(cache), queue,
|
||||
addr, bytes, dir, io_class, flags);
|
||||
}
|
||||
|
||||
static inline struct ocf_io *ocf_new_core_io(struct ocf_cache *cache,
|
||||
ocf_core_id_t core_id)
|
||||
static inline struct ocf_io *ocf_new_core_io(ocf_core_t core,
|
||||
ocf_queue_t queue, uint64_t addr, uint32_t bytes,
|
||||
uint32_t dir, uint32_t io_class, uint64_t flags)
|
||||
{
|
||||
ENV_BUG_ON(core_id >= OCF_CORE_MAX);
|
||||
|
||||
return ocf_volume_new_io(&cache->core[core_id].volume);
|
||||
return ocf_volume_new_io(ocf_core_get_volume(core), queue,
|
||||
addr, bytes, dir, io_class, flags);
|
||||
}
|
||||
|
||||
#endif /* UTILS_IO_H_ */
|
||||
|
Reference in New Issue
Block a user