Error codes in IO path changed to OCF-specific
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user