Rename "data object" to "volume"

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2019-02-08 12:19:04 +01:00
parent 21012df2f8
commit 97300b1137
65 changed files with 1420 additions and 1386 deletions

View File

@@ -102,11 +102,11 @@ struct ocf_cachemng_attach_params {
struct ocf_cache *cache;
/*!< cache that is being initialized */
struct ocf_data_obj_uuid uuid;
/*!< Caching device data object UUID */
struct ocf_volume_uuid uuid;
/*!< Caching device volume UUID */
uint8_t device_type;
/*!< data object (block device) type */
/*!< volume (block device) type */
uint64_t device_size;
/*!< size of the device in cache lines */
@@ -131,14 +131,14 @@ struct ocf_cachemng_attach_params {
bool device_alloc : 1;
/*!< data structure allocated */
bool data_obj_inited : 1;
bool volume_inited : 1;
/*!< uuid for cache device is allocated */
bool attached_metadata_inited : 1;
/*!< attached metadata sections initialized */
bool device_opened : 1;
/*!< underlying device object is open */
/*!< underlying device volume is open */
bool cleaner_started : 1;
/*!< Cleaner has been started */
@@ -275,8 +275,8 @@ static void __init_cores(struct ocf_cache *cache)
{
/* No core devices yet */
cache->conf_meta->core_count = 0;
ENV_BUG_ON(env_memset(cache->conf_meta->valid_object_bitmap,
sizeof(cache->conf_meta->valid_object_bitmap), 0));
ENV_BUG_ON(env_memset(cache->conf_meta->valid_core_bitmap,
sizeof(cache->conf_meta->valid_core_bitmap), 0));
}
static void __init_metadata_version(struct ocf_cache *cache)
@@ -357,22 +357,22 @@ static void _init_partitions(ocf_cache_t cache)
static void _ocf_mngt_close_all_uninitialized_cores(
struct ocf_cache *cache)
{
ocf_data_obj_t obj;
ocf_volume_t volume;
int j, i;
for (j = cache->conf_meta->core_count, i = 0; j > 0; ++i) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
obj = &(cache->core[i].obj);
ocf_dobj_close(obj);
volume = &(cache->core[i].volume);
ocf_volume_close(volume);
--j;
env_free(cache->core[i].counters);
cache->core[i].counters = NULL;
env_bit_clear(i, cache->conf_meta->valid_object_bitmap);
env_bit_clear(i, cache->conf_meta->valid_core_bitmap);
}
cache->conf_meta->core_count = 0;
@@ -412,13 +412,13 @@ static int _ocf_mngt_init_instance_add_cores(
/* Check in metadata which cores were added into cache */
for (i = 0; i < OCF_CORE_MAX; i++) {
ocf_data_obj_t tobj = NULL;
ocf_volume_t tvolume = NULL;
ocf_core_t core = &cache->core[i];
if (!cache->core_conf_meta[i].added)
continue;
if (!cache->core[i].obj.type)
if (!cache->core[i].volume.type)
goto err;
ret = snprintf(core_name, sizeof(core_name), "core%d", i);
@@ -429,21 +429,21 @@ static int _ocf_mngt_init_instance_add_cores(
if (ret)
goto err;
tobj = ocf_mngt_core_pool_lookup(ocf_cache_get_ctx(cache),
&core->obj.uuid, core->obj.type);
if (tobj) {
tvolume = ocf_mngt_core_pool_lookup(ocf_cache_get_ctx(cache),
&core->volume.uuid, core->volume.type);
if (tvolume) {
/*
* Attach bottom device to core structure
* in cache
*/
ocf_dobj_move(&core->obj, tobj);
ocf_mngt_core_pool_remove(cache->owner, tobj);
ocf_volume_move(&core->volume, tvolume);
ocf_mngt_core_pool_remove(cache->owner, tvolume);
core->opened = true;
ocf_cache_log(cache, log_info,
"Attached core %u from pool\n", i);
} else {
ret = ocf_dobj_open(&core->obj);
ret = ocf_volume_open(&core->volume);
if (ret == -OCF_ERR_NOT_OPEN_EXC) {
ocf_cache_log(cache, log_warn,
"Cannot open core %u. "
@@ -456,11 +456,11 @@ static int _ocf_mngt_init_instance_add_cores(
}
}
env_bit_set(i, cache->conf_meta->valid_object_bitmap);
env_bit_set(i, cache->conf_meta->valid_core_bitmap);
cache->conf_meta->core_count++;
core->obj.cache = cache;
core->volume.cache = cache;
if (ocf_mngt_core_init_front_dobj(core))
if (ocf_mngt_core_init_front_volume(core))
goto err;
core->counters =
@@ -479,8 +479,8 @@ static int _ocf_mngt_init_instance_add_cores(
}
hd_lines = ocf_bytes_2_lines(cache,
ocf_dobj_get_length(
&cache->core[i].obj));
ocf_volume_get_length(
&cache->core[i].volume));
if (hd_lines) {
ocf_cache_log(cache, log_info,
@@ -621,7 +621,7 @@ static int _ocf_mngt_init_new_cache(struct ocf_cachemng_init_params *params)
static int _ocf_mngt_attach_cache_device(struct ocf_cache *cache,
struct ocf_cachemng_attach_params *attach_params)
{
ocf_data_obj_type_t type;
ocf_volume_type_t type;
int ret;
cache->device = env_vzalloc(sizeof(*cache->device));
@@ -629,35 +629,35 @@ static int _ocf_mngt_attach_cache_device(struct ocf_cache *cache,
return -OCF_ERR_NO_MEM;
attach_params->flags.device_alloc = true;
cache->device->obj.cache = cache;
cache->device->volume.cache = cache;
/* Prepare UUID of cache data object */
type = ocf_ctx_get_data_obj_type(cache->owner,
/* Prepare UUID of cache volume */
type = ocf_ctx_get_volume_type(cache->owner,
attach_params->device_type);
if (!type) {
ret = -OCF_ERR_INVAL_DATA_OBJ_TYPE;
ret = -OCF_ERR_INVAL_VOLUME_TYPE;
goto err;
}
ret = ocf_dobj_init(&cache->device->obj, type,
ret = ocf_volume_init(&cache->device->volume, type,
&attach_params->uuid, true);
if (ret)
goto err;
attach_params->flags.data_obj_inited = true;
attach_params->flags.volume_inited = true;
/*
* Open cache device, It has to be done first because metadata service
* need to know size of cache device.
*/
ret = ocf_dobj_open(&cache->device->obj);
ret = ocf_volume_open(&cache->device->volume);
if (ret) {
ocf_cache_log(cache, log_err, "ERROR: Cache not available\n");
goto err;
}
attach_params->flags.device_opened = true;
attach_params->device_size = ocf_dobj_get_length(&cache->device->obj);
attach_params->device_size = ocf_volume_get_length(&cache->device->volume);
/* Check minimum size of cache device */
if (attach_params->device_size < OCF_CACHE_SIZE_MIN) {
@@ -833,13 +833,13 @@ static int _ocf_mngt_init_test_device(struct ocf_cache *cache)
goto end;
}
if (!ocf_dobj_is_atomic(&cache->device->obj))
if (!ocf_volume_is_atomic(&cache->device->volume))
goto end;
/*
* Submit discard request
*/
ret = ocf_submit_obj_discard_wait(&cache->device->obj,
ret = ocf_submit_volume_discard_wait(&cache->device->volume,
reserved_lba_addr, PAGE_SIZE);
if (ret)
goto end;
@@ -859,7 +859,7 @@ static int _ocf_mngt_init_test_device(struct ocf_cache *cache)
if (diff) {
/* discard does not cause target adresses to return 0 on
subsequent read */
cache->device->obj.features.discard_zeroes = 0;
cache->device->volume.features.discard_zeroes = 0;
}
end:
@@ -887,7 +887,7 @@ static int _ocf_mngt_init_prepare_metadata(
if (cache->device->init_mode != ocf_init_mode_metadata_volatile) {
if (cache->device->init_mode == ocf_init_mode_load) {
attach_params->metadata.status = ocf_metadata_load_properties(
&cache->device->obj,
&cache->device->volume,
&line_size,
&cache->conf_meta->metadata_layout,
&cache->conf_meta->cache_mode,
@@ -899,7 +899,7 @@ static int _ocf_mngt_init_prepare_metadata(
}
} else {
attach_params->metadata.status = ocf_metadata_load_properties(
&cache->device->obj,
&cache->device->volume,
NULL, NULL, NULL,
&attach_params->metadata.shutdown_status,
&attach_params->metadata.dirty_flushed);
@@ -1093,13 +1093,13 @@ static void _ocf_mngt_attach_handle_error(
ocf_metadata_deinit_variable_size(cache);
if (attach_params->flags.device_opened)
ocf_dobj_close(&cache->device->obj);
ocf_volume_close(&cache->device->volume);
if (attach_params->flags.concurrency_inited)
ocf_concurrency_deinit(cache);
if (attach_params->flags.data_obj_inited)
ocf_dobj_deinit(&cache->device->obj);
if (attach_params->flags.volume_inited)
ocf_volume_deinit(&cache->device->volume);
if (attach_params->flags.device_alloc)
env_vfree(cache->device);
@@ -1109,22 +1109,22 @@ static int _ocf_mngt_cache_discard_after_metadata(struct ocf_cache *cache)
{
int result;
uint64_t addr = cache->device->metadata_offset;
uint64_t length = ocf_dobj_get_length(
&cache->device->obj) - addr;
bool discard = cache->device->obj.features.discard_zeroes;
uint64_t length = ocf_volume_get_length(
&cache->device->volume) - addr;
bool discard = cache->device->volume.features.discard_zeroes;
if (!discard && ocf_dobj_is_atomic(&cache->device->obj)) {
if (!discard && ocf_volume_is_atomic(&cache->device->volume)) {
/* discard does not zero data - need to explicitly write
zeroes */
result = ocf_submit_write_zeroes_wait(
&cache->device->obj, addr, length);
&cache->device->volume, addr, length);
if (!result) {
result = ocf_submit_obj_flush_wait(
&cache->device->obj);
result = ocf_submit_volume_flush_wait(
&cache->device->volume);
}
} else {
/* Discard object after metadata */
result = ocf_submit_obj_discard_wait(&cache->device->obj, addr,
/* Discard volume after metadata */
result = ocf_submit_volume_discard_wait(&cache->device->volume, addr,
length);
}
@@ -1133,7 +1133,7 @@ static int _ocf_mngt_cache_discard_after_metadata(struct ocf_cache *cache)
discard ? "Discarding whole cache device" :
"Overwriting cache with zeroes");
if (ocf_dobj_is_atomic(&cache->device->obj)) {
if (ocf_volume_is_atomic(&cache->device->volume)) {
ocf_cache_log(cache, log_err, "This step is required"
" for atomic mode!\n");
} else {
@@ -1271,7 +1271,7 @@ static int _ocf_mngt_cache_add_cores_t_clean_pol(ocf_cache_t cache)
if (cleaning_policy_ops[clean_type].add_core) {
no = cache->conf_meta->core_count;
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
result = cleaning_policy_ops[clean_type].add_core(cache, i);
if (result) {
@@ -1288,7 +1288,7 @@ err:
return result;
while (i--) {
if (env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (env_bit_test(i, cache->conf_meta->valid_core_bitmap))
cleaning_policy_ops[clean_type].remove_core(cache, i);
};
@@ -1315,7 +1315,7 @@ static int _ocf_mngt_cache_attach(ocf_cache_t cache,
attach_params.force = device_cfg->force;
attach_params.uuid = device_cfg->uuid;
attach_params.device_type = device_cfg->data_obj_type;
attach_params.device_type = device_cfg->volume_type;
attach_params.perform_test = device_cfg->perform_test;
attach_params.metadata.shutdown_status = ocf_metadata_clean_shutdown;
attach_params.metadata.dirty_flushed = DIRTY_FLUSHED;
@@ -1341,7 +1341,7 @@ static int _ocf_mngt_cache_attach(ocf_cache_t cache,
goto _cache_mng_init_attach_ERROR;
/* Test device features */
cache->device->obj.features.discard_zeroes = 1;
cache->device->volume.features.discard_zeroes = 1;
if (attach_params.perform_test) {
result = _ocf_mngt_init_test_device(cache);
if (result)
@@ -1422,7 +1422,7 @@ static int _ocf_mngt_cache_validate_device_cfg(
if (!device_cfg->uuid.data)
return -OCF_ERR_INVAL;
if (device_cfg->uuid.size > OCF_DATA_OBJ_UUID_MAX_SIZE)
if (device_cfg->uuid.size > OCF_VOLUME_UUID_MAX_SIZE)
return -OCF_ERR_INVAL;
if (device_cfg->cache_line_size &&
@@ -1505,7 +1505,7 @@ int ocf_mngt_cache_attach(ocf_cache_t cache,
/**
* @brief Unplug caching device from cache instance. Variable size metadata
* containers are deinitialiazed as well as other cacheline related
* structures. Cache device object is closed.
* structures. Cache volume is closed.
*
* @param cache OCF cache instance
* @param stop - true if unplugging during stop - in this case we mark
@@ -1548,12 +1548,12 @@ static int _ocf_mngt_cache_unplug(ocf_cache_t cache, bool stop)
result = ocf_metadata_flush_all(cache);
}
ocf_dobj_close(&cache->device->obj);
ocf_volume_close(&cache->device->volume);
ocf_metadata_deinit_variable_size(cache);
ocf_concurrency_deinit(cache);
ocf_dobj_deinit(&cache->device->obj);
ocf_volume_deinit(&cache->device->volume);
env_vfree(cache->device);
cache->device = NULL;
@@ -1583,7 +1583,7 @@ static int _ocf_mngt_cache_stop(ocf_cache_t cache)
/* All exported objects removed, cleaning up rest. */
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
cache_mng_core_remove_from_cache(cache, i);
if (ocf_cache_is_device_attached(cache))
@@ -1742,7 +1742,7 @@ static int _cache_mng_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode,
int i;
for (i = 0; i != OCF_CORE_MAX; ++i) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
env_atomic_set(&cache->core_runtime_meta[i].
initial_dirty_clines,
@@ -1871,7 +1871,7 @@ int ocf_mngt_cache_detach(ocf_cache_t cache)
/* remove cacheline metadata and cleaning policy meta for all cores */
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
cache_mng_core_deinit_attached_meta(cache, i);
cache_mng_core_remove_from_cleaning_pol(cache, i);

View File

@@ -22,7 +22,7 @@ int cache_mng_core_close(ocf_cache_t cache, ocf_core_id_t core_id)
if (!cache->core[core_id].opened)
return -OCF_ERR_CORE_IN_INACTIVE_STATE;
ocf_dobj_close(&cache->core[core_id].obj);
ocf_volume_close(&cache->core[core_id].volume);
cache->core[core_id].opened = false;
return 0;
@@ -53,11 +53,11 @@ void cache_mng_core_deinit_attached_meta(struct ocf_cache *cache, int core_id)
int retry = 1;
uint64_t core_size = 0;
ocf_cleaning_t clean_pol_type;
ocf_data_obj_t core;
ocf_volume_t core;
core = &cache->core[core_id].obj;
core = &cache->core[core_id].volume;
core_size = ocf_dobj_get_length(core);
core_size = ocf_volume_get_length(core);
if (!core_size)
core_size = ~0ULL;
@@ -107,7 +107,7 @@ void cache_mng_core_remove_from_cache(struct ocf_cache *cache, int core_id)
{
env_free(cache->core[core_id].counters);
cache->core[core_id].counters = NULL;
env_bit_clear(core_id, cache->conf_meta->valid_object_bitmap);
env_bit_clear(core_id, cache->conf_meta->valid_core_bitmap);
if (!cache->core[core_id].opened &&
--cache->ocf_core_inactive_count == 0) {

View File

@@ -26,22 +26,22 @@ static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
{
int result = 0;
ocf_core_t tmp_core;
ocf_data_obj_t obj;
ocf_volume_t volume;
tmp_core = &cache->core[cfg->core_id];
obj = &tmp_core->obj;
volume = &tmp_core->volume;
if (ocf_ctx_get_data_obj_type_id(cache->owner, obj->type) !=
cfg->data_obj_type) {
result = -OCF_ERR_INVAL_DATA_OBJ_TYPE;
if (ocf_ctx_get_volume_type_id(cache->owner, volume->type) !=
cfg->volume_type) {
result = -OCF_ERR_INVAL_VOLUME_TYPE;
goto error_out;
}
result = ocf_dobj_open(obj);
result = ocf_volume_open(volume);
if (result)
goto error_out;
if (!ocf_dobj_get_length(obj)) {
if (!ocf_volume_get_length(volume)) {
result = -OCF_ERR_CORE_NOT_AVAIL;
goto error_after_open;
}
@@ -55,7 +55,7 @@ static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
return 0;
error_after_open:
ocf_dobj_close(obj);
ocf_volume_close(volume);
error_out:
*core = NULL;
return result;
@@ -65,31 +65,31 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
struct ocf_mngt_core_config *cfg)
{
ocf_core_t tmp_core;
struct ocf_data_obj_uuid new_uuid;
ocf_data_obj_t obj;
ocf_data_obj_type_t type;
struct ocf_volume_uuid new_uuid;
ocf_volume_t volume;
ocf_volume_type_t type;
ocf_seq_no_t core_sequence_no;
ocf_cleaning_t clean_type;
uint64_t length;
int result = 0;
tmp_core = &cache->core[cfg->core_id];
obj = &tmp_core->obj;
volume = &tmp_core->volume;
tmp_core->obj.cache = cache;
tmp_core->volume.cache = cache;
/* Set uuid */
result = ocf_metadata_set_core_uuid(tmp_core, &cfg->uuid, &new_uuid);
if (result)
return -OCF_ERR_INVAL;
type = ocf_ctx_get_data_obj_type(cache->owner, cfg->data_obj_type);
type = ocf_ctx_get_volume_type(cache->owner, cfg->volume_type);
if (!type) {
result = -OCF_ERR_INVAL_DATA_OBJ_TYPE;
result = -OCF_ERR_INVAL_VOLUME_TYPE;
goto error_out;
}
result = ocf_dobj_init(obj, type, &new_uuid, false);
result = ocf_volume_init(volume, type, &new_uuid, false);
if (result)
goto error_out;
@@ -101,11 +101,11 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
goto error_out;
}
result = ocf_dobj_open(obj);
result = ocf_volume_open(volume);
if (result)
goto error_out;
length = ocf_dobj_get_length(obj);
length = ocf_volume_get_length(volume);
if (!length) {
result = -OCF_ERR_CORE_NOT_AVAIL;
goto error_after_open;
@@ -138,7 +138,7 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
dirty_since, 0);
/* In metadata mark data this core was added into cache */
env_bit_set(cfg->core_id, cache->conf_meta->valid_object_bitmap);
env_bit_set(cfg->core_id, cache->conf_meta->valid_core_bitmap);
cache->core_conf_meta[cfg->core_id].added = true;
tmp_core->opened = true;
@@ -169,7 +169,7 @@ static int _ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
return 0;
error_after_counters_allocation:
env_bit_clear(cfg->core_id, cache->conf_meta->valid_object_bitmap);
env_bit_clear(cfg->core_id, cache->conf_meta->valid_core_bitmap);
cache->core_conf_meta[cfg->core_id].added = false;
tmp_core->opened = false;
@@ -190,7 +190,7 @@ error_after_clean_pol:
cleaning_policy_ops[clean_type].remove_core(cache, cfg->core_id);
error_after_open:
ocf_dobj_close(obj);
ocf_volume_close(volume);
error_out:
ocf_metadata_clear_core_uuid(tmp_core);
*core = NULL;
@@ -240,19 +240,19 @@ static int __ocf_mngt_lookup_core_uuid(ocf_cache_t cache,
for (i = 0; i < OCF_CORE_MAX; i++) {
ocf_core_t core = &cache->core[i];
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
if (cache->core[i].opened)
continue;
if (ocf_ctx_get_data_obj_type_id(cache->owner, core->obj.type)
!= cfg->data_obj_type) {
if (ocf_ctx_get_volume_type_id(cache->owner, core->volume.type)
!= cfg->volume_type) {
continue;
}
if (!env_strncmp(core->obj.uuid.data, cfg->uuid.data,
OCF_MIN(core->obj.uuid.size,
if (!env_strncmp(core->volume.uuid.data, cfg->uuid.data,
OCF_MIN(core->volume.uuid.size,
cfg->uuid.size)))
return i;
}
@@ -297,7 +297,7 @@ static int __ocf_mngt_find_core_id(ocf_cache_t cache,
/* Core is unspecified */
cfg->core_id = _ocf_mngt_find_first_free_core(
cache->conf_meta->valid_object_bitmap);
cache->conf_meta->valid_core_bitmap);
/* no need to check if find_first_zero_bit failed and
* *core_id == MAX_CORE_OBJS_PER_CACHE, as above there is check
* for core_count being greater or equal to
@@ -306,7 +306,7 @@ static int __ocf_mngt_find_core_id(ocf_cache_t cache,
} else if (cfg->core_id < OCF_CORE_MAX) {
/* check if id is not used already */
if (env_bit_test(cfg->core_id,
cache->conf_meta->valid_object_bitmap)) {
cache->conf_meta->valid_core_bitmap)) {
ocf_cache_log(cache, log_debug,
"Core ID already allocated: %d.\n",
cfg->core_id);
@@ -341,25 +341,25 @@ static int _ocf_mngt_find_core_id(ocf_cache_t cache,
return result;
}
int ocf_mngt_core_init_front_dobj(ocf_core_t core)
int ocf_mngt_core_init_front_volume(ocf_core_t core)
{
ocf_cache_t cache = ocf_core_get_cache(core);
ocf_data_obj_type_t type;
struct ocf_data_obj_uuid uuid = {
ocf_volume_type_t type;
struct ocf_volume_uuid uuid = {
.data = core,
.size = sizeof(core),
};
int ret;
type = ocf_ctx_get_data_obj_type(cache->owner, 0);
type = ocf_ctx_get_volume_type(cache->owner, 0);
if (!type)
return -OCF_ERR_INVAL;
ret = ocf_dobj_init(&core->front_obj, type, &uuid, false);
ret = ocf_volume_init(&core->front_volume, type, &uuid, false);
if (ret)
return ret;
return ocf_dobj_open(&core->front_obj);
return ocf_volume_open(&core->front_volume);
}
int ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
@@ -402,7 +402,7 @@ int ocf_mngt_cache_add_core(ocf_cache_t cache, ocf_core_t *core,
if (result)
goto out;
result = ocf_mngt_core_init_front_dobj(*core);
result = ocf_mngt_core_init_front_volume(*core);
out:
if (!result) {
@@ -421,7 +421,7 @@ out:
static int _ocf_mngt_cache_remove_core(ocf_core_t core, bool detach)
{
struct ocf_cache *cache = core->obj.cache;
struct ocf_cache *cache = core->volume.cache;
ocf_core_id_t core_id = ocf_core_get_id(core);
int status;
@@ -435,7 +435,7 @@ static int _ocf_mngt_cache_remove_core(ocf_core_t core, bool detach)
return status;
}
ocf_dobj_close(&core->front_obj);
ocf_volume_close(&core->front_volume);
/* Deinit everything*/
if (ocf_cache_is_device_attached(cache)) {

View File

@@ -28,24 +28,24 @@ int ocf_mngt_core_pool_get_count(ocf_ctx_t ctx)
int ocf_mngt_core_pool_add(ocf_ctx_t ctx, ocf_uuid_t uuid, uint8_t type)
{
ocf_data_obj_t obj;
ocf_volume_t volume;
int result = 0;
OCF_CHECK_NULL(ctx);
result = ocf_ctx_data_obj_create(ctx, &obj, uuid, type);
result = ocf_ctx_volume_create(ctx, &volume, uuid, type);
if (result)
return result;
result = ocf_dobj_open(obj);
result = ocf_volume_open(volume);
if (result) {
ocf_dobj_deinit(obj);
ocf_volume_deinit(volume);
return result;
}
env_mutex_lock(&ctx->lock);
list_add(&obj->core_pool_item, &ctx->core_pool.core_pool_head);
list_add(&volume->core_pool_item, &ctx->core_pool.core_pool_head);
ctx->core_pool.core_pool_count++;
env_mutex_unlock(&ctx->lock);
return result;
@@ -55,15 +55,15 @@ int ocf_mngt_core_pool_visit(ocf_ctx_t ctx,
int (*visitor)(ocf_uuid_t, void *), void *visitor_ctx)
{
int result = 0;
ocf_data_obj_t sobj;
ocf_volume_t svolume;
OCF_CHECK_NULL(ctx);
OCF_CHECK_NULL(visitor);
env_mutex_lock(&ctx->lock);
list_for_each_entry(sobj, &ctx->core_pool.core_pool_head,
list_for_each_entry(svolume, &ctx->core_pool.core_pool_head,
core_pool_item) {
result = visitor(&sobj->uuid, visitor_ctx);
result = visitor(&svolume->uuid, visitor_ctx);
if (result)
break;
}
@@ -71,46 +71,46 @@ int ocf_mngt_core_pool_visit(ocf_ctx_t ctx,
return result;
}
ocf_data_obj_t ocf_mngt_core_pool_lookup(ocf_ctx_t ctx, ocf_uuid_t uuid,
ocf_data_obj_type_t type)
ocf_volume_t ocf_mngt_core_pool_lookup(ocf_ctx_t ctx, ocf_uuid_t uuid,
ocf_volume_type_t type)
{
ocf_data_obj_t sobj;
ocf_volume_t svolume;
OCF_CHECK_NULL(ctx);
OCF_CHECK_NULL(uuid);
OCF_CHECK_NULL(uuid->data);
list_for_each_entry(sobj, &ctx->core_pool.core_pool_head,
list_for_each_entry(svolume, &ctx->core_pool.core_pool_head,
core_pool_item) {
if (sobj->type == type && !env_strncmp(sobj->uuid.data,
uuid->data, OCF_MIN(sobj->uuid.size, uuid->size))) {
return sobj;
if (svolume->type == type && !env_strncmp(svolume->uuid.data,
uuid->data, OCF_MIN(svolume->uuid.size, uuid->size))) {
return svolume;
}
}
return NULL;
}
void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_data_obj_t obj)
void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_volume_t volume)
{
OCF_CHECK_NULL(ctx);
OCF_CHECK_NULL(obj);
OCF_CHECK_NULL(volume);
env_mutex_lock(&ctx->lock);
ctx->core_pool.core_pool_count--;
list_del(&obj->core_pool_item);
list_del(&volume->core_pool_item);
env_mutex_unlock(&ctx->lock);
ocf_dobj_destroy(obj);
ocf_volume_destroy(volume);
}
void ocf_mngt_core_pool_deinit(ocf_ctx_t ctx)
{
ocf_data_obj_t sobj, tobj;
ocf_volume_t svolume, tvolume;
OCF_CHECK_NULL(ctx);
list_for_each_entry_safe(sobj, tobj, &ctx->core_pool.core_pool_head,
list_for_each_entry_safe(svolume, tvolume, &ctx->core_pool.core_pool_head,
core_pool_item) {
ocf_dobj_close(sobj);
ocf_mngt_core_pool_remove(ctx, sobj);
ocf_volume_close(svolume);
ocf_mngt_core_pool_remove(ctx, svolume);
}
}

View File

@@ -8,6 +8,6 @@
#include "../ocf_core_priv.h"
int ocf_mngt_core_init_front_dobj(ocf_core_t core);
int ocf_mngt_core_init_front_volume(ocf_core_t core);
#endif /* __OCF_CORE_MNGT_PRIV_H__ */

View File

@@ -159,7 +159,7 @@ static int _ocf_mngt_get_flush_containers(ocf_cache_t cache,
}
for (i = 0, j = 0; i < OCF_CORE_MAX; i++) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
fc[j].core_id = i;
@@ -374,7 +374,7 @@ static int _ocf_mngt_flush_containers(ocf_cache_t cache,
static int _ocf_mngt_flush_core(ocf_core_t core, bool allow_interruption)
{
ocf_core_id_t core_id = ocf_core_get_id(core);
ocf_cache_t cache = core->obj.cache;
ocf_cache_t cache = core->volume.cache;
struct flush_container fc;
int ret;
@@ -450,7 +450,7 @@ static int _ocf_mng_cache_flush(ocf_cache_t cache, bool interruption)
env_atomic_set(&cache->flush_in_progress, 0);
for (i = 0, j = 0; i < OCF_CORE_MAX; i++) {
if (!env_bit_test(i, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(i, cache->conf_meta->valid_core_bitmap))
continue;
env_atomic_set(&cache->core[i].flushed, 0);
@@ -563,7 +563,7 @@ int ocf_mngt_core_purge(ocf_core_t core, bool interruption)
cache = ocf_core_get_cache(core);
core_id = ocf_core_get_id(core);
core_size = ocf_dobj_get_length(&cache->core[core_id].obj);
core_size = ocf_volume_get_length(&cache->core[core_id].volume);
core_size = core_size ?: ~0ULL;
_ocf_mngt_begin_flush(cache);