Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 25 additions & 37 deletions modules/cas_cache/layer_cache_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
34 changes: 17 additions & 17 deletions modules/cas_cache/volume/vol_block_dev_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -718,19 +718,17 @@ 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));

if (bvol->expobj_locked) {
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));
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion ocf
Loading