Add management queue guards where needed

Prevent starting management operations that require pipeline
when management queue isn't set.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-05-02 17:21:12 +02:00
parent c2aea209db
commit a82d420ee0
2 changed files with 29 additions and 0 deletions

View File

@ -1736,6 +1736,9 @@ void ocf_mngt_cache_attach(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
OCF_CHECK_NULL(cfg);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
result = _ocf_mngt_cache_validate_device_cfg(cfg);
if (result)
OCF_CMPL_RET(cache, priv, result);
@ -1873,6 +1876,9 @@ void ocf_mngt_cache_load(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
OCF_CHECK_NULL(cfg);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
/* Load is not allowed in volatile metadata mode */
if (cache->metadata.is_volatile)
OCF_CMPL_RET(cache, priv, -EINVAL);
@ -2039,6 +2045,14 @@ void ocf_mngt_cache_stop(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
/*
* FIXME: What if creating/setting management queue failed?
* In such case we will be unable to use pipeline, and thus
* perform cache stop procedure.
*/
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
result = ocf_pipeline_create(&pipeline, cache,
&ocf_mngt_cache_stop_pipeline_properties);
if (result)
@ -2116,6 +2130,9 @@ void ocf_mngt_cache_save(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
result = ocf_pipeline_create(&pipeline, cache,
&ocf_mngt_cache_save_pipeline_properties);
if (result)
@ -2386,6 +2403,9 @@ void ocf_mngt_cache_detach(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
if (!env_atomic_read(&cache->attached))
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);

View File

@ -522,6 +522,9 @@ void ocf_mngt_cache_add_core(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, NULL, priv, -OCF_ERR_INVAL);
result = ocf_pipeline_create(&pipeline, cache,
&ocf_mngt_cache_add_core_pipeline_properties);
if (result)
@ -634,6 +637,9 @@ void ocf_mngt_cache_remove_core(ocf_core_t core,
cache = ocf_core_get_cache(core);
core_id = ocf_core_get_id(core);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, -OCF_ERR_INVAL);
/* TODO: Make this asynchronous */
if (_ocf_cleaning_wait_for_finish(cache, 60 * 1000))
OCF_CMPL_RET(priv, -OCF_ERR_CACHE_IN_USE);
@ -697,6 +703,9 @@ void ocf_mngt_cache_detach_core(ocf_core_t core,
cache = ocf_core_get_cache(core);
core_name = ocf_core_get_name(core);
if (!cache->mngt_queue)
OCF_CMPL_RET(cache, -OCF_ERR_INVAL);
/* TODO: Make this asynchronous */
if (_ocf_cleaning_wait_for_finish(cache, 60 * 1000))
OCF_CMPL_RET(priv, -OCF_ERR_CACHE_IN_USE);