Merge pull request #98 from mmichal10/fix-add-core-after-load

Fix add core after load
This commit is contained in:
Kamil Łepek 2019-09-11 09:04:55 +02:00 committed by GitHub
commit 6f77e1eb50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -132,6 +132,25 @@ static inline int cache_id_from_name(uint16_t *cache_id, const char *name)
return result;
}
static inline int core_id_from_name(uint16_t *core_id, const char *name)
{
const char *id_str;
long res;
int result;
if (strnlen(name, OCF_CORE_NAME_SIZE) < sizeof("core") - 1)
return -EINVAL;
id_str = name + sizeof("core") - 1;
result = kstrtol(id_str, 10, &res);
if (!result)
*core_id = res;
return result;
}
static inline int mngt_get_cache_by_id(ocf_ctx_t ctx, uint16_t id,
ocf_cache_t *cache)
{

View File

@ -592,10 +592,19 @@ static void _cache_mngt_log_core_device_path(ocf_core_t core)
ocf_core_get_name(core), ocf_cache_get_name(cache));
}
static int _cache_mngt_log_core_device_path_visitor(ocf_core_t core, void *cntx)
static int _cache_mngt_core_device_loaded_visitor(ocf_core_t core, void *cntx)
{
struct cache_priv *cache_priv;
uint16_t core_id = OCF_CORE_ID_INVALID;
ocf_cache_t cache = ocf_core_get_cache(core);
cache_priv = ocf_cache_get_priv(cache);
_cache_mngt_log_core_device_path(core);
core_id_from_name(&core_id, ocf_core_get_name(core));
mark_core_id_used(cache_priv->core_id_bitmap, core_id);
return 0;
}
@ -1339,7 +1348,7 @@ static int _cache_mngt_load(struct ocf_mngt_cache_config *cfg,
if (result)
goto err_core_obj;
ocf_core_visit(tmp_cache, _cache_mngt_log_core_device_path_visitor,
ocf_core_visit(tmp_cache, _cache_mngt_core_device_loaded_visitor,
NULL, false);
*cache = tmp_cache;