Fixed some bugs found by the coverity tool
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
parent
0391fc17b7
commit
83e23c5593
@ -68,6 +68,7 @@ static void _ocf_discard_core_complete(struct ocf_io *io, int error)
|
|||||||
static int _ocf_discard_core(struct ocf_request *req)
|
static int _ocf_discard_core(struct ocf_request *req)
|
||||||
{
|
{
|
||||||
struct ocf_io *io;
|
struct ocf_io *io;
|
||||||
|
int err;
|
||||||
|
|
||||||
io = ocf_volume_new_io(&req->core->volume, req->io_queue,
|
io = ocf_volume_new_io(&req->core->volume, req->io_queue,
|
||||||
SECTORS_TO_BYTES(req->discard.sector),
|
SECTORS_TO_BYTES(req->discard.sector),
|
||||||
@ -79,7 +80,11 @@ static int _ocf_discard_core(struct ocf_request *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ocf_io_set_cmpl(io, req, NULL, _ocf_discard_core_complete);
|
ocf_io_set_cmpl(io, req, NULL, _ocf_discard_core_complete);
|
||||||
ocf_io_set_data(io, req->data, 0);
|
err = ocf_io_set_data(io, req->data, 0);
|
||||||
|
if (err) {
|
||||||
|
_ocf_discard_complete_req(req, err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
ocf_volume_submit_discard(io);
|
ocf_volume_submit_discard(io);
|
||||||
|
|
||||||
|
@ -774,9 +774,16 @@ int ocf_metadata_query_cores_segment_io(
|
|||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint32_t io_count;
|
uint32_t io_count;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t max_pages_per_io = ocf_volume_get_max_io_size(volume) /
|
uint32_t max_pages_per_io;
|
||||||
PAGE_SIZE;
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
unsigned int max_io_size = ocf_volume_get_max_io_size(volume);
|
||||||
|
|
||||||
|
if (!max_io_size) {
|
||||||
|
err = -OCF_ERR_INVAL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_pages_per_io = max_io_size / PAGE_SIZE;
|
||||||
|
|
||||||
/* Allocate data */
|
/* Allocate data */
|
||||||
segment_data->data = ctx_data_alloc(owner,
|
segment_data->data = ctx_data_alloc(owner,
|
||||||
|
@ -373,7 +373,7 @@ static int _raw_ram_flush_do_asynch_fill(ocf_cache_t cache,
|
|||||||
uint32_t raw_page;
|
uint32_t raw_page;
|
||||||
struct _raw_ram_flush_ctx *ctx = context;
|
struct _raw_ram_flush_ctx *ctx = context;
|
||||||
struct ocf_metadata_raw *raw = NULL;
|
struct ocf_metadata_raw *raw = NULL;
|
||||||
uint64_t size;
|
uint32_t size;
|
||||||
|
|
||||||
ENV_BUG_ON(!ctx);
|
ENV_BUG_ON(!ctx);
|
||||||
|
|
||||||
|
@ -571,9 +571,14 @@ static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params)
|
|||||||
return -OCF_ERR_NO_MEM;
|
return -OCF_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ocf_refcnt_inc(&cache->refcnt.cache)){
|
||||||
|
env_mutex_destroy(&cache->flush_mutex);
|
||||||
|
env_vfree(cache);
|
||||||
|
return -OCF_ERR_START_CACHE_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&cache->list);
|
INIT_LIST_HEAD(&cache->list);
|
||||||
list_add_tail(&cache->list, ¶ms->ctx->caches);
|
list_add_tail(&cache->list, ¶ms->ctx->caches);
|
||||||
ocf_refcnt_inc(&cache->refcnt.cache);
|
|
||||||
cache->owner = params->ctx;
|
cache->owner = params->ctx;
|
||||||
|
|
||||||
/* start with freezed metadata ref counter to indicate detached device*/
|
/* start with freezed metadata ref counter to indicate detached device*/
|
||||||
@ -1654,14 +1659,8 @@ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
|||||||
ocf_cache_log(*cache, log_info, "Successfully added\n");
|
ocf_cache_log(*cache, log_info, "Successfully added\n");
|
||||||
ocf_cache_log(*cache, log_info, "Cache mode : %s\n",
|
ocf_cache_log(*cache, log_info, "Cache mode : %s\n",
|
||||||
_ocf_cache_mode_get_name(ocf_cache_get_mode(*cache)));
|
_ocf_cache_mode_get_name(ocf_cache_get_mode(*cache)));
|
||||||
} else {
|
} else
|
||||||
if (cfg->name) {
|
ocf_log(ctx, log_err, "%s: Inserting cache failed\n", cfg->name);
|
||||||
ocf_log(ctx, log_err, "Inserting cache %s failed\n",
|
|
||||||
cfg->name);
|
|
||||||
} else {
|
|
||||||
ocf_log(ctx, log_err, "Inserting cache failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (!uuid->data || !muuid->data)
|
if (!uuid->data)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (uuid->size > sizeof(muuid->data))
|
if (uuid->size > sizeof(muuid->data))
|
||||||
|
@ -277,8 +277,8 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
|
|||||||
|
|
||||||
OCF_METADATA_LOCK_WR();
|
OCF_METADATA_LOCK_WR();
|
||||||
|
|
||||||
result = env_memcpy(old_config, sizeof(&cache->user_parts),
|
result = env_memcpy(old_config, sizeof(cache->user_parts),
|
||||||
cache->user_parts, sizeof(&cache->user_parts));
|
cache->user_parts, sizeof(cache->user_parts));
|
||||||
if (result)
|
if (result)
|
||||||
goto out_cpy;
|
goto out_cpy;
|
||||||
|
|
||||||
@ -295,8 +295,8 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
|
|||||||
|
|
||||||
out_edit:
|
out_edit:
|
||||||
if (result) {
|
if (result) {
|
||||||
ENV_BUG_ON(env_memcpy(cache->user_parts, sizeof(&cache->user_parts),
|
ENV_BUG_ON(env_memcpy(cache->user_parts, sizeof(cache->user_parts),
|
||||||
old_config, sizeof(&cache->user_parts)));
|
old_config, sizeof(cache->user_parts)));
|
||||||
}
|
}
|
||||||
|
|
||||||
out_cpy:
|
out_cpy:
|
||||||
|
@ -73,13 +73,15 @@ void ocf_volume_type_deinit(struct ocf_volume_type *type)
|
|||||||
int ocf_volume_init(ocf_volume_t volume, ocf_volume_type_t type,
|
int ocf_volume_init(ocf_volume_t volume, ocf_volume_type_t type,
|
||||||
struct ocf_volume_uuid *uuid, bool uuid_copy)
|
struct ocf_volume_uuid *uuid, bool uuid_copy)
|
||||||
{
|
{
|
||||||
uint32_t priv_size = type->properties->volume_priv_size;
|
uint32_t priv_size;
|
||||||
void *data;
|
void *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!volume || !type)
|
if (!volume || !type)
|
||||||
return -OCF_ERR_INVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
|
priv_size = type->properties->volume_priv_size;
|
||||||
|
|
||||||
volume->opened = false;
|
volume->opened = false;
|
||||||
volume->type = type;
|
volume->type = type;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ static int ocf_part_lst_cmp_valid(struct ocf_cache *cache,
|
|||||||
if (!p2->config->flags.valid) {
|
if (!p2->config->flags.valid) {
|
||||||
if (p2_size) {
|
if (p2_size) {
|
||||||
v2 = SHRT_MAX;
|
v2 = SHRT_MAX;
|
||||||
p1->config->flags.eviction = true;
|
p2->config->flags.eviction = true;
|
||||||
} else {
|
} else {
|
||||||
v2 = SHRT_MIN;
|
v2 = SHRT_MIN;
|
||||||
p2->config->flags.eviction = false;
|
p2->config->flags.eviction = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user