Merge pull request #181 from micrakow/IO_err_codes

Error codes in IO path changed to OCF-specific
This commit is contained in:
Michał Wysoczański 2019-06-05 10:53:55 +02:00 committed by GitHub
commit cc3b38c9e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 111 additions and 91 deletions

View File

@ -18,22 +18,34 @@ typedef enum {
/** Invalid input parameter value */ /** Invalid input parameter value */
OCF_ERR_INVAL = 1000000, OCF_ERR_INVAL = 1000000,
/** Try again */
OCF_ERR_AGAIN,
/** Operation interrupted */ /** Operation interrupted */
OCF_ERR_INTR, OCF_ERR_INTR,
/** Operation not supported */
OCF_ERR_NOT_SUPP,
/** Out of memory */ /** Out of memory */
OCF_ERR_NO_MEM, OCF_ERR_NO_MEM,
/** Lock not acquired */ /** Lock not acquired */
OCF_ERR_NO_LOCK, OCF_ERR_NO_LOCK,
/** Metadata version mismatch */
OCF_ERR_METADATA_VER,
/** No metadata found on device */
OCF_ERR_NO_METADATA,
/** Invalid volume type */ /** Invalid volume type */
OCF_ERR_INVAL_VOLUME_TYPE, OCF_ERR_INVAL_VOLUME_TYPE,
/** Unknown error occurred */ /** Unknown error occurred */
OCF_ERR_UNKNOWN, OCF_ERR_UNKNOWN,
/*!< To many caches */ /** To many caches */
OCF_ERR_TOO_MANY_CACHES, OCF_ERR_TOO_MANY_CACHES,
/** Not enough RAM to start cache */ /** Not enough RAM to start cache */
@ -63,6 +75,9 @@ typedef enum {
/** IO Class does not exist */ /** IO Class does not exist */
OCF_ERR_IO_CLASS_NOT_EXIST, OCF_ERR_IO_CLASS_NOT_EXIST,
/** IO Error */
OCF_ERR_IO,
/** Error while writing to cache device */ /** Error while writing to cache device */
OCF_ERR_WRITE_CACHE, OCF_ERR_WRITE_CACHE,

View File

@ -701,7 +701,7 @@ int cleaning_policy_acp_add_core(ocf_cache_t cache,
if (!acp->chunk_info[core_id]) { if (!acp->chunk_info[core_id]) {
ACP_UNLOCK_CHUNKS_WR(); ACP_UNLOCK_CHUNKS_WR();
OCF_DEBUG_PARAM(cache, "failed to allocate acp tables\n"); OCF_DEBUG_PARAM(cache, "failed to allocate acp tables\n");
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
OCF_DEBUG_PARAM(cache, "successfully allocated acp tables\n"); OCF_DEBUG_PARAM(cache, "successfully allocated acp tables\n");

View File

@ -244,7 +244,7 @@ int ocf_engine_hndl_req(struct ocf_request *req,
req->io_if = ocf_get_io_if(req_cache_mode); req->io_if = ocf_get_io_if(req_cache_mode);
if (!req->io_if) if (!req->io_if)
return -EINVAL; return -OCF_ERR_INVAL;
/* Till OCF engine is not synchronous fully need to push OCF request /* Till OCF engine is not synchronous fully need to push OCF request
* to into OCF workers * to into OCF workers
@ -263,7 +263,7 @@ int ocf_engine_hndl_fast_req(struct ocf_request *req,
io_if = ocf_get_io_if(req_cache_mode); io_if = ocf_get_io_if(req_cache_mode);
if (!io_if) if (!io_if)
return -EINVAL; return -OCF_ERR_INVAL;
switch (req->rw) { switch (req->rw) {
case OCF_READ: case OCF_READ:

View File

@ -584,7 +584,7 @@ static int _ocf_engine_refresh(struct ocf_request *req)
ENV_BUG(); ENV_BUG();
} else { } else {
ENV_WARN(true, "Inconsistent request"); ENV_WARN(true, "Inconsistent request");
req->error = -EINVAL; req->error = -OCF_ERR_INVAL;
/* Complete request */ /* Complete request */
req->complete(req, req->error); req->complete(req, req->error);

View File

@ -71,8 +71,8 @@ static int _ocf_discard_core(struct ocf_request *req)
io = ocf_volume_new_io(&req->core->volume); io = ocf_volume_new_io(&req->core->volume);
if (!io) { if (!io) {
_ocf_discard_complete_req(req, -ENOMEM); _ocf_discard_complete_req(req, -OCF_ERR_NO_MEM);
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
ocf_io_configure(io, SECTORS_TO_BYTES(req->discard.sector), ocf_io_configure(io, SECTORS_TO_BYTES(req->discard.sector),
@ -112,8 +112,8 @@ static int _ocf_discard_flush_cache(struct ocf_request *req)
io = ocf_volume_new_io(&req->cache->device->volume); io = ocf_volume_new_io(&req->cache->device->volume);
if (!io) { if (!io) {
ocf_metadata_error(req->cache); ocf_metadata_error(req->cache);
_ocf_discard_complete_req(req, -ENOMEM); _ocf_discard_complete_req(req, -OCF_ERR_NO_MEM);
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0); ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
@ -261,7 +261,7 @@ int ocf_discard(struct ocf_request *req)
ocf_io_start(req->io); ocf_io_start(req->io);
if (req->rw == OCF_READ) { if (req->rw == OCF_READ) {
req->complete(req, -EINVAL); req->complete(req, -OCF_ERR_INVAL);
return 0; return 0;
} }

View File

@ -132,7 +132,7 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *req)
return; return;
err_alloc: err_alloc:
_ocf_read_generic_miss_complete(req, -ENOMEM); _ocf_read_generic_miss_complete(req, -OCF_ERR_NO_MEM);
} }
static int _ocf_read_generic_do(struct ocf_request *req) static int _ocf_read_generic_do(struct ocf_request *req)

View File

@ -190,7 +190,7 @@ static int ocf_metadata_read_sb(ocf_ctx_t ctx, ocf_volume_t volume,
context = env_zalloc(sizeof(*context), ENV_MEM_NORMAL); context = env_zalloc(sizeof(*context), ENV_MEM_NORMAL);
if (!context) { if (!context) {
ocf_log(ctx, log_err, "Memory allocation error"); ocf_log(ctx, log_err, "Memory allocation error");
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
context->cmpl = cmpl; context->cmpl = cmpl;
@ -202,14 +202,14 @@ static int ocf_metadata_read_sb(ocf_ctx_t ctx, ocf_volume_t volume,
io = ocf_volume_new_io(volume); io = ocf_volume_new_io(volume);
if (!io) { if (!io) {
ocf_log(ctx, log_err, "Memory allocation error"); ocf_log(ctx, log_err, "Memory allocation error");
result = -ENOMEM; result = -OCF_ERR_NO_MEM;
goto err_io; goto err_io;
} }
data = ctx_data_alloc(ctx, sb_pages); data = ctx_data_alloc(ctx, sb_pages);
if (!data) { if (!data) {
ocf_log(ctx, log_err, "Memory allocation error"); ocf_log(ctx, log_err, "Memory allocation error");
result = -ENOMEM; result = -OCF_ERR_NO_MEM;
goto err_data; goto err_data;
} }
@ -220,7 +220,7 @@ static int ocf_metadata_read_sb(ocf_ctx_t ctx, ocf_volume_t volume,
result = ocf_io_set_data(io, data, 0); result = ocf_io_set_data(io, data, 0);
if (result) { if (result) {
ocf_log(ctx, log_err, "Metadata IO configuration error\n"); ocf_log(ctx, log_err, "Metadata IO configuration error\n");
result = -EIO; result = -OCF_ERR_IO;
goto err_set_data; goto err_set_data;
} }
@ -251,37 +251,37 @@ static void ocf_metadata_load_properties_cmpl(
if (superblock->magic_number != CACHE_MAGIC_NUMBER) { if (superblock->magic_number != CACHE_MAGIC_NUMBER) {
ocf_log(ctx, log_info, "Cannot detect pre-existing metadata\n"); ocf_log(ctx, log_info, "Cannot detect pre-existing metadata\n");
OCF_CMPL_RET(priv, -ENODATA, NULL); OCF_CMPL_RET(priv, -OCF_ERR_NO_METADATA, NULL);
} }
if (METADATA_VERSION() != superblock->metadata_version) { if (METADATA_VERSION() != superblock->metadata_version) {
ocf_log(ctx, log_err, "Metadata version mismatch!\n"); ocf_log(ctx, log_err, "Metadata version mismatch!\n");
OCF_CMPL_RET(priv, -EBADF, NULL); OCF_CMPL_RET(priv, -OCF_ERR_METADATA_VER, NULL);
} }
if (!ocf_cache_line_size_is_valid(superblock->line_size)) { if (!ocf_cache_line_size_is_valid(superblock->line_size)) {
ocf_log(ctx, log_err, "ERROR: Invalid cache line size!\n"); ocf_log(ctx, log_err, "ERROR: Invalid cache line size!\n");
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
} }
if ((unsigned)superblock->metadata_layout >= ocf_metadata_layout_max) { if ((unsigned)superblock->metadata_layout >= ocf_metadata_layout_max) {
ocf_log(ctx, log_err, "ERROR: Invalid metadata layout!\n"); ocf_log(ctx, log_err, "ERROR: Invalid metadata layout!\n");
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
} }
if (superblock->cache_mode >= ocf_cache_mode_max) { if (superblock->cache_mode >= ocf_cache_mode_max) {
ocf_log(ctx, log_err, "ERROR: Invalid cache mode!\n"); ocf_log(ctx, log_err, "ERROR: Invalid cache mode!\n");
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
} }
if (superblock->clean_shutdown > ocf_metadata_clean_shutdown) { if (superblock->clean_shutdown > ocf_metadata_clean_shutdown) {
ocf_log(ctx, log_err, "ERROR: Invalid shutdown status!\n"); ocf_log(ctx, log_err, "ERROR: Invalid shutdown status!\n");
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
} }
if (superblock->dirty_flushed > DIRTY_FLUSHED) { if (superblock->dirty_flushed > DIRTY_FLUSHED) {
ocf_log(ctx, log_err, "ERROR: Invalid flush status!\n"); ocf_log(ctx, log_err, "ERROR: Invalid flush status!\n");
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
} }
properties.line_size = superblock->line_size; properties.line_size = superblock->line_size;
@ -314,16 +314,16 @@ static void ocf_metadata_probe_cmpl(struct ocf_metadata_read_sb_ctx *context)
void *priv = context->priv2; void *priv = context->priv2;
if (superblock->magic_number != CACHE_MAGIC_NUMBER) if (superblock->magic_number != CACHE_MAGIC_NUMBER)
OCF_CMPL_RET(priv, -ENODATA, NULL); OCF_CMPL_RET(priv, -OCF_ERR_NO_METADATA, NULL);
if (METADATA_VERSION() != superblock->metadata_version) if (METADATA_VERSION() != superblock->metadata_version)
OCF_CMPL_RET(priv, -EBADF, NULL); OCF_CMPL_RET(priv, -OCF_ERR_METADATA_VER, NULL);
if (superblock->clean_shutdown > ocf_metadata_clean_shutdown) if (superblock->clean_shutdown > ocf_metadata_clean_shutdown)
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
if (superblock->dirty_flushed > DIRTY_FLUSHED) if (superblock->dirty_flushed > DIRTY_FLUSHED)
OCF_CMPL_RET(priv, -EINVAL, NULL); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
status.clean_shutdown = (superblock->clean_shutdown != status.clean_shutdown = (superblock->clean_shutdown !=
ocf_metadata_dirty_shutdown); ocf_metadata_dirty_shutdown);

View File

@ -518,7 +518,7 @@ int ocf_metadata_hash_init(struct ocf_cache *cache,
ctrl = ocf_metadata_hash_ctrl_init(metadata->is_volatile); ctrl = ocf_metadata_hash_ctrl_init(metadata->is_volatile);
if (!ctrl) if (!ctrl)
return -ENOMEM; return -OCF_ERR_NO_MEM;
metadata->iface_priv = ctrl; metadata->iface_priv = ctrl;
for (i = 0; i < metadata_segment_fixed_size_max; i++) { for (i = 0; i < metadata_segment_fixed_size_max; i++) {
@ -634,7 +634,7 @@ static void ocf_metadata_query_cores_end(struct query_cores_context *context,
sizeof(context->superblock)); sizeof(context->superblock));
if (context->superblock.magic_number != CACHE_MAGIC_NUMBER) { if (context->superblock.magic_number != CACHE_MAGIC_NUMBER) {
error = -ENODATA; error = -OCF_ERR_NO_METADATA;
goto exit; goto exit;
} }
@ -663,11 +663,11 @@ static void ocf_metadata_query_cores_end(struct query_cores_context *context,
continue; continue;
if (muuid->size > OCF_VOLUME_UUID_MAX_SIZE) { if (muuid->size > OCF_VOLUME_UUID_MAX_SIZE) {
error = -EINVAL; error = -OCF_ERR_INVAL;
goto exit; goto exit;
} }
if (muuid->size > context->params.uuids[core_idx].size) { if (muuid->size > context->params.uuids[core_idx].size) {
error = -ENOSPC; error = -OCF_ERR_INVAL;
goto exit; goto exit;
} }
@ -762,7 +762,7 @@ int ocf_metadata_query_cores_segment_io(
segment_data->data = ctx_data_alloc(owner, segment_data->data = ctx_data_alloc(owner,
ctrl->raw_desc[segment].ssd_pages); ctrl->raw_desc[segment].ssd_pages);
if (!segment_data->data) { if (!segment_data->data) {
err = -ENOMEM; err = -OCF_ERR_NO_MEM;
goto exit; goto exit;
} }
@ -805,12 +805,12 @@ void ocf_metadata_hash_query_cores(ocf_ctx_t owner, ocf_volume_t volume,
int err; int err;
if (count > OCF_CORE_MAX) if (count > OCF_CORE_MAX)
OCF_CMPL_RET(priv, -EINVAL, 0); OCF_CMPL_RET(priv, -OCF_ERR_INVAL, 0);
/* intialize query context */ /* intialize query context */
context = env_secure_alloc(sizeof(*context)); context = env_secure_alloc(sizeof(*context));
if (!context) if (!context)
OCF_CMPL_RET(priv, -ENOMEM, 0); OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM, 0);
ENV_BUG_ON(env_memset(context, sizeof(*context), 0)); ENV_BUG_ON(env_memset(context, sizeof(*context), 0));
context->ctx = owner; context->ctx = owner;
@ -822,7 +822,7 @@ void ocf_metadata_hash_query_cores(ocf_ctx_t owner, ocf_volume_t volume,
ctrl = ocf_metadata_hash_ctrl_init(false); ctrl = ocf_metadata_hash_ctrl_init(false);
if (!ctrl) { if (!ctrl) {
err = -ENOMEM; err = -OCF_ERR_NO_MEM;
goto exit; goto exit;
} }
@ -989,7 +989,7 @@ finalize:
lg = ocf_metadata_map_phy2lg(cache, phy); lg = ocf_metadata_map_phy2lg(cache, phy);
if (line != lg) { if (line != lg) {
result = -EINVAL; result = -OCF_ERR_INVAL;
break; break;
} }
env_cond_resched(); env_cond_resched();

View File

@ -63,7 +63,7 @@ int ocf_metadata_actor(struct ocf_cache *cache,
if (_is_cache_line_acting(cache, i, core_id, if (_is_cache_line_acting(cache, i, core_id,
start_line, end_line)) { start_line, end_line)) {
if (ocf_cache_line_is_used(cache, i)) if (ocf_cache_line_is_used(cache, i))
ret = -EAGAIN; ret = -OCF_ERR_AGAIN;
else else
actor(cache, i); actor(cache, i);
} }
@ -75,7 +75,7 @@ int ocf_metadata_actor(struct ocf_cache *cache,
if (_is_cache_line_acting(cache, i, core_id, if (_is_cache_line_acting(cache, i, core_id,
start_line, end_line)) { start_line, end_line)) {
if (ocf_cache_line_is_used(cache, i)) if (ocf_cache_line_is_used(cache, i))
ret = -EAGAIN; ret = -OCF_ERR_AGAIN;
else else
actor(cache, i); actor(cache, i);
} }

View File

@ -102,7 +102,7 @@ static int _raw_ram_init(ocf_cache_t cache,
raw->mem_pool_limit = mem_pool_size; raw->mem_pool_limit = mem_pool_size;
raw->mem_pool = env_secure_alloc(mem_pool_size); raw->mem_pool = env_secure_alloc(mem_pool_size);
if (!raw->mem_pool) if (!raw->mem_pool)
return -ENOMEM; return -OCF_ERR_NO_MEM;
ENV_BUG_ON(env_memset(raw->mem_pool, mem_pool_size, 0)); ENV_BUG_ON(env_memset(raw->mem_pool, mem_pool_size, 0));
return 0; return 0;
@ -470,8 +470,8 @@ static int _raw_ram_flush_do_asynch(ocf_cache_t cache,
ctx = env_zalloc(sizeof(*ctx), ENV_MEM_NOIO); ctx = env_zalloc(sizeof(*ctx), ENV_MEM_NOIO);
if (!ctx) { if (!ctx) {
complete(req, -ENOMEM); complete(req, -OCF_ERR_NO_MEM);
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
ctx->req = req; ctx->req = req;
@ -485,8 +485,8 @@ static int _raw_ram_flush_do_asynch(ocf_cache_t cache,
pages_tab = env_zalloc(sizeof(*pages_tab) * line_no, ENV_MEM_NOIO); pages_tab = env_zalloc(sizeof(*pages_tab) * line_no, ENV_MEM_NOIO);
if (!pages_tab) { if (!pages_tab) {
env_free(ctx); env_free(ctx);
complete(req, -ENOMEM); complete(req, -OCF_ERR_NO_MEM);
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
} }

View File

@ -73,7 +73,7 @@ static int _raw_atomic_io_discard_do(struct ocf_cache *cache, void *context,
struct ocf_io *io = ocf_new_cache_io(cache); struct ocf_io *io = ocf_new_cache_io(cache);
if (!io) { if (!io) {
req->error = -ENOMEM; req->error = -OCF_ERR_NO_MEM;
return req->error; return req->error;
} }
@ -158,8 +158,8 @@ int raw_atomic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *req,
ctx = env_zalloc(sizeof(*ctx), ENV_MEM_NOIO); ctx = env_zalloc(sizeof(*ctx), ENV_MEM_NOIO);
if (!ctx) { if (!ctx) {
complete(req, -ENOMEM); complete(req, -OCF_ERR_NO_MEM);
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
ctx->req = req; ctx->req = req;
@ -182,9 +182,9 @@ int raw_atomic_flush_do_asynch(struct ocf_cache *cache, struct ocf_request *req,
clines_tab = env_zalloc(sizeof(*clines_tab) * line_no, clines_tab = env_zalloc(sizeof(*clines_tab) * line_no,
ENV_MEM_NOIO); ENV_MEM_NOIO);
if (!clines_tab) { if (!clines_tab) {
complete(req, -ENOMEM); complete(req, -OCF_ERR_NO_MEM);
env_free(ctx); env_free(ctx);
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
} }

View File

@ -564,5 +564,5 @@ int raw_dynamic_flush_do_asynch(ocf_cache_t cache, struct ocf_request *req,
struct ocf_metadata_raw *raw, ocf_req_end_t complete) struct ocf_metadata_raw *raw, ocf_req_end_t complete)
{ {
ENV_BUG(); ENV_BUG();
return -ENOSYS; return -OCF_ERR_NOT_SUPP;
} }

View File

@ -32,7 +32,7 @@ uint32_t raw_volatile_checksum(ocf_cache_t cache,
void raw_volatile_load_all(ocf_cache_t cache, struct ocf_metadata_raw *raw, void raw_volatile_load_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
ocf_metadata_end_t cmpl, void *priv) ocf_metadata_end_t cmpl, void *priv)
{ {
cmpl(priv, -ENOTSUP); cmpl(priv, -OCF_ERR_NOT_SUPP);
} }
/* /*

View File

@ -752,7 +752,7 @@ static void _ocf_mngt_test_volume_first_read_complete(void *priv, int error)
if (diff) { if (diff) {
/* we read back different data than what we had just /* we read back different data than what we had just
written - this is fatal error */ written - this is fatal error */
OCF_PL_FINISH_RET(context->test.pipeline, -EIO); OCF_PL_FINISH_RET(context->test.pipeline, -OCF_ERR_IO);
} }
if (!ocf_volume_is_atomic(&cache->device->volume)) { if (!ocf_volume_is_atomic(&cache->device->volume)) {

View File

@ -168,35 +168,35 @@ static inline int ocf_core_validate_io(struct ocf_io *io)
ocf_core_t core; ocf_core_t core;
if (!io->volume) if (!io->volume)
return -EINVAL; return -OCF_ERR_INVAL;
if (!io->ops) if (!io->ops)
return -EINVAL; return -OCF_ERR_INVAL;
if (io->addr >= ocf_volume_get_length(io->volume)) if (io->addr >= ocf_volume_get_length(io->volume))
return -EINVAL; return -OCF_ERR_INVAL;
if (io->addr + io->bytes > ocf_volume_get_length(io->volume)) if (io->addr + io->bytes > ocf_volume_get_length(io->volume))
return -EINVAL; return -OCF_ERR_INVAL;
if (io->io_class >= OCF_IO_CLASS_MAX) if (io->io_class >= OCF_IO_CLASS_MAX)
return -EINVAL; return -OCF_ERR_INVAL;
if (io->dir != OCF_READ && io->dir != OCF_WRITE) if (io->dir != OCF_READ && io->dir != OCF_WRITE)
return -EINVAL; return -OCF_ERR_INVAL;
if (!io->io_queue) if (!io->io_queue)
return -EINVAL; return -OCF_ERR_INVAL;
if (!io->end) if (!io->end)
return -EINVAL; return -OCF_ERR_INVAL;
/* Core volume I/O must not be queued on management queue - this would /* Core volume I/O must not be queued on management queue - this would
* break I/O accounting code, resulting in use-after-free type of errors * break I/O accounting code, resulting in use-after-free type of errors
* after cache detach, core remove etc. */ * after cache detach, core remove etc. */
core = ocf_volume_to_core(io->volume); core = ocf_volume_to_core(io->volume);
if (io->io_queue == ocf_core_get_cache(core)->mngt_queue) if (io->io_queue == ocf_core_get_cache(core)->mngt_queue)
return -EINVAL; return -OCF_ERR_INVAL;
return 0; return 0;
} }
@ -241,7 +241,7 @@ void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
if (unlikely(!env_bit_test(ocf_cache_state_running, if (unlikely(!env_bit_test(ocf_cache_state_running,
&cache->cache_state))) { &cache->cache_state))) {
ocf_io_end(io, -EIO); ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
return; return;
} }
@ -260,7 +260,7 @@ void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
io->dir); io->dir);
if (!core_io->req) { if (!core_io->req) {
dec_counter_if_req_was_dirty(core_io, cache); dec_counter_if_req_was_dirty(core_io, cache);
io->end(io, -ENOMEM); io->end(io, -OCF_ERR_NO_MEM);
return; return;
} }
@ -314,7 +314,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
if (unlikely(!env_bit_test(ocf_cache_state_running, if (unlikely(!env_bit_test(ocf_cache_state_running,
&cache->cache_state))) { &cache->cache_state))) {
ocf_io_end(io, -EIO); ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
return 0; return 0;
} }
@ -326,7 +326,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
switch (req_cache_mode) { switch (req_cache_mode) {
case ocf_req_cache_mode_pt: case ocf_req_cache_mode_pt:
return -EIO; return -OCF_ERR_IO;
case ocf_req_cache_mode_wb: case ocf_req_cache_mode_wb:
req_cache_mode = ocf_req_cache_mode_fast; req_cache_mode = ocf_req_cache_mode_fast;
break; break;
@ -334,7 +334,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
if (cache->use_submit_io_fast) if (cache->use_submit_io_fast)
break; break;
if (io->dir == OCF_WRITE) if (io->dir == OCF_WRITE)
return -EIO; return -OCF_ERR_IO;
req_cache_mode = ocf_req_cache_mode_fast; req_cache_mode = ocf_req_cache_mode_fast;
} }
@ -347,13 +347,13 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
if (!req) { if (!req) {
dec_counter_if_req_was_dirty(core_io, cache); dec_counter_if_req_was_dirty(core_io, cache);
io->end(io, -ENOMEM); io->end(io, -OCF_ERR_NO_MEM);
return 0; return 0;
} }
if (req->d2c) { if (req->d2c) {
dec_counter_if_req_was_dirty(core_io, cache); dec_counter_if_req_was_dirty(core_io, cache);
ocf_req_put(req); ocf_req_put(req);
return -EIO; return -OCF_ERR_IO;
} }
req->part_id = ocf_part_class2id(cache, io->io_class); req->part_id = ocf_part_class2id(cache, io->io_class);
@ -383,7 +383,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
ocf_io_put(io); ocf_io_put(io);
ocf_req_put(req); ocf_req_put(req);
return -EIO; return -OCF_ERR_IO;
} }
static void ocf_core_volume_submit_io(struct ocf_io *io) static void ocf_core_volume_submit_io(struct ocf_io *io)
@ -413,14 +413,14 @@ static void ocf_core_volume_submit_flush(struct ocf_io *io)
if (unlikely(!env_bit_test(ocf_cache_state_running, if (unlikely(!env_bit_test(ocf_cache_state_running,
&cache->cache_state))) { &cache->cache_state))) {
ocf_io_end(io, -EIO); ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
return; return;
} }
core_io->req = ocf_req_new(io->io_queue, core, io->addr, io->bytes, core_io->req = ocf_req_new(io->io_queue, core, io->addr, io->bytes,
io->dir); io->dir);
if (!core_io->req) { if (!core_io->req) {
ocf_io_end(io, -ENOMEM); ocf_io_end(io, -OCF_ERR_NO_MEM);
return; return;
} }
@ -455,14 +455,14 @@ static void ocf_core_volume_submit_discard(struct ocf_io *io)
if (unlikely(!env_bit_test(ocf_cache_state_running, if (unlikely(!env_bit_test(ocf_cache_state_running,
&cache->cache_state))) { &cache->cache_state))) {
ocf_io_end(io, -EIO); ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
return; return;
} }
core_io->req = ocf_req_new_discard(io->io_queue, core, core_io->req = ocf_req_new_discard(io->io_queue, core,
io->addr, io->bytes, OCF_WRITE); io->addr, io->bytes, OCF_WRITE);
if (!core_io->req) { if (!core_io->req) {
ocf_io_end(io, -ENOMEM); ocf_io_end(io, -OCF_ERR_NO_MEM);
return; return;
} }
@ -517,7 +517,7 @@ static int ocf_core_io_set_data(struct ocf_io *io,
OCF_CHECK_NULL(io); OCF_CHECK_NULL(io);
if (!data || offset) if (!data || offset)
return -EINVAL; return -OCF_ERR_INVAL;
core_io = ocf_io_to_core_io(io); core_io = ocf_io_to_core_io(io);
core_io->data = data; core_io->data = data;

View File

@ -31,7 +31,7 @@ int ocf_metadata_get_atomic_entry(ocf_cache_t cache,
OCF_CHECK_NULL(entry); OCF_CHECK_NULL(entry);
if (addr > ocf_volume_get_length(&cache->device->volume)) if (addr > ocf_volume_get_length(&cache->device->volume))
return -EFAULT; return -OCF_ERR_INVAL;
if (addr < cache->device->metadata_offset) { if (addr < cache->device->metadata_offset) {
/* Metadata IO of OCF */ /* Metadata IO of OCF */

View File

@ -211,8 +211,8 @@ int ocf_req_alloc_map(struct ocf_request *req)
req->map = env_zalloc(ocf_req_sizeof_map(req), ENV_MEM_NOIO); req->map = env_zalloc(ocf_req_sizeof_map(req), ENV_MEM_NOIO);
if (!req->map) { if (!req->map) {
req->error = -ENOMEM; req->error = -OCF_ERR_NO_MEM;
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
return 0; return 0;

View File

@ -189,7 +189,7 @@ struct ocf_request {
/*!< Detailed request info */ /*!< Detailed request info */
void (*complete)(struct ocf_request *ocf_req, int error); void (*complete)(struct ocf_request *ocf_req, int error);
/*!< Request completion funstion */ /*!< Request completion function */
struct ocf_io *io; struct ocf_io *io;
/*!< OCF IO associated with request */ /*!< OCF IO associated with request */

View File

@ -24,11 +24,11 @@ int ocf_volume_type_init(struct ocf_volume_type **type,
if (!ops->submit_io || !ops->open || !ops->close || if (!ops->submit_io || !ops->open || !ops->close ||
!ops->get_max_io_size || !ops->get_length) { !ops->get_max_io_size || !ops->get_length) {
return -EINVAL; return -OCF_ERR_INVAL;
} }
if (properties->caps.atomic_writes && !ops->submit_metadata) if (properties->caps.atomic_writes && !ops->submit_metadata)
return -EINVAL; return -OCF_ERR_INVAL;
new_type = env_zalloc(sizeof(**type), ENV_MEM_NORMAL); new_type = env_zalloc(sizeof(**type), ENV_MEM_NORMAL);
if (!new_type) if (!new_type)
@ -37,7 +37,7 @@ int ocf_volume_type_init(struct ocf_volume_type **type,
new_type->allocator = ocf_io_allocator_create( new_type->allocator = ocf_io_allocator_create(
properties->io_priv_size, properties->name); properties->io_priv_size, properties->name);
if (!new_type->allocator) { if (!new_type->allocator) {
ret = -ENOMEM; ret = -OCF_ERR_NO_MEM;
goto err; goto err;
} }
@ -234,7 +234,7 @@ void ocf_volume_submit_io(struct ocf_io *io)
ENV_BUG_ON(!io->volume->type->properties->ops.submit_io); ENV_BUG_ON(!io->volume->type->properties->ops.submit_io);
if (!io->volume->opened) if (!io->volume->opened)
io->end(io, -EIO); io->end(io, -OCF_ERR_IO);
io->volume->type->properties->ops.submit_io(io); io->volume->type->properties->ops.submit_io(io);
} }
@ -244,7 +244,7 @@ void ocf_volume_submit_flush(struct ocf_io *io)
ENV_BUG_ON(!io->volume->type->properties->ops.submit_flush); ENV_BUG_ON(!io->volume->type->properties->ops.submit_flush);
if (!io->volume->opened) if (!io->volume->opened)
io->end(io, -EIO); io->end(io, -OCF_ERR_IO);
if (!io->volume->type->properties->ops.submit_flush) { if (!io->volume->type->properties->ops.submit_flush) {
ocf_io_end(io, 0); ocf_io_end(io, 0);
@ -257,7 +257,7 @@ void ocf_volume_submit_flush(struct ocf_io *io)
void ocf_volume_submit_discard(struct ocf_io *io) void ocf_volume_submit_discard(struct ocf_io *io)
{ {
if (!io->volume->opened) if (!io->volume->opened)
io->end(io, -EIO); io->end(io, -OCF_ERR_IO);
if (!io->volume->type->properties->ops.submit_discard) { if (!io->volume->type->properties->ops.submit_discard) {
ocf_io_end(io, 0); ocf_io_end(io, 0);

View File

@ -163,7 +163,7 @@ static void _ocf_cleaner_set_error(struct ocf_request *req)
return; return;
} }
master->error = -EIO; master->error = -OCF_ERR_IO;
} }
static void _ocf_cleaner_complete_req(struct ocf_request *req) static void _ocf_cleaner_complete_req(struct ocf_request *req)
@ -273,8 +273,8 @@ static int _ocf_cleaner_fire_flush_cache(struct ocf_request *req)
io = ocf_volume_new_io(&req->cache->device->volume); io = ocf_volume_new_io(&req->cache->device->volume);
if (!io) { if (!io) {
ocf_metadata_error(req->cache); ocf_metadata_error(req->cache);
req->error = -ENOMEM; req->error = -OCF_ERR_NO_MEM;
return -ENOMEM; return -OCF_ERR_NO_MEM;
} }
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0); ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
@ -421,7 +421,7 @@ static int _ocf_cleaner_fire_flush_cores(struct ocf_request *req)
io = ocf_new_core_io(cache, core_id); io = ocf_new_core_io(cache, core_id);
if (!io) { if (!io) {
_ocf_cleaner_flush_cores_io_end(iter, req, -ENOMEM); _ocf_cleaner_flush_cores_io_end(iter, req, -OCF_ERR_NO_MEM);
continue; continue;
} }
@ -845,7 +845,7 @@ void ocf_cleaner_fire(struct ocf_cache *cache,
} }
if (!master) { if (!master) {
attribs->cmpl_fn(attribs->cmpl_context, -ENOMEM); attribs->cmpl_fn(attribs->cmpl_context, -OCF_ERR_NO_MEM);
return; return;
} }
@ -877,7 +877,7 @@ void ocf_cleaner_fire(struct ocf_cache *cache,
/* when request allocation failed stop processing */ /* when request allocation failed stop processing */
if (!req) { if (!req) {
master->error = -ENOMEM; master->error = -OCF_ERR_NO_MEM;
break; break;
} }

View File

@ -242,7 +242,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
if (reqs == 1) { if (reqs == 1) {
io = ocf_new_cache_io(cache); io = ocf_new_cache_io(cache);
if (!io) { if (!io) {
callback(req, -ENOMEM); callback(req, -OCF_ERR_NO_MEM);
goto update_stats; goto update_stats;
} }
@ -277,7 +277,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
if (!io) { if (!io) {
/* Finish all IOs which left with ERROR */ /* Finish all IOs which left with ERROR */
for (; i < reqs; i++) for (; i < reqs; i++)
callback(req, -ENOMEM); callback(req, -OCF_ERR_NO_MEM);
goto update_stats; goto update_stats;
} }
@ -342,7 +342,7 @@ void ocf_submit_volume_req(ocf_volume_t volume, struct ocf_request *req,
io = ocf_volume_new_io(volume); io = ocf_volume_new_io(volume);
if (!io) { if (!io) {
callback(req, -ENOMEM); callback(req, -OCF_ERR_NO_MEM);
return; return;
} }

View File

@ -13,9 +13,13 @@ from ..utils import Size as S
class OcfErrorCode(IntEnum): class OcfErrorCode(IntEnum):
OCF_ERR_INVAL = 1000000 OCF_ERR_INVAL = 1000000
OCF_ERR_AGAIN = auto()
OCF_ERR_INTR = auto() OCF_ERR_INTR = auto()
OCF_ERR_NOT_SUPP = auto()
OCF_ERR_NO_MEM = auto() OCF_ERR_NO_MEM = auto()
OCF_ERR_NO_LOCK = auto() OCF_ERR_NO_LOCK = auto()
OCF_ERR_METADATA_VER = auto()
OCF_ERR_NO_METADATA = auto()
OCF_ERR_INVAL_VOLUME_TYPE = auto() OCF_ERR_INVAL_VOLUME_TYPE = auto()
OCF_ERR_UNKNOWN = auto() OCF_ERR_UNKNOWN = auto()
OCF_ERR_TOO_MANY_CACHES = auto() OCF_ERR_TOO_MANY_CACHES = auto()
@ -28,6 +32,7 @@ class OcfErrorCode(IntEnum):
OCF_ERR_NOT_OPEN_EXC = auto() OCF_ERR_NOT_OPEN_EXC = auto()
OCF_ERR_CACHE_NOT_AVAIL = auto() OCF_ERR_CACHE_NOT_AVAIL = auto()
OCF_ERR_IO_CLASS_NOT_EXIST = auto() OCF_ERR_IO_CLASS_NOT_EXIST = auto()
OCF_ERR_IO = auto()
OCF_ERR_WRITE_CACHE = auto() OCF_ERR_WRITE_CACHE = auto()
OCF_ERR_WRITE_CORE = auto() OCF_ERR_WRITE_CORE = auto()
OCF_ERR_DIRTY_SHUTDOWN = auto() OCF_ERR_DIRTY_SHUTDOWN = auto()