Merge pull request #126 from mmichal10/fix-try-add

Don't generate core name when adding core to corepool.
This commit is contained in:
Kamil Łepek 2019-09-26 09:17:52 +02:00 committed by GitHub
commit cdab8cacd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -61,6 +61,10 @@ struct {
OCF_ERR_TOO_MANY_CORES,
"Too many core devices in cache"
},
{
OCF_ERR_CORE_EXIST,
"Core id already used"
},
{
OCF_ERR_CORE_NOT_AVAIL,
"Core device not available"

View File

@ -534,8 +534,7 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
struct kcas_insert_core *cmd_info)
{
struct block_device *bdev;
static char core_name[OCF_CORE_NAME_SIZE];
struct cache_priv *cache_priv;
char core_name[OCF_CORE_NAME_SIZE] = {};
ocf_cache_t cache;
uint16_t core_id;
int result;
@ -546,17 +545,19 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
if (cmd_info->core_id == OCF_CORE_MAX) {
result = mngt_get_cache_by_id(cas_ctx, cmd_info->cache_id,
&cache);
if (result)
if (result && result != -OCF_ERR_CACHE_NOT_EXIST) {
return result;
} else if (!result) {
struct cache_priv *cache_priv;
cache_priv = ocf_cache_get_priv(cache);
ocf_mngt_cache_put(cache);
cache_priv = ocf_cache_get_priv(cache);
ocf_mngt_cache_put(cache);
core_id = find_free_core_id(cache_priv->core_id_bitmap);
if (core_id == OCF_CORE_MAX)
return -OCF_ERR_INVAL;
core_id = find_free_core_id(cache_priv->core_id_bitmap);
if (core_id == OCF_CORE_MAX)
return -OCF_ERR_INVAL;
cmd_info->core_id = core_id;
cmd_info->core_id = core_id;
}
}
snprintf(core_name, sizeof(core_name), "core%d", cmd_info->core_id);