diff --git a/modules/cas_cache/layer_cache_management.c b/modules/cas_cache/layer_cache_management.c index 0e6998061..d13805c61 100644 --- a/modules/cas_cache/layer_cache_management.c +++ b/modules/cas_cache/layer_cache_management.c @@ -1360,18 +1360,20 @@ 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_core_device_loaded_visitor(ocf_core_t core, void *cntx) +static void _cache_mngt_log_core_devices_loaded(ocf_cache_t cache) { - uint16_t core_id = OCF_CORE_ID_INVALID; - ocf_cache_t cache = ocf_core_get_cache(core); + uint16_t core_id; + ocf_core_t core; - _cache_mngt_log_core_device_path(core); + ocf_core_for_each(core, cache, false) { + core_id = OCF_CORE_ID_INVALID; - core_id_from_name(&core_id, ocf_core_get_name(core)); + _cache_mngt_log_core_device_path(core); - mark_core_id_used(cache, core_id); + core_id_from_name(&core_id, ocf_core_get_name(core)); - return 0; + mark_core_id_used(cache, core_id); + } } struct _cache_mngt_add_core_context { @@ -1846,40 +1848,27 @@ int cache_mngt_set_partitions(const char *cache_name, size_t name_len, return result; } -static int _cache_mngt_create_core_exp_obj(ocf_core_t core, void *cntx) -{ - int result; - - result = kcas_core_create_exported_object(core); - if (result) - return result; - - return result; -} - -static int _cache_mngt_destroy_core_exp_obj(ocf_core_t core, void *cntx) +static int cache_mngt_initialize_core_exported_objects(ocf_cache_t cache) { - if (kcas_core_destroy_exported_object(core)) { - ocf_cache_t cache = ocf_core_get_cache(core); + ocf_core_t core; + int result = 0; - printk(KERN_ERR "Cannot to destroy exported object, %s.%s\n", - ocf_cache_get_name(cache), - ocf_core_get_name(core)); + ocf_core_for_each(core, cache, true) { + result = kcas_core_create_exported_object(core); + if (result) + break; } - return 0; -} - -static int cache_mngt_initialize_core_exported_objects(ocf_cache_t cache) -{ - int result; - - result = ocf_core_visit(cache, _cache_mngt_create_core_exp_obj, NULL, - true); if (result) { /* Need to cleanup */ - ocf_core_visit(cache, _cache_mngt_destroy_core_exp_obj, NULL, - true); + ocf_core_for_each(core, cache, true) { + if (kcas_core_destroy_exported_object(core)) { + printk(KERN_ERR "Cannot to destroy exported " + "object, %s.%s\n", + ocf_cache_get_name(cache), + ocf_core_get_name(core)); + } + } } return result; @@ -2419,8 +2408,7 @@ static int _cache_start_finalize(ocf_cache_t cache, int init_mode, ctx->ocf_start_error = result; return result; } - ocf_core_visit(cache, _cache_mngt_core_device_loaded_visitor, - NULL, false); + _cache_mngt_log_core_devices_loaded(cache); break; case CACHE_INIT_STANDBY_NEW: case CACHE_INIT_STANDBY_LOAD: diff --git a/modules/cas_cache/volume/vol_block_dev_top.c b/modules/cas_cache/volume/vol_block_dev_top.c index b37e3d833..f34f6f92e 100644 --- a/modules/cas_cache/volume/vol_block_dev_top.c +++ b/modules/cas_cache/volume/vol_block_dev_top.c @@ -691,7 +691,7 @@ int kcas_cache_destroy_exported_object(ocf_cache_t cache) return kcas_volume_destroy_exported_object(volume); } -static int kcas_core_lock_exported_object(ocf_core_t core, void *cntx) +static int kcas_core_lock_exported_object(ocf_core_t core) { int result; struct bd_object *bvol = bd_object( @@ -718,7 +718,7 @@ static int kcas_core_lock_exported_object(ocf_core_t core, void *cntx) } -static int kcas_core_unlock_exported_object(ocf_core_t core, void *cntx) +static void kcas_core_unlock_exported_object(ocf_core_t core) { struct bd_object *bvol = bd_object(ocf_core_get_volume(core)); @@ -726,11 +726,9 @@ static int kcas_core_unlock_exported_object(ocf_core_t core, void *cntx) cas_exp_obj_unlock(bvol->dsk); bvol->expobj_locked = false; } - - return 0; } -static int kcas_core_stop_exported_object(ocf_core_t core, void *cntx) +static void kcas_core_stop_exported_object(ocf_core_t core) { struct bd_object *bvol = bd_object( ocf_core_get_volume(core)); @@ -753,35 +751,37 @@ static int kcas_core_stop_exported_object(ocf_core_t core, void *cntx) cas_exp_obj_unlock(bvol->dsk); bvol->expobj_locked = false; } - - return 0; } -static int kcas_core_cleanup_exported_object(ocf_core_t core, void *cntx) +static void kcas_core_cleanup_exported_object(ocf_core_t core) { struct bd_object *bvol = bd_object(ocf_core_get_volume(core)); cas_exp_obj_cleanup(bvol->dsk); - - return 0; } int kcas_cache_destroy_all_core_exported_objects(ocf_cache_t cache) { - int result; + ocf_core_t core; + int result = 0; /* Try lock exported objects */ - result = ocf_core_visit(cache, kcas_core_lock_exported_object, NULL, - true); + ocf_core_for_each(core, cache, true) { + result = kcas_core_lock_exported_object(core); + if (result) + break; + } if (result) { /* Failure, unlock already locked exported objects */ - ocf_core_visit(cache, kcas_core_unlock_exported_object, NULL, - true); + ocf_core_for_each(core, cache, true) + kcas_core_unlock_exported_object(core); return result; } - ocf_core_visit(cache, kcas_core_stop_exported_object, NULL, true); - ocf_core_visit(cache, kcas_core_cleanup_exported_object, NULL, true); + ocf_core_for_each(core, cache, true) + kcas_core_stop_exported_object(core); + ocf_core_for_each(core, cache, true) + kcas_core_cleanup_exported_object(core); return 0; } diff --git a/ocf b/ocf index 7d3dc5207..916713b2f 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit 7d3dc5207377e4e5d1264f9ccf30d841d99e58d8 +Subproject commit 916713b2fb6e68ac5594b5071e73226ff41031dc