Fix exported object cleanup in case of cache stop failure

In case of error during cache stop exported object is not being restored after destroying.
This may result in bug in case of calling stop once more.
This commit fixes this issue - exported objects are restored.

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
Michal Rakowski
2019-07-16 16:12:43 +02:00
parent ee6cba515a
commit eee7a0e220
3 changed files with 29 additions and 3 deletions

View File

@@ -1646,7 +1646,7 @@ int cache_mngt_exit_instance(ocf_cache_id_t id, int flush)
/* Stop cache device */
status = _cache_mngt_cache_stop_sync(cache);
if (status && status != -OCF_ERR_WRITE_CACHE)
goto unlock;
goto restore_exp_obj;
if (!status && flush_status)
status = -KCAS_ERR_STOPPED_DIRTY;
@@ -1658,6 +1658,24 @@ int cache_mngt_exit_instance(ocf_cache_id_t id, int flush)
ocf_queue_put(cache_priv->mngt_queue);
vfree(cache_priv);
ocf_mngt_cache_unlock(cache);
ocf_mngt_cache_put(cache);
return status;
restore_exp_obj:
if (block_dev_create_all_exported_objects(cache)) {
/* Print error msg but do not change return err code to inform user why
* stop failed originally. */
printk(KERN_WARNING
"Failed to restore (create) all exported objects!\n");
goto unlock;
}
if (block_dev_activate_all_exported_objects(cache)) {
block_dev_destroy_all_exported_objects(cache);
printk(KERN_WARNING
"Failed to restore (activate) all exported objects!\n");
}
unlock:
ocf_mngt_cache_unlock(cache);
put: