Merge pull request #181 from micrakow/IO_err_codes
Error codes in IO path changed to OCF-specific
This commit is contained in:
commit
cc3b38c9e3
@ -18,22 +18,34 @@ typedef enum {
|
||||
/** Invalid input parameter value */
|
||||
OCF_ERR_INVAL = 1000000,
|
||||
|
||||
/** Try again */
|
||||
OCF_ERR_AGAIN,
|
||||
|
||||
/** Operation interrupted */
|
||||
OCF_ERR_INTR,
|
||||
|
||||
/** Operation not supported */
|
||||
OCF_ERR_NOT_SUPP,
|
||||
|
||||
/** Out of memory */
|
||||
OCF_ERR_NO_MEM,
|
||||
|
||||
/** Lock not acquired */
|
||||
OCF_ERR_NO_LOCK,
|
||||
|
||||
/** Metadata version mismatch */
|
||||
OCF_ERR_METADATA_VER,
|
||||
|
||||
/** No metadata found on device */
|
||||
OCF_ERR_NO_METADATA,
|
||||
|
||||
/** Invalid volume type */
|
||||
OCF_ERR_INVAL_VOLUME_TYPE,
|
||||
|
||||
/** Unknown error occurred */
|
||||
OCF_ERR_UNKNOWN,
|
||||
|
||||
/*!< To many caches */
|
||||
/** To many caches */
|
||||
OCF_ERR_TOO_MANY_CACHES,
|
||||
|
||||
/** Not enough RAM to start cache */
|
||||
@ -63,6 +75,9 @@ typedef enum {
|
||||
/** IO Class does not exist */
|
||||
OCF_ERR_IO_CLASS_NOT_EXIST,
|
||||
|
||||
/** IO Error */
|
||||
OCF_ERR_IO,
|
||||
|
||||
/** Error while writing to cache device */
|
||||
OCF_ERR_WRITE_CACHE,
|
||||
|
||||
|
@ -701,7 +701,7 @@ int cleaning_policy_acp_add_core(ocf_cache_t cache,
|
||||
if (!acp->chunk_info[core_id]) {
|
||||
ACP_UNLOCK_CHUNKS_WR();
|
||||
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");
|
||||
|
@ -244,7 +244,7 @@ int ocf_engine_hndl_req(struct ocf_request *req,
|
||||
|
||||
req->io_if = ocf_get_io_if(req_cache_mode);
|
||||
if (!req->io_if)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
/* Till OCF engine is not synchronous fully need to push OCF request
|
||||
* 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);
|
||||
if (!io_if)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
switch (req->rw) {
|
||||
case OCF_READ:
|
||||
|
@ -584,7 +584,7 @@ static int _ocf_engine_refresh(struct ocf_request *req)
|
||||
ENV_BUG();
|
||||
} else {
|
||||
ENV_WARN(true, "Inconsistent request");
|
||||
req->error = -EINVAL;
|
||||
req->error = -OCF_ERR_INVAL;
|
||||
|
||||
/* Complete request */
|
||||
req->complete(req, req->error);
|
||||
|
@ -71,8 +71,8 @@ static int _ocf_discard_core(struct ocf_request *req)
|
||||
|
||||
io = ocf_volume_new_io(&req->core->volume);
|
||||
if (!io) {
|
||||
_ocf_discard_complete_req(req, -ENOMEM);
|
||||
return -ENOMEM;
|
||||
_ocf_discard_complete_req(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!io) {
|
||||
ocf_metadata_error(req->cache);
|
||||
_ocf_discard_complete_req(req, -ENOMEM);
|
||||
return -ENOMEM;
|
||||
_ocf_discard_complete_req(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (req->rw == OCF_READ) {
|
||||
req->complete(req, -EINVAL);
|
||||
req->complete(req, -OCF_ERR_INVAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *req)
|
||||
return;
|
||||
|
||||
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)
|
||||
|
@ -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);
|
||||
if (!context) {
|
||||
ocf_log(ctx, log_err, "Memory allocation error");
|
||||
return -ENOMEM;
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!io) {
|
||||
ocf_log(ctx, log_err, "Memory allocation error");
|
||||
result = -ENOMEM;
|
||||
result = -OCF_ERR_NO_MEM;
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
data = ctx_data_alloc(ctx, sb_pages);
|
||||
if (!data) {
|
||||
ocf_log(ctx, log_err, "Memory allocation error");
|
||||
result = -ENOMEM;
|
||||
result = -OCF_ERR_NO_MEM;
|
||||
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);
|
||||
if (result) {
|
||||
ocf_log(ctx, log_err, "Metadata IO configuration error\n");
|
||||
result = -EIO;
|
||||
result = -OCF_ERR_IO;
|
||||
goto err_set_data;
|
||||
}
|
||||
|
||||
@ -251,37 +251,37 @@ static void ocf_metadata_load_properties_cmpl(
|
||||
|
||||
if (superblock->magic_number != CACHE_MAGIC_NUMBER) {
|
||||
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) {
|
||||
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)) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
@ -314,16 +314,16 @@ static void ocf_metadata_probe_cmpl(struct ocf_metadata_read_sb_ctx *context)
|
||||
void *priv = context->priv2;
|
||||
|
||||
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)
|
||||
OCF_CMPL_RET(priv, -EBADF, NULL);
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_METADATA_VER, NULL);
|
||||
|
||||
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)
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
|
||||
|
||||
status.clean_shutdown = (superblock->clean_shutdown !=
|
||||
ocf_metadata_dirty_shutdown);
|
||||
|
@ -518,7 +518,7 @@ int ocf_metadata_hash_init(struct ocf_cache *cache,
|
||||
|
||||
ctrl = ocf_metadata_hash_ctrl_init(metadata->is_volatile);
|
||||
if (!ctrl)
|
||||
return -ENOMEM;
|
||||
return -OCF_ERR_NO_MEM;
|
||||
metadata->iface_priv = ctrl;
|
||||
|
||||
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));
|
||||
|
||||
if (context->superblock.magic_number != CACHE_MAGIC_NUMBER) {
|
||||
error = -ENODATA;
|
||||
error = -OCF_ERR_NO_METADATA;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -663,11 +663,11 @@ static void ocf_metadata_query_cores_end(struct query_cores_context *context,
|
||||
continue;
|
||||
|
||||
if (muuid->size > OCF_VOLUME_UUID_MAX_SIZE) {
|
||||
error = -EINVAL;
|
||||
error = -OCF_ERR_INVAL;
|
||||
goto exit;
|
||||
}
|
||||
if (muuid->size > context->params.uuids[core_idx].size) {
|
||||
error = -ENOSPC;
|
||||
error = -OCF_ERR_INVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -762,7 +762,7 @@ int ocf_metadata_query_cores_segment_io(
|
||||
segment_data->data = ctx_data_alloc(owner,
|
||||
ctrl->raw_desc[segment].ssd_pages);
|
||||
if (!segment_data->data) {
|
||||
err = -ENOMEM;
|
||||
err = -OCF_ERR_NO_MEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -805,12 +805,12 @@ void ocf_metadata_hash_query_cores(ocf_ctx_t owner, ocf_volume_t volume,
|
||||
int err;
|
||||
|
||||
if (count > OCF_CORE_MAX)
|
||||
OCF_CMPL_RET(priv, -EINVAL, 0);
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_INVAL, 0);
|
||||
|
||||
/* intialize query context */
|
||||
context = env_secure_alloc(sizeof(*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));
|
||||
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);
|
||||
if (!ctrl) {
|
||||
err = -ENOMEM;
|
||||
err = -OCF_ERR_NO_MEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -989,7 +989,7 @@ finalize:
|
||||
lg = ocf_metadata_map_phy2lg(cache, phy);
|
||||
|
||||
if (line != lg) {
|
||||
result = -EINVAL;
|
||||
result = -OCF_ERR_INVAL;
|
||||
break;
|
||||
}
|
||||
env_cond_resched();
|
||||
|
@ -63,7 +63,7 @@ int ocf_metadata_actor(struct ocf_cache *cache,
|
||||
if (_is_cache_line_acting(cache, i, core_id,
|
||||
start_line, end_line)) {
|
||||
if (ocf_cache_line_is_used(cache, i))
|
||||
ret = -EAGAIN;
|
||||
ret = -OCF_ERR_AGAIN;
|
||||
else
|
||||
actor(cache, i);
|
||||
}
|
||||
@ -75,7 +75,7 @@ int ocf_metadata_actor(struct ocf_cache *cache,
|
||||
if (_is_cache_line_acting(cache, i, core_id,
|
||||
start_line, end_line)) {
|
||||
if (ocf_cache_line_is_used(cache, i))
|
||||
ret = -EAGAIN;
|
||||
ret = -OCF_ERR_AGAIN;
|
||||
else
|
||||
actor(cache, i);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ static int _raw_ram_init(ocf_cache_t cache,
|
||||
raw->mem_pool_limit = mem_pool_size;
|
||||
raw->mem_pool = env_secure_alloc(mem_pool_size);
|
||||
if (!raw->mem_pool)
|
||||
return -ENOMEM;
|
||||
return -OCF_ERR_NO_MEM;
|
||||
ENV_BUG_ON(env_memset(raw->mem_pool, mem_pool_size, 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);
|
||||
if (!ctx) {
|
||||
complete(req, -ENOMEM);
|
||||
return -ENOMEM;
|
||||
complete(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!pages_tab) {
|
||||
env_free(ctx);
|
||||
complete(req, -ENOMEM);
|
||||
return -ENOMEM;
|
||||
complete(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
if (!io) {
|
||||
req->error = -ENOMEM;
|
||||
req->error = -OCF_ERR_NO_MEM;
|
||||
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);
|
||||
if (!ctx) {
|
||||
complete(req, -ENOMEM);
|
||||
return -ENOMEM;
|
||||
complete(req, -OCF_ERR_NO_MEM);
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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,
|
||||
ENV_MEM_NOIO);
|
||||
if (!clines_tab) {
|
||||
complete(req, -ENOMEM);
|
||||
complete(req, -OCF_ERR_NO_MEM);
|
||||
env_free(ctx);
|
||||
return -ENOMEM;
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
ENV_BUG();
|
||||
return -ENOSYS;
|
||||
return -OCF_ERR_NOT_SUPP;
|
||||
}
|
||||
|
@ -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,
|
||||
ocf_metadata_end_t cmpl, void *priv)
|
||||
{
|
||||
cmpl(priv, -ENOTSUP);
|
||||
cmpl(priv, -OCF_ERR_NOT_SUPP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -752,7 +752,7 @@ static void _ocf_mngt_test_volume_first_read_complete(void *priv, int error)
|
||||
if (diff) {
|
||||
/* we read back different data than what we had just
|
||||
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)) {
|
||||
|
@ -168,35 +168,35 @@ static inline int ocf_core_validate_io(struct ocf_io *io)
|
||||
ocf_core_t core;
|
||||
|
||||
if (!io->volume)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (!io->ops)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
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))
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (io->io_class >= OCF_IO_CLASS_MAX)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (io->dir != OCF_READ && io->dir != OCF_WRITE)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (!io->io_queue)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (!io->end)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
/* 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
|
||||
* after cache detach, core remove etc. */
|
||||
core = ocf_volume_to_core(io->volume);
|
||||
if (io->io_queue == ocf_core_get_cache(core)->mngt_queue)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
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,
|
||||
&cache->cache_state))) {
|
||||
ocf_io_end(io, -EIO);
|
||||
ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
||||
io->dir);
|
||||
if (!core_io->req) {
|
||||
dec_counter_if_req_was_dirty(core_io, cache);
|
||||
io->end(io, -ENOMEM);
|
||||
io->end(io, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
|
||||
|
||||
if (unlikely(!env_bit_test(ocf_cache_state_running,
|
||||
&cache->cache_state))) {
|
||||
ocf_io_end(io, -EIO);
|
||||
ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
|
||||
|
||||
switch (req_cache_mode) {
|
||||
case ocf_req_cache_mode_pt:
|
||||
return -EIO;
|
||||
return -OCF_ERR_IO;
|
||||
case ocf_req_cache_mode_wb:
|
||||
req_cache_mode = ocf_req_cache_mode_fast;
|
||||
break;
|
||||
@ -334,7 +334,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
|
||||
if (cache->use_submit_io_fast)
|
||||
break;
|
||||
if (io->dir == OCF_WRITE)
|
||||
return -EIO;
|
||||
return -OCF_ERR_IO;
|
||||
|
||||
req_cache_mode = ocf_req_cache_mode_fast;
|
||||
}
|
||||
@ -347,13 +347,13 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
|
||||
|
||||
if (!req) {
|
||||
dec_counter_if_req_was_dirty(core_io, cache);
|
||||
io->end(io, -ENOMEM);
|
||||
io->end(io, -OCF_ERR_NO_MEM);
|
||||
return 0;
|
||||
}
|
||||
if (req->d2c) {
|
||||
dec_counter_if_req_was_dirty(core_io, cache);
|
||||
ocf_req_put(req);
|
||||
return -EIO;
|
||||
return -OCF_ERR_IO;
|
||||
}
|
||||
|
||||
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_req_put(req);
|
||||
return -EIO;
|
||||
return -OCF_ERR_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,
|
||||
&cache->cache_state))) {
|
||||
ocf_io_end(io, -EIO);
|
||||
ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
core_io->req = ocf_req_new(io->io_queue, core, io->addr, io->bytes,
|
||||
io->dir);
|
||||
if (!core_io->req) {
|
||||
ocf_io_end(io, -ENOMEM);
|
||||
ocf_io_end(io, -OCF_ERR_NO_MEM);
|
||||
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,
|
||||
&cache->cache_state))) {
|
||||
ocf_io_end(io, -EIO);
|
||||
ocf_io_end(io, -OCF_ERR_CACHE_NOT_AVAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
core_io->req = ocf_req_new_discard(io->io_queue, core,
|
||||
io->addr, io->bytes, OCF_WRITE);
|
||||
if (!core_io->req) {
|
||||
ocf_io_end(io, -ENOMEM);
|
||||
ocf_io_end(io, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ static int ocf_core_io_set_data(struct ocf_io *io,
|
||||
OCF_CHECK_NULL(io);
|
||||
|
||||
if (!data || offset)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
core_io = ocf_io_to_core_io(io);
|
||||
core_io->data = data;
|
||||
|
@ -31,7 +31,7 @@ int ocf_metadata_get_atomic_entry(ocf_cache_t cache,
|
||||
OCF_CHECK_NULL(entry);
|
||||
|
||||
if (addr > ocf_volume_get_length(&cache->device->volume))
|
||||
return -EFAULT;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (addr < cache->device->metadata_offset) {
|
||||
/* Metadata IO of OCF */
|
||||
|
@ -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);
|
||||
if (!req->map) {
|
||||
req->error = -ENOMEM;
|
||||
return -ENOMEM;
|
||||
req->error = -OCF_ERR_NO_MEM;
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -189,7 +189,7 @@ struct ocf_request {
|
||||
/*!< Detailed request info */
|
||||
|
||||
void (*complete)(struct ocf_request *ocf_req, int error);
|
||||
/*!< Request completion funstion */
|
||||
/*!< Request completion function */
|
||||
|
||||
struct ocf_io *io;
|
||||
/*!< OCF IO associated with request */
|
||||
|
@ -24,11 +24,11 @@ int ocf_volume_type_init(struct ocf_volume_type **type,
|
||||
|
||||
if (!ops->submit_io || !ops->open || !ops->close ||
|
||||
!ops->get_max_io_size || !ops->get_length) {
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
}
|
||||
|
||||
if (properties->caps.atomic_writes && !ops->submit_metadata)
|
||||
return -EINVAL;
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
new_type = env_zalloc(sizeof(**type), ENV_MEM_NORMAL);
|
||||
if (!new_type)
|
||||
@ -37,7 +37,7 @@ int ocf_volume_type_init(struct ocf_volume_type **type,
|
||||
new_type->allocator = ocf_io_allocator_create(
|
||||
properties->io_priv_size, properties->name);
|
||||
if (!new_type->allocator) {
|
||||
ret = -ENOMEM;
|
||||
ret = -OCF_ERR_NO_MEM;
|
||||
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);
|
||||
|
||||
if (!io->volume->opened)
|
||||
io->end(io, -EIO);
|
||||
io->end(io, -OCF_ERR_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);
|
||||
|
||||
if (!io->volume->opened)
|
||||
io->end(io, -EIO);
|
||||
io->end(io, -OCF_ERR_IO);
|
||||
|
||||
if (!io->volume->type->properties->ops.submit_flush) {
|
||||
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)
|
||||
{
|
||||
if (!io->volume->opened)
|
||||
io->end(io, -EIO);
|
||||
io->end(io, -OCF_ERR_IO);
|
||||
|
||||
if (!io->volume->type->properties->ops.submit_discard) {
|
||||
ocf_io_end(io, 0);
|
||||
|
@ -163,7 +163,7 @@ static void _ocf_cleaner_set_error(struct ocf_request *req)
|
||||
return;
|
||||
}
|
||||
|
||||
master->error = -EIO;
|
||||
master->error = -OCF_ERR_IO;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!io) {
|
||||
ocf_metadata_error(req->cache);
|
||||
req->error = -ENOMEM;
|
||||
return -ENOMEM;
|
||||
req->error = -OCF_ERR_NO_MEM;
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!io) {
|
||||
_ocf_cleaner_flush_cores_io_end(iter, req, -ENOMEM);
|
||||
_ocf_cleaner_flush_cores_io_end(iter, req, -OCF_ERR_NO_MEM);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -845,7 +845,7 @@ void ocf_cleaner_fire(struct ocf_cache *cache,
|
||||
}
|
||||
|
||||
if (!master) {
|
||||
attribs->cmpl_fn(attribs->cmpl_context, -ENOMEM);
|
||||
attribs->cmpl_fn(attribs->cmpl_context, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ void ocf_cleaner_fire(struct ocf_cache *cache,
|
||||
|
||||
/* when request allocation failed stop processing */
|
||||
if (!req) {
|
||||
master->error = -ENOMEM;
|
||||
master->error = -OCF_ERR_NO_MEM;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
if (reqs == 1) {
|
||||
io = ocf_new_cache_io(cache);
|
||||
if (!io) {
|
||||
callback(req, -ENOMEM);
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
goto update_stats;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
|
||||
if (!io) {
|
||||
/* Finish all IOs which left with ERROR */
|
||||
for (; i < reqs; i++)
|
||||
callback(req, -ENOMEM);
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
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);
|
||||
if (!io) {
|
||||
callback(req, -ENOMEM);
|
||||
callback(req, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,13 @@ from ..utils import Size as S
|
||||
|
||||
class OcfErrorCode(IntEnum):
|
||||
OCF_ERR_INVAL = 1000000
|
||||
OCF_ERR_AGAIN = auto()
|
||||
OCF_ERR_INTR = auto()
|
||||
OCF_ERR_NOT_SUPP = auto()
|
||||
OCF_ERR_NO_MEM = auto()
|
||||
OCF_ERR_NO_LOCK = auto()
|
||||
OCF_ERR_METADATA_VER = auto()
|
||||
OCF_ERR_NO_METADATA = auto()
|
||||
OCF_ERR_INVAL_VOLUME_TYPE = auto()
|
||||
OCF_ERR_UNKNOWN = auto()
|
||||
OCF_ERR_TOO_MANY_CACHES = auto()
|
||||
@ -28,6 +32,7 @@ class OcfErrorCode(IntEnum):
|
||||
OCF_ERR_NOT_OPEN_EXC = auto()
|
||||
OCF_ERR_CACHE_NOT_AVAIL = auto()
|
||||
OCF_ERR_IO_CLASS_NOT_EXIST = auto()
|
||||
OCF_ERR_IO = auto()
|
||||
OCF_ERR_WRITE_CACHE = auto()
|
||||
OCF_ERR_WRITE_CORE = auto()
|
||||
OCF_ERR_DIRTY_SHUTDOWN = auto()
|
||||
|
Loading…
Reference in New Issue
Block a user