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

@@ -83,7 +83,7 @@ static int _ocf_cleaner_run_check_dirty_inactive(struct ocf_cache *cache)
return 0;
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;
if (cache->core[i].opened && env_atomic_read(&(cache->

View File

@@ -48,7 +48,7 @@ int ocf_io_d2c(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
ocf_submit_obj_req(&core->obj, req, _ocf_d2c_completion);
ocf_submit_volume_req(&core->volume, req, _ocf_d2c_completion);
ocf_engine_update_block_stats(req);

View File

@@ -65,7 +65,7 @@ static int _ocf_discard_core(struct ocf_request *req)
struct ocf_cache *cache = req->cache;
struct ocf_io *io;
io = ocf_dobj_new_io(&cache->core[req->core_id].obj);
io = ocf_volume_new_io(&cache->core[req->core_id].volume);
if (!io) {
_ocf_discard_complete_req(req, -ENOMEM);
return -ENOMEM;
@@ -79,7 +79,7 @@ static int _ocf_discard_core(struct ocf_request *req)
ocf_io_set_data(io, req->data, 0);
ocf_io_set_queue(io, req->io_queue);
ocf_dobj_submit_discard(io);
ocf_volume_submit_discard(io);
return 0;
}
@@ -105,7 +105,7 @@ static int _ocf_discard_flush_cache(struct ocf_request *req)
{
struct ocf_io *io;
io = ocf_dobj_new_io(&req->cache->device->obj);
io = ocf_volume_new_io(&req->cache->device->volume);
if (!io) {
ocf_metadata_error(req->cache);
_ocf_discard_complete_req(req, -ENOMEM);
@@ -116,7 +116,7 @@ static int _ocf_discard_flush_cache(struct ocf_request *req)
ocf_io_set_cmpl(io, req, NULL, _ocf_discard_cache_flush_complete);
ocf_io_set_queue(io, req->io_queue);
ocf_dobj_submit_flush(io);
ocf_volume_submit_flush(io);
return 0;
}

View File

@@ -50,7 +50,7 @@ static int _ocf_invalidate_do(struct ocf_request *req)
env_atomic_inc(&req->req_remaining);
if (ocf_dobj_is_atomic(&cache->device->obj) &&
if (ocf_volume_is_atomic(&cache->device->volume) &&
req->info.flush_metadata) {
/* Metadata flush IO */
ocf_metadata_flush_do_asynch(cache, req, _ocf_invalidate_req);

View File

@@ -48,7 +48,7 @@ int ocf_engine_ops(struct ocf_request *req)
env_atomic_set(&req->req_remaining, 2);
/* Submit operation into core device */
ocf_submit_obj_req(&cache->core[req->core_id].obj, req,
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_engine_ops_complete);
ocf_submit_cache_reqs(cache, req->map, req, req->rw,

View File

@@ -50,7 +50,7 @@ static inline void _ocf_read_pt_submit(struct ocf_request *req)
OCF_DEBUG_RQ(req, "Submit");
/* Core read */
ocf_submit_obj_req(&cache->core[req->core_id].obj, req,
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_read_pt_complete);
}

View File

@@ -128,7 +128,7 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *req)
goto err_alloc;
/* Submit read request to core device. */
ocf_submit_obj_req(&cache->core[req->core_id].obj, req,
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_read_generic_miss_complete);
return;

View File

@@ -72,7 +72,7 @@ int ocf_write_wa(struct ocf_request *req)
/* Submit write IO to the core */
env_atomic_set(&req->req_remaining, 1);
ocf_submit_obj_req(&cache->core[req->core_id].obj, req,
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_read_wa_complete);
/* Update statistics */

View File

@@ -111,7 +111,7 @@ static int _ocf_write_wi_do(struct ocf_request *req)
OCF_DEBUG_RQ(req, "Submit");
/* Submit write IO to the core */
ocf_submit_obj_req(&cache->core[req->core_id].obj, req,
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_write_wi_core_complete);
/* Update statistics */

View File

@@ -93,7 +93,7 @@ static inline void _ocf_write_wt_submit(struct ocf_request *req)
ocf_engine_io_count(req), _ocf_write_wt_cache_complete);
/* To core */
ocf_submit_obj_req(&cache->core[req->core_id].obj, req,
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_write_wt_core_complete);
}

View File

@@ -410,7 +410,7 @@ uint32_t evp_lru_req_clines(struct ocf_cache *cache, uint32_t io_queue,
ENV_BUG_ON(metadata_test_dirty(cache, curr_cline));
if (ocf_dobj_is_atomic(&cache->device->obj)) {
if (ocf_volume_is_atomic(&cache->device->volume)) {
/* atomic cache, we have to trim cache lines before
* eviction
*/

View File

@@ -184,7 +184,8 @@ static inline int ocf_metadata_check_properties(void)
return 0;
}
static int ocf_metadata_read_properties(ocf_ctx_t ctx, ocf_data_obj_t cache_obj,
static int ocf_metadata_read_properties(ocf_ctx_t ctx,
ocf_volume_t cache_volume,
struct ocf_superblock_config *superblock)
{
ctx_data_t *data;
@@ -195,7 +196,7 @@ static int ocf_metadata_read_properties(ocf_ctx_t ctx, ocf_data_obj_t cache_obj,
return -EINVAL;
/* Allocate resources for IO */
io = ocf_dobj_new_io(cache_obj);
io = ocf_volume_new_io(cache_volume);
data = ctx_data_alloc(ctx, 1);
/* Check allocation result */
@@ -237,7 +238,7 @@ out:
/**
* @brief function loads individual properties from metadata set
* @param cache_obj object from which to load metadata
* @param cache_volume volume from which to load metadata
* @param variant - field to which save metadata variant; if NULL,
* metadata variant won't be read.
* @param cache mode; if NULL is passed it won't be read
@@ -246,7 +247,7 @@ out:
* the cache
* @return 0 upon successful completion
*/
int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
int ocf_metadata_load_properties(ocf_volume_t cache_volume,
ocf_cache_line_size_t *line_size,
ocf_metadata_layout_t *layout,
ocf_cache_mode_t *cache_mode,
@@ -259,28 +260,28 @@ int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
/* Allocate first page of super block */
superblock = env_zalloc(PAGE_SIZE, ENV_MEM_NORMAL);
if (!superblock) {
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"Allocation memory error");
return -ENOMEM;
}
OCF_DEBUG_TRACE(cache);
err_value = ocf_metadata_read_properties(cache_obj->cache->owner,
cache_obj, superblock);
err_value = ocf_metadata_read_properties(cache_volume->cache->owner,
cache_volume, superblock);
if (err_value)
goto ocf_metadata_load_variant_ERROR;
if (superblock->magic_number != CACHE_MAGIC_NUMBER) {
err_value = -ENODATA;
ocf_cache_log(cache_obj->cache, log_info,
ocf_cache_log(cache_volume->cache, log_info,
"Can not detect pre-existing metadata\n");
goto ocf_metadata_load_variant_ERROR;
}
if (METADATA_VERSION() != superblock->metadata_version) {
err_value = -EBADF;
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"Metadata version mismatch!\n");
goto ocf_metadata_load_variant_ERROR;
}
@@ -290,7 +291,7 @@ int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
*line_size = superblock->line_size;
} else {
err_value = -EINVAL;
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"ERROR: Invalid cache line size!\n");
}
}
@@ -299,7 +300,7 @@ int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
if (superblock->metadata_layout >= ocf_metadata_layout_max ||
superblock->metadata_layout < 0) {
err_value = -EINVAL;
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"ERROR: Invalid metadata layout!\n");
} else {
*layout = superblock->metadata_layout;
@@ -310,7 +311,7 @@ int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
if (superblock->cache_mode < ocf_cache_mode_max) {
*cache_mode = superblock->cache_mode;
} else {
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"ERROR: Invalid cache mode!\n");
err_value = -EINVAL;
}
@@ -320,7 +321,7 @@ int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
if (superblock->clean_shutdown <= ocf_metadata_clean_shutdown) {
*shutdown_status = superblock->clean_shutdown;
} else {
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"ERROR: Invalid shutdown status!\n");
err_value = -EINVAL;
}
@@ -330,7 +331,7 @@ int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
if (superblock->dirty_flushed <= DIRTY_FLUSHED) {
*dirty_flushed = superblock->dirty_flushed;
} else {
ocf_cache_log(cache_obj->cache, log_err,
ocf_cache_log(cache_volume->cache, log_err,
"ERROR: Invalid flush status!\n");
err_value = -EINVAL;
}
@@ -342,14 +343,14 @@ ocf_metadata_load_variant_ERROR:
return err_value;
}
int ocf_metadata_probe(ocf_ctx_t ctx, ocf_data_obj_t cache_obj,
int ocf_metadata_probe(ocf_ctx_t ctx, ocf_volume_t cache_volume,
bool *clean_shutdown, bool *cache_dirty)
{
struct ocf_superblock_config *superblock;
int result = 0;
OCF_CHECK_NULL(ctx);
OCF_CHECK_NULL(cache_obj);
OCF_CHECK_NULL(cache_volume);
/* Allocate first page of super block */
superblock = env_zalloc(PAGE_SIZE, ENV_MEM_NORMAL);
@@ -360,7 +361,7 @@ int ocf_metadata_probe(ocf_ctx_t ctx, ocf_data_obj_t cache_obj,
OCF_DEBUG_TRACE(cache);
result = ocf_metadata_read_properties(ctx, cache_obj, superblock);
result = ocf_metadata_read_properties(ctx, cache_volume, superblock);
if (result)
goto ocf_metadata_probe_END;

View File

@@ -306,7 +306,7 @@ static inline ocf_cache_line_t ocf_metadata_entries_hash(
return cache->metadata.iface.entries_hash(cache);
}
int ocf_metadata_load_properties(ocf_data_obj_t cache_obj,
int ocf_metadata_load_properties(ocf_volume_t cache_volume,
ocf_cache_line_size_t *line_size,
ocf_metadata_layout_t *layout,
ocf_cache_mode_t *cache_mode,

View File

@@ -576,7 +576,7 @@ static int ocf_metadata_hash_init_variable_size(struct ocf_cache *cache,
if (cache->device->init_mode == ocf_init_mode_metadata_volatile) {
raw->raw_type = metadata_raw_type_volatile;
} else if (i == metadata_segment_collision &&
ocf_dobj_is_atomic(&cache->device->obj)) {
ocf_volume_is_atomic(&cache->device->volume)) {
raw->raw_type = metadata_raw_type_atomic;
}
@@ -887,7 +887,7 @@ static int ocf_metadata_hash_load_superblock(struct ocf_cache *cache)
struct ocf_superblock_config *sb_config;
struct ocf_superblock_runtime *sb_runtime;
struct ocf_metadata_uuid *muuid;
struct ocf_data_obj_uuid uuid;
struct ocf_volume_uuid uuid;
OCF_DEBUG_TRACE(cache);
@@ -973,9 +973,9 @@ static int ocf_metadata_hash_load_superblock(struct ocf_cache *cache)
uuid.data = muuid->data;
uuid.size = muuid->size;
/* Initialize core data object */
ocf_dobj_init(&cache->core[i].obj,
ocf_ctx_get_data_obj_type(cache->owner,
/* Initialize core volume */
ocf_volume_init(&cache->core[i].volume,
ocf_ctx_get_volume_type(cache->owner,
cache->core_conf_meta[i].type),
&uuid, false);
}
@@ -1022,8 +1022,8 @@ static int ocf_metadata_hash_flush_superblock(struct ocf_cache *cache)
/* Synchronize core objects types */
for (i = 0; i < OCF_CORE_MAX; i++) {
cache->core_conf_meta[i].type = ocf_ctx_get_data_obj_type_id(
cache->owner, cache->core[i].obj.type);
cache->core_conf_meta[i].type = ocf_ctx_get_volume_type_id(
cache->owner, cache->core[i].volume.type);
}
/* Calculate checksum */
@@ -1543,7 +1543,7 @@ static int ocf_metadata_hash_load_recovery(struct ocf_cache *cache)
OCF_DEBUG_TRACE(cache);
if (ocf_dobj_is_atomic(&cache->device->obj)) {
if (ocf_volume_is_atomic(&cache->device->volume)) {
result = _ocf_metadata_hash_load_recovery_atomic(cache);
rebuild_dirty_only = false;
} else {

View File

@@ -46,7 +46,7 @@ static struct ocf_io_if meta_restart_if = {
*/
static uint32_t metadata_io_max_page(struct ocf_cache *cache)
{
return ocf_dobj_get_max_io_size(&cache->device->obj) / PAGE_SIZE;
return ocf_volume_get_max_io_size(&cache->device->volume) / PAGE_SIZE;
}
/*
@@ -56,7 +56,7 @@ static void metadata_io_read_i_atomic_end(struct ocf_io *io, int error)
{
struct metadata_io_request_atomic *meta_atom_req = io->priv1;
OCF_DEBUG_TRACE(ocf_dobj_get_cache(io->obj));
OCF_DEBUG_TRACE(ocf_volume_get_cache(io->volume));
meta_atom_req->error |= error;
env_completion_complete(&meta_atom_req->complete);
@@ -119,7 +119,7 @@ int metadata_io_read_i_atomic(struct ocf_cache *cache,
}
/* Submit IO */
ocf_dobj_submit_metadata(io);
ocf_volume_submit_metadata(io);
ocf_io_put(io);
/* Wait for completion of IO */
@@ -194,7 +194,7 @@ static int ocf_restart_meta_io(struct ocf_request *req)
metadata_io_write_i_asynch_end(meta_io_req, ret);
return ret;
}
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
return 0;
}
@@ -376,7 +376,7 @@ int metadata_io_write_i_asynch(struct ocf_cache *cache, uint32_t queue,
break;
}
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
}
count -= curr_count;
@@ -507,7 +507,7 @@ static int metadata_submit_io(
/* Submit IO */
env_atomic_inc(&mio->req_remaining);
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
return 0;

View File

@@ -85,10 +85,10 @@ static int _raw_atomic_io_discard_do(struct ocf_cache *cache, void *context,
ocf_io_configure(io, start_addr, len, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, ctx, NULL, _raw_atomic_io_discard_end);
if (cache->device->obj.features.discard_zeroes)
ocf_dobj_submit_discard(io);
if (cache->device->volume.features.discard_zeroes)
ocf_volume_submit_discard(io);
else
ocf_dobj_submit_write_zeroes(io);
ocf_volume_submit_write_zeroes(io);
return req->error;
}

View File

@@ -31,7 +31,7 @@ struct ocf_superblock_config {
ocf_metadata_layout_t metadata_layout;
uint32_t core_count;
unsigned long valid_object_bitmap[(OCF_CORE_MAX /
unsigned long valid_core_bitmap[(OCF_CORE_MAX /
(sizeof(unsigned long) * 8)) + 1];
ocf_cleaning_t cleaning_policy_type;

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);

View File

@@ -10,9 +10,9 @@
#include "ocf_priv.h"
#include "ocf_cache_priv.h"
ocf_data_obj_t ocf_cache_get_data_object(ocf_cache_t cache)
ocf_volume_t ocf_cache_get_volume(ocf_cache_t cache)
{
return ocf_cache_is_device_attached(cache) ? &cache->device->obj : NULL;
return ocf_cache_is_device_attached(cache) ? &cache->device->volume : NULL;
}
ocf_cache_id_t ocf_cache_get_id(ocf_cache_t cache)
@@ -87,8 +87,8 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
info->attached = ocf_cache_is_device_attached(cache);
if (info->attached) {
info->data_obj_type = ocf_ctx_get_data_obj_type_id(cache->owner,
cache->device->obj.type);
info->volume_type = ocf_ctx_get_volume_type_id(cache->owner,
cache->device->volume.type);
info->size = cache->conf_meta->cachelines;
}
info->core_count = cache->conf_meta->core_count;
@@ -99,7 +99,7 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
* valid objects may be not continuous
*/
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;
/* If current dirty blocks exceeds saved initial dirty
@@ -170,12 +170,12 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
return 0;
}
const struct ocf_data_obj_uuid *ocf_cache_get_uuid(ocf_cache_t cache)
const struct ocf_volume_uuid *ocf_cache_get_uuid(ocf_cache_t cache)
{
if (!ocf_cache_is_device_attached(cache))
return NULL;
return ocf_dobj_get_uuid(ocf_cache_get_data_object(cache));
return ocf_volume_get_uuid(ocf_cache_get_volume(cache));
}
uint8_t ocf_cache_get_type_id(ocf_cache_t cache)
@@ -183,8 +183,8 @@ uint8_t ocf_cache_get_type_id(ocf_cache_t cache)
if (!ocf_cache_is_device_attached(cache))
return 0xff;
return ocf_ctx_get_data_obj_type_id(ocf_cache_get_ctx(cache),
ocf_dobj_get_type(ocf_cache_get_data_object(cache)));
return ocf_ctx_get_volume_type_id(ocf_cache_get_ctx(cache),
ocf_volume_get_type(ocf_cache_get_volume(cache)));
}
ocf_cache_line_size_t ocf_cache_get_line_size(ocf_cache_t cache)
@@ -210,3 +210,15 @@ ocf_ctx_t ocf_cache_get_ctx(ocf_cache_t cache)
OCF_CHECK_NULL(cache);
return cache->owner;
}
void ocf_cache_set_priv(ocf_cache_t cache, void *priv)
{
OCF_CHECK_NULL(cache);
cache->priv = priv;
}
void *ocf_cache_get_priv(ocf_cache_t cache)
{
OCF_CHECK_NULL(cache);
return cache->priv;
}

View File

@@ -8,7 +8,7 @@
#include "ocf/ocf.h"
#include "ocf_env.h"
#include "ocf_data_obj_priv.h"
#include "ocf_volume_priv.h"
#include "ocf_core_priv.h"
#include "metadata/metadata_structs.h"
#include "metadata/metadata_partition_structs.h"
@@ -37,7 +37,7 @@ struct ocf_trace {
struct ocf_metadata_uuid {
uint32_t size;
uint8_t data[OCF_DATA_OBJ_UUID_MAX_SIZE];
uint8_t data[OCF_VOLUME_UUID_MAX_SIZE];
} __packed;
#define OCF_CORE_USER_DATA_SIZE 64
@@ -111,7 +111,7 @@ enum ocf_mngt_cache_init_mode {
/* Cache device */
struct ocf_cache_device {
struct ocf_data_obj obj;
struct ocf_volume volume;
ocf_cache_line_t metadata_offset_line;
@@ -226,6 +226,8 @@ struct ocf_cache {
void *cleaning_policy_context;
struct ocf_trace trace;
void *priv;
};
#define ocf_cache_log_prefix(cache, lvl, prefix, fmt, ...) \

View File

@@ -15,26 +15,26 @@
#include "ocf_request.h"
#include "ocf_trace_priv.h"
struct ocf_core_dobj {
struct ocf_core_volume {
ocf_core_t core;
};
ocf_cache_t ocf_core_get_cache(ocf_core_t core)
{
OCF_CHECK_NULL(core);
return core->obj.cache;
return core->volume.cache;
}
ocf_data_obj_t ocf_core_get_data_object(ocf_core_t core)
ocf_volume_t ocf_core_get_volume(ocf_core_t core)
{
OCF_CHECK_NULL(core);
return &core->obj;
return &core->volume;
}
ocf_data_obj_t ocf_core_get_front_data_object(ocf_core_t core)
ocf_volume_t ocf_core_get_front_volume(ocf_core_t core)
{
OCF_CHECK_NULL(core);
return &core->front_obj;
return &core->front_volume;
}
ocf_core_id_t ocf_core_get_id(ocf_core_t core)
@@ -44,7 +44,7 @@ ocf_core_id_t ocf_core_get_id(ocf_core_t core)
OCF_CHECK_NULL(core);
cache = core->obj.cache;
cache = core->volume.cache;
core_id = core - cache->core;
return core_id;
@@ -80,7 +80,7 @@ bool ocf_core_is_valid(ocf_cache_t cache, ocf_core_id_t id)
if (id > OCF_CORE_ID_MAX || id < OCF_CORE_ID_MIN)
return false;
if (!env_bit_test(id, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(id, cache->conf_meta->valid_core_bitmap))
return false;
return true;
@@ -97,10 +97,10 @@ int ocf_core_get(ocf_cache_t cache, ocf_core_id_t id, ocf_core_t *core)
return 0;
}
int ocf_core_set_uuid(ocf_core_t core, const struct ocf_data_obj_uuid *uuid)
int ocf_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid)
{
struct ocf_cache *cache;
struct ocf_data_obj_uuid *current_uuid;
struct ocf_volume_uuid *current_uuid;
int result;
int diff;
@@ -108,8 +108,8 @@ int ocf_core_set_uuid(ocf_core_t core, const struct ocf_data_obj_uuid *uuid)
OCF_CHECK_NULL(uuid);
OCF_CHECK_NULL(uuid->data);
cache = core->obj.cache;
current_uuid = &ocf_core_get_data_object(core)->uuid;
cache = core->volume.cache;
current_uuid = &ocf_core_get_volume(core)->uuid;
result = env_memcmp(current_uuid->data, current_uuid->size,
uuid->data, uuid->size, &diff);
@@ -125,7 +125,7 @@ int ocf_core_set_uuid(ocf_core_t core, const struct ocf_data_obj_uuid *uuid)
if (result)
return result;
ocf_dobj_set_uuid(&core->obj, uuid);
ocf_volume_set_uuid(&core->volume, uuid);
result = ocf_metadata_flush_superblock(cache);
if (result) {
@@ -217,7 +217,7 @@ int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
return -OCF_ERR_INVAL;
for (id = 0; id < OCF_CORE_MAX; id++) {
if (!env_bit_test(id, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(id, cache->conf_meta->valid_core_bitmap))
continue;
if (only_opened && !cache->core[id].opened)
@@ -238,11 +238,11 @@ static inline struct ocf_core_io *ocf_io_to_core_io(struct ocf_io *io)
return ocf_io_get_priv(io);
}
static inline ocf_core_t ocf_data_obj_to_core(ocf_data_obj_t obj)
static inline ocf_core_t ocf_volume_to_core(ocf_volume_t volume)
{
struct ocf_core_dobj *core_dobj = ocf_dobj_get_priv(obj);
struct ocf_core_volume *core_volume = ocf_volume_get_priv(volume);
return core_dobj->core;
return core_volume->core;
}
static inline void inc_dirty_req_counter(struct ocf_core_io *core_io,
@@ -273,19 +273,19 @@ static inline void dec_counter_if_req_was_dirty(struct ocf_core_io *core_io,
static inline int ocf_core_validate_io(struct ocf_io *io)
{
ocf_core_t core = ocf_data_obj_to_core(io->obj);
ocf_core_t core = ocf_volume_to_core(io->volume);
ocf_cache_t cache = ocf_core_get_cache(core);
if (!io->obj)
if (!io->volume)
return -EINVAL;
if (!io->ops)
return -EINVAL;
if (io->addr >= ocf_dobj_get_length(io->obj))
if (io->addr >= ocf_volume_get_length(io->volume))
return -EINVAL;
if (io->addr + io->bytes > ocf_dobj_get_length(io->obj))
if (io->addr + io->bytes > ocf_volume_get_length(io->volume))
return -EINVAL;
if (io->io_class >= OCF_IO_CLASS_MAX)
@@ -336,7 +336,7 @@ void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
core_io = ocf_io_to_core_io(io);
core = ocf_data_obj_to_core(io->obj);
core = ocf_volume_to_core(io->volume);
cache = ocf_core_get_cache(core);
ocf_trace_init_io(core_io, cache);
@@ -418,7 +418,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
core_io = ocf_io_to_core_io(io);
core = ocf_data_obj_to_core(io->obj);
core = ocf_volume_to_core(io->volume);
cache = ocf_core_get_cache(core);
if (unlikely(!env_bit_test(ocf_cache_state_running,
@@ -502,12 +502,12 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
return -EIO;
}
static void ocf_core_data_obj_submit_io(struct ocf_io *io)
static void ocf_core_volume_submit_io(struct ocf_io *io)
{
ocf_core_submit_io_mode(io, ocf_cache_mode_none);
}
static void ocf_core_data_obj_submit_flush(struct ocf_io *io)
static void ocf_core_volume_submit_flush(struct ocf_io *io)
{
struct ocf_core_io *core_io;
ocf_core_t core;
@@ -524,7 +524,7 @@ static void ocf_core_data_obj_submit_flush(struct ocf_io *io)
core_io = ocf_io_to_core_io(io);
core = ocf_data_obj_to_core(io->obj);
core = ocf_volume_to_core(io->volume);
cache = ocf_core_get_cache(core);
if (unlikely(!env_bit_test(ocf_cache_state_running,
@@ -550,7 +550,7 @@ static void ocf_core_data_obj_submit_flush(struct ocf_io *io)
ocf_engine_hndl_ops_req(core_io->req);
}
static void ocf_core_data_obj_submit_discard(struct ocf_io *io)
static void ocf_core_volume_submit_discard(struct ocf_io *io)
{
struct ocf_core_io *core_io;
ocf_core_t core;
@@ -567,7 +567,7 @@ static void ocf_core_data_obj_submit_discard(struct ocf_io *io)
core_io = ocf_io_to_core_io(io);
core = ocf_data_obj_to_core(io->obj);
core = ocf_volume_to_core(io->volume);
cache = ocf_core_get_cache(core);
if (unlikely(!env_bit_test(ocf_cache_state_running,
@@ -593,35 +593,35 @@ static void ocf_core_data_obj_submit_discard(struct ocf_io *io)
ocf_engine_hndl_discard_req(core_io->req);
}
/* *** DATA OBJECT OPS *** */
/* *** VOLUME OPS *** */
static int ocf_core_data_obj_open(ocf_data_obj_t obj)
static int ocf_core_volume_open(ocf_volume_t volume)
{
struct ocf_core_dobj *core_dobj = ocf_dobj_get_priv(obj);
const struct ocf_data_obj_uuid *uuid = ocf_dobj_get_uuid(obj);
struct ocf_core_volume *core_volume = ocf_volume_get_priv(volume);
const struct ocf_volume_uuid *uuid = ocf_volume_get_uuid(volume);
ocf_core_t core = (ocf_core_t)uuid->data;
core_dobj->core = core;
core_volume->core = core;
return 0;
}
static void ocf_core_data_obj_close(ocf_data_obj_t obj)
static void ocf_core_volume_close(ocf_volume_t volume)
{
}
static unsigned int ocf_core_data_obj_get_max_io_size(ocf_data_obj_t obj)
static unsigned int ocf_core_volume_get_max_io_size(ocf_volume_t volume)
{
ocf_core_t core = ocf_data_obj_to_core(obj);
ocf_core_t core = ocf_volume_to_core(volume);
return ocf_dobj_get_max_io_size(&core->obj);
return ocf_volume_get_max_io_size(&core->volume);
}
static uint64_t ocf_core_data_obj_get_byte_length(ocf_data_obj_t obj)
static uint64_t ocf_core_volume_get_byte_length(ocf_volume_t volume)
{
ocf_core_t core = ocf_data_obj_to_core(obj);
ocf_core_t core = ocf_volume_to_core(volume);
return ocf_dobj_get_length(&core->obj);
return ocf_volume_get_length(&core->volume);
}
@@ -653,23 +653,23 @@ static ctx_data_t *ocf_core_io_get_data(struct ocf_io *io)
return core_io->data;
}
const struct ocf_data_obj_properties ocf_core_data_obj_properties = {
const struct ocf_volume_properties ocf_core_volume_properties = {
.name = "OCF Core",
.io_priv_size = sizeof(struct ocf_core_io),
.dobj_priv_size = sizeof(struct ocf_core_dobj),
.volume_priv_size = sizeof(struct ocf_core_volume),
.caps = {
.atomic_writes = 0,
},
.ops = {
.submit_io = ocf_core_data_obj_submit_io,
.submit_flush = ocf_core_data_obj_submit_flush,
.submit_discard = ocf_core_data_obj_submit_discard,
.submit_io = ocf_core_volume_submit_io,
.submit_flush = ocf_core_volume_submit_flush,
.submit_discard = ocf_core_volume_submit_discard,
.submit_metadata = NULL,
.open = ocf_core_data_obj_open,
.close = ocf_core_data_obj_close,
.get_max_io_size = ocf_core_data_obj_get_max_io_size,
.get_length = ocf_core_data_obj_get_byte_length,
.open = ocf_core_volume_open,
.close = ocf_core_volume_close,
.get_max_io_size = ocf_core_volume_get_max_io_size,
.get_length = ocf_core_volume_get_byte_length,
},
.io_ops = {
.set_data = ocf_core_io_set_data,
@@ -677,13 +677,13 @@ const struct ocf_data_obj_properties ocf_core_data_obj_properties = {
},
};
int ocf_core_data_obj_type_init(ocf_ctx_t ctx)
int ocf_core_volume_type_init(ocf_ctx_t ctx)
{
return ocf_ctx_register_data_obj_type(ctx, 0,
&ocf_core_data_obj_properties);
return ocf_ctx_register_volume_type(ctx, 0,
&ocf_core_volume_properties);
}
void ocf_core_data_obj_type_deinit(ocf_ctx_t ctx)
void ocf_core_volume_type_deinit(ocf_ctx_t ctx)
{
ocf_ctx_unregister_data_obj_type(ctx, 0);
ocf_ctx_unregister_volume_type(ctx, 0);
}

View File

@@ -9,7 +9,7 @@
#include "ocf/ocf.h"
#include "ocf_env.h"
#include "ocf_ctx_priv.h"
#include "ocf_data_obj_priv.h"
#include "ocf_volume_priv.h"
#define ocf_core_log_prefix(core, lvl, prefix, fmt, ...) \
ocf_cache_log_prefix(ocf_core_get_cache(core), lvl, ".%s" prefix, \
@@ -35,8 +35,8 @@ struct ocf_core_io {
struct ocf_core {
char name[OCF_CORE_NAME_SIZE];
struct ocf_data_obj front_obj;
struct ocf_data_obj obj;
struct ocf_volume front_volume;
struct ocf_volume volume;
struct {
uint64_t last;
@@ -56,8 +56,8 @@ bool ocf_core_is_valid(ocf_cache_t cache, ocf_core_id_t id);
int ocf_core_set_user_metadata_raw(ocf_core_t core, void *data, size_t size);
int ocf_core_data_obj_type_init(ocf_ctx_t ctx);
int ocf_core_volume_type_init(ocf_ctx_t ctx);
void ocf_core_data_obj_type_deinit(ocf_ctx_t ctx);
void ocf_core_volume_type_deinit(ocf_ctx_t ctx);
#endif /* __OCF_CORE_PRIV_H__ */

View File

@@ -6,7 +6,7 @@
#include "ocf/ocf.h"
#include "ocf_ctx_priv.h"
#include "ocf_priv.h"
#include "ocf_data_obj_priv.h"
#include "ocf_volume_priv.h"
#include "ocf_utils.h"
#include "ocf_logger_priv.h"
#include "ocf_core_priv.h"
@@ -14,8 +14,8 @@
/*
*
*/
int ocf_ctx_register_data_obj_type(ocf_ctx_t ctx, uint8_t type_id,
const struct ocf_data_obj_properties *properties)
int ocf_ctx_register_volume_type(ocf_ctx_t ctx, uint8_t type_id,
const struct ocf_volume_properties *properties)
{
int result = 0;
@@ -24,14 +24,14 @@ int ocf_ctx_register_data_obj_type(ocf_ctx_t ctx, uint8_t type_id,
env_mutex_lock(&ctx->lock);
if (type_id >= OCF_DATA_OBJ_TYPE_MAX || ctx->data_obj_type[type_id]) {
if (type_id >= OCF_VOLUME_TYPE_MAX || ctx->volume_type[type_id]) {
env_mutex_unlock(&ctx->lock);
result = -EINVAL;
goto err;
}
ocf_data_obj_type_init(&ctx->data_obj_type[type_id], properties);
if (!ctx->data_obj_type[type_id])
ocf_volume_type_init(&ctx->volume_type[type_id], properties);
if (!ctx->volume_type[type_id])
result = -EINVAL;
env_mutex_unlock(&ctx->lock);
@@ -39,12 +39,12 @@ int ocf_ctx_register_data_obj_type(ocf_ctx_t ctx, uint8_t type_id,
if (result)
goto err;
ocf_log(ctx, log_debug, "'%s' data object operations registered\n",
ocf_log(ctx, log_debug, "'%s' volume operations registered\n",
properties->name);
return 0;
err:
ocf_log(ctx, log_err, "Failed to register data object operations '%s'",
ocf_log(ctx, log_err, "Failed to register volume operations '%s'",
properties->name);
return result;
}
@@ -52,15 +52,15 @@ err:
/*
*
*/
void ocf_ctx_unregister_data_obj_type(ocf_ctx_t ctx, uint8_t type_id)
void ocf_ctx_unregister_volume_type(ocf_ctx_t ctx, uint8_t type_id)
{
OCF_CHECK_NULL(ctx);
env_mutex_lock(&ctx->lock);
if (type_id < OCF_DATA_OBJ_TYPE_MAX && ctx->data_obj_type[type_id]) {
ocf_data_obj_type_deinit(ctx->data_obj_type[type_id]);
ctx->data_obj_type[type_id] = NULL;
if (type_id < OCF_VOLUME_TYPE_MAX && ctx->volume_type[type_id]) {
ocf_volume_type_deinit(ctx->volume_type[type_id]);
ctx->volume_type[type_id] = NULL;
}
env_mutex_unlock(&ctx->lock);
@@ -69,27 +69,27 @@ void ocf_ctx_unregister_data_obj_type(ocf_ctx_t ctx, uint8_t type_id)
/*
*
*/
ocf_data_obj_type_t ocf_ctx_get_data_obj_type(ocf_ctx_t ctx, uint8_t type_id)
ocf_volume_type_t ocf_ctx_get_volume_type(ocf_ctx_t ctx, uint8_t type_id)
{
OCF_CHECK_NULL(ctx);
if (type_id >= OCF_DATA_OBJ_TYPE_MAX)
if (type_id >= OCF_VOLUME_TYPE_MAX)
return NULL;
return ctx->data_obj_type[type_id];
return ctx->volume_type[type_id];
}
/*
*
*/
int ocf_ctx_get_data_obj_type_id(ocf_ctx_t ctx, ocf_data_obj_type_t type)
int ocf_ctx_get_volume_type_id(ocf_ctx_t ctx, ocf_volume_type_t type)
{
int i;
OCF_CHECK_NULL(ctx);
for (i = 0; i < OCF_DATA_OBJ_TYPE_MAX; ++i) {
if (ctx->data_obj_type[i] == type)
for (i = 0; i < OCF_VOLUME_TYPE_MAX; ++i) {
if (ctx->volume_type[i] == type)
return i;
}
@@ -99,15 +99,15 @@ int ocf_ctx_get_data_obj_type_id(ocf_ctx_t ctx, ocf_data_obj_type_t type)
/*
*
*/
int ocf_ctx_data_obj_create(ocf_ctx_t ctx, ocf_data_obj_t *obj,
struct ocf_data_obj_uuid *uuid, uint8_t type_id)
int ocf_ctx_volume_create(ocf_ctx_t ctx, ocf_volume_t *volume,
struct ocf_volume_uuid *uuid, uint8_t type_id)
{
OCF_CHECK_NULL(ctx);
if (type_id >= OCF_DATA_OBJ_TYPE_MAX)
if (type_id >= OCF_VOLUME_TYPE_MAX)
return -EINVAL;
return ocf_dobj_create(obj, ctx->data_obj_type[type_id], uuid);
return ocf_volume_create(volume, ctx->volume_type[type_id], uuid);
}
/*
@@ -143,7 +143,7 @@ int ocf_ctx_init(ocf_ctx_t *ctx, const struct ocf_ctx_config *cfg)
if (ret)
goto err_logger;
ret = ocf_core_data_obj_type_init(ocf_ctx);
ret = ocf_core_volume_type_init(ocf_ctx);
if (ret)
goto err_utils;
@@ -177,7 +177,7 @@ int ocf_ctx_exit(ocf_ctx_t ctx)
if (result)
return result;
ocf_core_data_obj_type_deinit(ctx);
ocf_core_volume_type_deinit(ctx);
ocf_utils_deinit(ctx);
ocf_logger_close(&ctx->logger);

View File

@@ -10,7 +10,7 @@
#include "ocf/ocf_ctx.h"
#include "ocf_logger_priv.h"
#define OCF_DATA_OBJ_TYPE_MAX 8
#define OCF_VOLUME_TYPE_MAX 8
/**
* @brief OCF main control structure
@@ -19,7 +19,7 @@ struct ocf_ctx {
const struct ocf_ctx_ops *ops;
const struct ocf_ctx_config *cfg;
struct ocf_logger logger;
struct ocf_data_obj_type *data_obj_type[OCF_DATA_OBJ_TYPE_MAX];
struct ocf_volume_type *volume_type[OCF_VOLUME_TYPE_MAX];
env_mutex lock;
struct list_head caches;
struct {

View File

@@ -1,310 +0,0 @@
/*
* Copyright(c) 2012-2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#include "ocf/ocf.h"
#include "ocf_priv.h"
#include "ocf_data_obj_priv.h"
#include "ocf_io_priv.h"
#include "ocf_env.h"
/* *** Bottom interface *** */
/*
* Data object type
*/
int ocf_data_obj_type_init(struct ocf_data_obj_type **type,
const struct ocf_data_obj_properties *properties)
{
const struct ocf_data_obj_ops *ops = &properties->ops;
struct ocf_data_obj_type *new_type;
int ret;
if (!ops->submit_io || !ops->open || !ops->close ||
!ops->get_max_io_size || !ops->get_length) {
return -EINVAL;
}
if (properties->caps.atomic_writes && !ops->submit_metadata)
return -EINVAL;
new_type = env_zalloc(sizeof(**type), ENV_MEM_NORMAL);
if (!new_type)
return -OCF_ERR_NO_MEM;
new_type->allocator = ocf_io_allocator_create(
properties->io_priv_size, properties->name);
if (!new_type->allocator) {
ret = -ENOMEM;
goto err;
}
new_type->properties = properties;
*type = new_type;
return 0;
err:
env_free(new_type);
return ret;
}
void ocf_data_obj_type_deinit(struct ocf_data_obj_type *type)
{
ocf_io_allocator_destroy(type->allocator);
env_free(type);
}
/*
* Data object frontend API
*/
int ocf_dobj_init(ocf_data_obj_t obj, ocf_data_obj_type_t type,
struct ocf_data_obj_uuid *uuid, bool uuid_copy)
{
uint32_t priv_size = type->properties->dobj_priv_size;
void *data;
int ret;
if (!obj || !type)
return -OCF_ERR_INVAL;
obj->opened = false;
obj->type = type;
obj->priv = env_zalloc(priv_size, ENV_MEM_NORMAL);
if (!obj->priv)
return -OCF_ERR_NO_MEM;
if (!uuid) {
obj->uuid.size = 0;
obj->uuid.data = NULL;
obj->uuid_copy = false;
return 0;
}
obj->uuid_copy = uuid_copy;
if (uuid_copy) {
data = env_vmalloc(uuid->size);
if (!data)
goto err;
ret = env_memcpy(data, uuid->size, uuid->data, uuid->size);
if (ret) {
env_vfree(data);
goto err;
}
obj->uuid.data = data;
} else {
obj->uuid.data = uuid->data;
}
obj->uuid.size = uuid->size;
return 0;
err:
env_free(obj->priv);
return -OCF_ERR_NO_MEM;
}
void ocf_dobj_deinit(ocf_data_obj_t obj)
{
OCF_CHECK_NULL(obj);
env_free(obj->priv);
if (obj->uuid_copy && obj->uuid.data)
env_vfree(obj->uuid.data);
}
void ocf_dobj_move(ocf_data_obj_t obj, ocf_data_obj_t from)
{
OCF_CHECK_NULL(obj);
OCF_CHECK_NULL(from);
ocf_dobj_deinit(obj);
obj->opened = from->opened;
obj->type = from->type;
obj->uuid = from->uuid;
obj->uuid_copy = from->uuid_copy;
obj->priv = from->priv;
obj->cache = from->cache;
obj->features = from->features;
/*
* Deinitialize original object without freeing resources.
*/
from->opened = false;
from->priv = NULL;
}
int ocf_dobj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
struct ocf_data_obj_uuid *uuid)
{
ocf_data_obj_t tmp_obj;
int ret;
OCF_CHECK_NULL(obj);
tmp_obj = env_zalloc(sizeof(*tmp_obj), ENV_MEM_NORMAL);
if (!tmp_obj)
return -OCF_ERR_NO_MEM;
ret = ocf_dobj_init(tmp_obj, type, uuid, true);
if (ret) {
env_free(tmp_obj);
return ret;
}
*obj = tmp_obj;
return 0;
}
void ocf_dobj_destroy(ocf_data_obj_t obj)
{
OCF_CHECK_NULL(obj);
ocf_dobj_deinit(obj);
env_free(obj);
}
ocf_data_obj_type_t ocf_dobj_get_type(ocf_data_obj_t obj)
{
OCF_CHECK_NULL(obj);
return obj->type;
}
const struct ocf_data_obj_uuid *ocf_dobj_get_uuid(ocf_data_obj_t obj)
{
OCF_CHECK_NULL(obj);
return &obj->uuid;
}
void ocf_dobj_set_uuid(ocf_data_obj_t obj, const struct ocf_data_obj_uuid *uuid)
{
OCF_CHECK_NULL(obj);
if (obj->uuid_copy && obj->uuid.data)
env_vfree(obj->uuid.data);
obj->uuid.data = uuid->data;
obj->uuid.size = uuid->size;
}
void *ocf_dobj_get_priv(ocf_data_obj_t obj)
{
return obj->priv;
}
ocf_cache_t ocf_dobj_get_cache(ocf_data_obj_t obj)
{
OCF_CHECK_NULL(obj);
return obj->cache;
}
int ocf_dobj_is_atomic(ocf_data_obj_t obj)
{
return obj->type->properties->caps.atomic_writes;
}
struct ocf_io *ocf_dobj_new_io(ocf_data_obj_t obj)
{
if (!obj->opened)
return NULL;
return ocf_io_new(obj);
}
void ocf_dobj_submit_io(struct ocf_io *io)
{
ENV_BUG_ON(!io->obj->type->properties->ops.submit_io);
if (!io->obj->opened)
io->end(io, -EIO);
io->obj->type->properties->ops.submit_io(io);
}
void ocf_dobj_submit_flush(struct ocf_io *io)
{
ENV_BUG_ON(!io->obj->type->properties->ops.submit_flush);
if (!io->obj->opened)
io->end(io, -EIO);
if (!io->obj->type->properties->ops.submit_flush) {
ocf_io_end(io, 0);
return;
}
io->obj->type->properties->ops.submit_flush(io);
}
void ocf_dobj_submit_discard(struct ocf_io *io)
{
if (!io->obj->opened)
io->end(io, -EIO);
if (!io->obj->type->properties->ops.submit_discard) {
ocf_io_end(io, 0);
return;
}
io->obj->type->properties->ops.submit_discard(io);
}
int ocf_dobj_open(ocf_data_obj_t obj)
{
int ret;
ENV_BUG_ON(!obj->type->properties->ops.open);
ENV_BUG_ON(obj->opened);
ret = obj->type->properties->ops.open(obj);
if (ret)
return ret;
obj->opened = true;
return 0;
}
void ocf_dobj_close(ocf_data_obj_t obj)
{
ENV_BUG_ON(!obj->type->properties->ops.close);
ENV_BUG_ON(!obj->opened);
obj->type->properties->ops.close(obj);
obj->opened = false;
}
unsigned int ocf_dobj_get_max_io_size(ocf_data_obj_t obj)
{
ENV_BUG_ON(!obj->type->properties->ops.get_max_io_size);
if (!obj->opened)
return 0;
return obj->type->properties->ops.get_max_io_size(obj);
}
uint64_t ocf_dobj_get_length(ocf_data_obj_t obj)
{
ENV_BUG_ON(!obj->type->properties->ops.get_length);
if (!obj->opened)
return 0;
return obj->type->properties->ops.get_length(obj);
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright(c) 2012-2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef __OCF_DATA_OBJ_PRIV_H__
#define __OCF_DATA_OBJ_PRIV_H__
#include "ocf_env.h"
#include "ocf_io_priv.h"
struct ocf_data_obj_type {
const struct ocf_data_obj_properties *properties;
env_allocator *allocator;
};
struct ocf_data_obj {
ocf_data_obj_type_t type;
struct ocf_data_obj_uuid uuid;
bool opened;
bool uuid_copy;
void *priv;
ocf_cache_t cache;
struct list_head core_pool_item;
struct {
unsigned discard_zeroes:1;
/* true if reading discarded pages returns 0 */
} features;
};
int ocf_data_obj_type_init(struct ocf_data_obj_type **type,
const struct ocf_data_obj_properties *properties);
void ocf_data_obj_type_deinit(struct ocf_data_obj_type *type);
void ocf_dobj_move(ocf_data_obj_t obj, ocf_data_obj_t from);
void ocf_dobj_set_uuid(ocf_data_obj_t obj,
const struct ocf_data_obj_uuid *uuid);
static inline void ocf_dobj_submit_metadata(struct ocf_io *io)
{
ENV_BUG_ON(!io->obj->type->properties->ops.submit_metadata);
io->obj->type->properties->ops.submit_metadata(io);
}
static inline void ocf_dobj_submit_write_zeroes(struct ocf_io *io)
{
ENV_BUG_ON(!io->obj->type->properties->ops.submit_write_zeroes);
io->obj->type->properties->ops.submit_write_zeroes(io);
}
#endif /*__OCF_DATA_OBJ_PRIV_H__ */

View File

@@ -5,7 +5,7 @@
#include "ocf/ocf.h"
#include "ocf_io_priv.h"
#include "ocf_data_obj_priv.h"
#include "ocf_volume_priv.h"
/*
* This is io allocator dedicated for bottom devices.
@@ -48,13 +48,13 @@ void *ocf_io_get_meta(struct ocf_io* io)
return (void *)io - sizeof(struct ocf_io_meta);
}
struct ocf_io *ocf_io_new(ocf_data_obj_t obj)
struct ocf_io *ocf_io_new(ocf_volume_t volume)
{
struct ocf_io *io;
struct ocf_io_meta *io_meta;
void *data;
data = env_allocator_new(obj->type->allocator);
data = env_allocator_new(volume->type->allocator);
if (!data)
return NULL;
@@ -62,8 +62,8 @@ struct ocf_io *ocf_io_new(ocf_data_obj_t obj)
io_meta = ocf_io_get_meta(io);
io->obj = obj;
io->ops = &obj->type->properties->io_ops;
io->volume = volume;
io->ops = &volume->type->properties->io_ops;
env_atomic_set(&io_meta->ref_count, 1);
return io;
@@ -92,6 +92,6 @@ void ocf_io_put(struct ocf_io *io)
if (env_atomic_dec_return(&io_meta->ref_count))
return;
env_allocator_del(io->obj->type->allocator,
env_allocator_del(io->volume->type->allocator,
(void *)io - sizeof(struct ocf_io_meta));
}

View File

@@ -18,7 +18,7 @@ env_allocator *ocf_io_allocator_create(uint32_t size, const char *name);
void ocf_io_allocator_destroy(env_allocator *allocator);
struct ocf_io *ocf_io_new(ocf_data_obj_t obj);
struct ocf_io *ocf_io_new(ocf_volume_t volume);
static inline void ocf_io_start(struct ocf_io *io)
{

View File

@@ -30,7 +30,7 @@ int ocf_metadata_get_atomic_entry(ocf_cache_t cache,
OCF_CHECK_NULL(cache);
OCF_CHECK_NULL(entry);
if (addr > ocf_dobj_get_length(&cache->device->obj))
if (addr > ocf_volume_get_length(&cache->device->volume))
return -EFAULT;
if (addr < cache->device->metadata_offset) {

View File

@@ -97,7 +97,7 @@ void ocf_core_stats_initialize_all(ocf_cache_t cache)
ocf_core_id_t id;
for (id = 0; id < OCF_CORE_MAX; id++) {
if (!env_bit_test(id, cache->conf_meta->valid_object_bitmap))
if (!env_bit_test(id, cache->conf_meta->valid_core_bitmap))
continue;
ocf_core_stats_initialize(&cache->core[id]);
@@ -234,8 +234,8 @@ int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
ENV_BUG_ON(env_memset(stats, sizeof(*stats), 0));
stats->core_size_bytes = ocf_dobj_get_length(
&cache->core[core_id].obj);
stats->core_size_bytes = ocf_volume_get_length(
&cache->core[core_id].volume);
stats->core_size = ocf_bytes_2_lines_round_up(cache,
stats->core_size_bytes);
stats->seq_cutoff_threshold = ocf_core_get_seq_cutoff_threshold(core);
@@ -244,8 +244,8 @@ int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
env_atomic_read(&cache->core_runtime_meta[core_id].cached_clines);
copy_block_stats(&stats->core_obj, &core_stats->core_blocks);
copy_block_stats(&stats->cache_obj, &core_stats->cache_blocks);
copy_block_stats(&stats->core_volume, &core_stats->core_blocks);
copy_block_stats(&stats->cache_volume, &core_stats->cache_blocks);
copy_error_stats(&stats->core_errors,
&core_stats->core_errors);

View File

@@ -50,7 +50,7 @@ static uint64_t _get_cache_occupancy(ocf_cache_t cache)
uint32_t 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;
result += env_atomic_read(
@@ -103,21 +103,21 @@ static void _fill_blocks(struct ocf_stats_blocks *blocks,
{
uint64_t rd, wr, total;
/* Core data object */
rd = _bytes4k(s->core_obj.read);
wr = _bytes4k(s->core_obj.write);
/* Core volume */
rd = _bytes4k(s->core_volume.read);
wr = _bytes4k(s->core_volume.write);
total = rd + wr;
_set(&blocks->core_obj_rd, rd, total);
_set(&blocks->core_obj_wr, wr, total);
_set(&blocks->core_obj_total, total, total);
_set(&blocks->core_volume_rd, rd, total);
_set(&blocks->core_volume_wr, wr, total);
_set(&blocks->core_volume_total, total, total);
/* Cache data object */
rd = _bytes4k(s->cache_obj.read);
wr = _bytes4k(s->cache_obj.write);
/* Cache volume */
rd = _bytes4k(s->cache_volume.read);
wr = _bytes4k(s->cache_volume.write);
total = rd + wr;
_set(&blocks->cache_obj_rd, rd, total);
_set(&blocks->cache_obj_wr, wr, total);
_set(&blocks->cache_obj_total, total, total);
_set(&blocks->cache_volume_rd, rd, total);
_set(&blocks->cache_volume_wr, wr, total);
_set(&blocks->cache_volume_total, total, total);
/* Core (cache volume) */
rd = _bytes4k(s->core.read);
@@ -136,16 +136,16 @@ static void _fill_errors(struct ocf_stats_errors *errors,
rd = s->core_errors.read;
wr = s->core_errors.write;
total = rd + wr;
_set(&errors->core_obj_rd, rd, total);
_set(&errors->core_obj_wr, wr, total);
_set(&errors->core_obj_total, total, total);
_set(&errors->core_volume_rd, rd, total);
_set(&errors->core_volume_wr, wr, total);
_set(&errors->core_volume_total, total, total);
rd = s->cache_errors.read;
wr = s->cache_errors.write;
total = rd + wr;
_set(&errors->cache_obj_rd, rd, total);
_set(&errors->cache_obj_wr, wr, total);
_set(&errors->cache_obj_total, total, total);
_set(&errors->cache_volume_rd, rd, total);
_set(&errors->cache_volume_wr, wr, total);
_set(&errors->cache_volume_total, total, total);
total = s->core_errors.read + s->core_errors.write +
s->cache_errors.read + s->cache_errors.write;
@@ -242,8 +242,8 @@ static int _accumulate_stats(ocf_core_t core, void *cntx)
if (result)
return result;
_accumulate_block(&total->cache_obj, &stats.cache_obj);
_accumulate_block(&total->core_obj, &stats.core_obj);
_accumulate_block(&total->cache_volume, &stats.cache_volume);
_accumulate_block(&total->core_volume, &stats.core_volume);
_accumulate_block(&total->core, &stats.core);
_accumulate_reqs(&total->read_reqs, &stats.read_reqs);

View File

@@ -28,8 +28,8 @@ static int _ocf_core_desc(ocf_core_t core, void *ctx)
env_ticks_to_nsecs(env_get_tick_count()),
sizeof(core_desc));
core_desc.id = ocf_core_get_id(core);
core_desc.core_size = ocf_dobj_get_length(
ocf_core_get_data_object(core));
core_desc.core_size = ocf_volume_get_length(
ocf_core_get_volume(core));
ocf_trace_push(cache, visitor_ctx->io_queue,
&core_desc, sizeof(core_desc));
@@ -54,8 +54,8 @@ static int _ocf_trace_cache_info(ocf_cache_t cache, uint32_t io_queue)
if (ocf_cache_is_device_attached(cache)) {
/* Attached cache */
cache_desc.cache_size = ocf_dobj_get_length(
ocf_cache_get_data_object(cache));
cache_desc.cache_size = ocf_volume_get_length(
ocf_cache_get_volume(cache));
} else {
cache_desc.cache_size = 0;
}

310
src/ocf_volume.c Normal file
View File

@@ -0,0 +1,310 @@
/*
* Copyright(c) 2012-2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#include "ocf/ocf.h"
#include "ocf_priv.h"
#include "ocf_volume_priv.h"
#include "ocf_io_priv.h"
#include "ocf_env.h"
/* *** Bottom interface *** */
/*
* Volume type
*/
int ocf_volume_type_init(struct ocf_volume_type **type,
const struct ocf_volume_properties *properties)
{
const struct ocf_volume_ops *ops = &properties->ops;
struct ocf_volume_type *new_type;
int ret;
if (!ops->submit_io || !ops->open || !ops->close ||
!ops->get_max_io_size || !ops->get_length) {
return -EINVAL;
}
if (properties->caps.atomic_writes && !ops->submit_metadata)
return -EINVAL;
new_type = env_zalloc(sizeof(**type), ENV_MEM_NORMAL);
if (!new_type)
return -OCF_ERR_NO_MEM;
new_type->allocator = ocf_io_allocator_create(
properties->io_priv_size, properties->name);
if (!new_type->allocator) {
ret = -ENOMEM;
goto err;
}
new_type->properties = properties;
*type = new_type;
return 0;
err:
env_free(new_type);
return ret;
}
void ocf_volume_type_deinit(struct ocf_volume_type *type)
{
ocf_io_allocator_destroy(type->allocator);
env_free(type);
}
/*
* Volume frontend API
*/
int ocf_volume_init(ocf_volume_t volume, ocf_volume_type_t type,
struct ocf_volume_uuid *uuid, bool uuid_copy)
{
uint32_t priv_size = type->properties->volume_priv_size;
void *data;
int ret;
if (!volume || !type)
return -OCF_ERR_INVAL;
volume->opened = false;
volume->type = type;
volume->priv = env_zalloc(priv_size, ENV_MEM_NORMAL);
if (!volume->priv)
return -OCF_ERR_NO_MEM;
if (!uuid) {
volume->uuid.size = 0;
volume->uuid.data = NULL;
volume->uuid_copy = false;
return 0;
}
volume->uuid_copy = uuid_copy;
if (uuid_copy) {
data = env_vmalloc(uuid->size);
if (!data)
goto err;
ret = env_memcpy(data, uuid->size, uuid->data, uuid->size);
if (ret) {
env_vfree(data);
goto err;
}
volume->uuid.data = data;
} else {
volume->uuid.data = uuid->data;
}
volume->uuid.size = uuid->size;
return 0;
err:
env_free(volume->priv);
return -OCF_ERR_NO_MEM;
}
void ocf_volume_deinit(ocf_volume_t volume)
{
OCF_CHECK_NULL(volume);
env_free(volume->priv);
if (volume->uuid_copy && volume->uuid.data)
env_vfree(volume->uuid.data);
}
void ocf_volume_move(ocf_volume_t volume, ocf_volume_t from)
{
OCF_CHECK_NULL(volume);
OCF_CHECK_NULL(from);
ocf_volume_deinit(volume);
volume->opened = from->opened;
volume->type = from->type;
volume->uuid = from->uuid;
volume->uuid_copy = from->uuid_copy;
volume->priv = from->priv;
volume->cache = from->cache;
volume->features = from->features;
/*
* Deinitialize original volume without freeing resources.
*/
from->opened = false;
from->priv = NULL;
}
int ocf_volume_create(ocf_volume_t *volume, ocf_volume_type_t type,
struct ocf_volume_uuid *uuid)
{
ocf_volume_t tmp_volume;
int ret;
OCF_CHECK_NULL(volume);
tmp_volume = env_zalloc(sizeof(*tmp_volume), ENV_MEM_NORMAL);
if (!tmp_volume)
return -OCF_ERR_NO_MEM;
ret = ocf_volume_init(tmp_volume, type, uuid, true);
if (ret) {
env_free(tmp_volume);
return ret;
}
*volume = tmp_volume;
return 0;
}
void ocf_volume_destroy(ocf_volume_t volume)
{
OCF_CHECK_NULL(volume);
ocf_volume_deinit(volume);
env_free(volume);
}
ocf_volume_type_t ocf_volume_get_type(ocf_volume_t volume)
{
OCF_CHECK_NULL(volume);
return volume->type;
}
const struct ocf_volume_uuid *ocf_volume_get_uuid(ocf_volume_t volume)
{
OCF_CHECK_NULL(volume);
return &volume->uuid;
}
void ocf_volume_set_uuid(ocf_volume_t volume, const struct ocf_volume_uuid *uuid)
{
OCF_CHECK_NULL(volume);
if (volume->uuid_copy && volume->uuid.data)
env_vfree(volume->uuid.data);
volume->uuid.data = uuid->data;
volume->uuid.size = uuid->size;
}
void *ocf_volume_get_priv(ocf_volume_t volume)
{
return volume->priv;
}
ocf_cache_t ocf_volume_get_cache(ocf_volume_t volume)
{
OCF_CHECK_NULL(volume);
return volume->cache;
}
int ocf_volume_is_atomic(ocf_volume_t volume)
{
return volume->type->properties->caps.atomic_writes;
}
struct ocf_io *ocf_volume_new_io(ocf_volume_t volume)
{
if (!volume->opened)
return NULL;
return ocf_io_new(volume);
}
void ocf_volume_submit_io(struct ocf_io *io)
{
ENV_BUG_ON(!io->volume->type->properties->ops.submit_io);
if (!io->volume->opened)
io->end(io, -EIO);
io->volume->type->properties->ops.submit_io(io);
}
void ocf_volume_submit_flush(struct ocf_io *io)
{
ENV_BUG_ON(!io->volume->type->properties->ops.submit_flush);
if (!io->volume->opened)
io->end(io, -EIO);
if (!io->volume->type->properties->ops.submit_flush) {
ocf_io_end(io, 0);
return;
}
io->volume->type->properties->ops.submit_flush(io);
}
void ocf_volume_submit_discard(struct ocf_io *io)
{
if (!io->volume->opened)
io->end(io, -EIO);
if (!io->volume->type->properties->ops.submit_discard) {
ocf_io_end(io, 0);
return;
}
io->volume->type->properties->ops.submit_discard(io);
}
int ocf_volume_open(ocf_volume_t volume)
{
int ret;
ENV_BUG_ON(!volume->type->properties->ops.open);
ENV_BUG_ON(volume->opened);
ret = volume->type->properties->ops.open(volume);
if (ret)
return ret;
volume->opened = true;
return 0;
}
void ocf_volume_close(ocf_volume_t volume)
{
ENV_BUG_ON(!volume->type->properties->ops.close);
ENV_BUG_ON(!volume->opened);
volume->type->properties->ops.close(volume);
volume->opened = false;
}
unsigned int ocf_volume_get_max_io_size(ocf_volume_t volume)
{
ENV_BUG_ON(!volume->type->properties->ops.get_max_io_size);
if (!volume->opened)
return 0;
return volume->type->properties->ops.get_max_io_size(volume);
}
uint64_t ocf_volume_get_length(ocf_volume_t volume)
{
ENV_BUG_ON(!volume->type->properties->ops.get_length);
if (!volume->opened)
return 0;
return volume->type->properties->ops.get_length(volume);
}

55
src/ocf_volume_priv.h Normal file
View File

@@ -0,0 +1,55 @@
/*
* Copyright(c) 2012-2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef __OCF_VOLUME_PRIV_H__
#define __OCF_VOLUME_PRIV_H__
#include "ocf_env.h"
#include "ocf_io_priv.h"
struct ocf_volume_type {
const struct ocf_volume_properties *properties;
env_allocator *allocator;
};
struct ocf_volume {
ocf_volume_type_t type;
struct ocf_volume_uuid uuid;
bool opened;
bool uuid_copy;
void *priv;
ocf_cache_t cache;
struct list_head core_pool_item;
struct {
unsigned discard_zeroes:1;
/* true if reading discarded pages returns 0 */
} features;
};
int ocf_volume_type_init(struct ocf_volume_type **type,
const struct ocf_volume_properties *properties);
void ocf_volume_type_deinit(struct ocf_volume_type *type);
void ocf_volume_move(ocf_volume_t volume, ocf_volume_t from);
void ocf_volume_set_uuid(ocf_volume_t volume,
const struct ocf_volume_uuid *uuid);
static inline void ocf_volume_submit_metadata(struct ocf_io *io)
{
ENV_BUG_ON(!io->volume->type->properties->ops.submit_metadata);
io->volume->type->properties->ops.submit_metadata(io);
}
static inline void ocf_volume_submit_write_zeroes(struct ocf_io *io)
{
ENV_BUG_ON(!io->volume->type->properties->ops.submit_write_zeroes);
io->volume->type->properties->ops.submit_write_zeroes(io);
}
#endif /*__OCF_VOLUME_PRIV_H__ */

View File

@@ -277,7 +277,7 @@ static int _ocf_cleaner_fire_flush_cache(struct ocf_request *req)
OCF_DEBUG_TRACE(req->cache);
io = ocf_dobj_new_io(&req->cache->device->obj);
io = ocf_volume_new_io(&req->cache->device->volume);
if (!io) {
ocf_metadata_error(req->cache);
req->error = -ENOMEM;
@@ -287,7 +287,7 @@ static int _ocf_cleaner_fire_flush_cache(struct ocf_request *req)
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, req, NULL, _ocf_cleaner_flush_cache_io_end);
ocf_dobj_submit_flush(io);
ocf_volume_submit_flush(io);
return 0;
}
@@ -432,7 +432,7 @@ static int _ocf_cleaner_fire_flush_cores(struct ocf_request *req)
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, iter, req, _ocf_cleaner_flush_cores_io_cmpl);
ocf_dobj_submit_flush(io);
ocf_volume_submit_flush(io);
}
/* Protect IO completion race */
@@ -519,7 +519,7 @@ static void _ocf_cleaner_core_io_for_dirty_range(struct ocf_request *req,
env_atomic_inc(&req->req_remaining);
/* Send IO */
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
return;
error:
@@ -695,7 +695,7 @@ static int _ocf_cleaner_fire_cache(struct ocf_request *req)
env_atomic64_add(ocf_line_size(cache), &cache_stats->read_bytes);
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
}
/* Protect IO completion race */

View File

@@ -6,7 +6,7 @@
#ifndef UTILS_DEVICE_H_
#define UTILS_DEVICE_H_
static inline int _ocf_uuid_set(const struct ocf_data_obj_uuid *uuid,
static inline int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
struct ocf_metadata_uuid *muuid)
{
int result;
@@ -36,8 +36,8 @@ static inline int _ocf_uuid_set(const struct ocf_data_obj_uuid *uuid,
}
static inline int ocf_metadata_set_core_uuid(ocf_core_t core,
const struct ocf_data_obj_uuid *uuid,
struct ocf_data_obj_uuid *new_uuid)
const struct ocf_volume_uuid *uuid,
struct ocf_volume_uuid *new_uuid)
{
ocf_cache_t cache = ocf_core_get_cache(core);
struct ocf_metadata_uuid *muuid = ocf_metadata_get_core_uuid(cache,
@@ -56,7 +56,7 @@ static inline int ocf_metadata_set_core_uuid(ocf_core_t core,
static inline void ocf_metadata_clear_core_uuid(ocf_core_t core)
{
struct ocf_data_obj_uuid uuid = { .size = 0, };
struct ocf_volume_uuid uuid = { .size = 0, };
ocf_metadata_set_core_uuid(core, &uuid, NULL);
}

View File

@@ -6,7 +6,7 @@
#include "ocf/ocf.h"
#include "../ocf_priv.h"
#include "../ocf_cache_priv.h"
#include "../ocf_data_obj_priv.h"
#include "../ocf_volume_priv.h"
#include "../ocf_request.h"
#include "utils_io.h"
#include "utils_cache_line.h"
@@ -27,7 +27,7 @@ struct discard_io_request {
int error;
};
static void _ocf_obj_flush_end(struct ocf_io *io, int err)
static void _ocf_volume_flush_end(struct ocf_io *io, int err)
{
struct ocf_submit_io_wait_context *cntx = io->priv1;
cntx->error = err;
@@ -36,7 +36,7 @@ static void _ocf_obj_flush_end(struct ocf_io *io, int err)
ocf_io_put(io);
}
int ocf_submit_obj_flush_wait(ocf_data_obj_t obj)
int ocf_submit_volume_flush_wait(ocf_volume_t volume)
{
struct ocf_submit_io_wait_context cntx = { };
struct ocf_io *io;
@@ -44,14 +44,14 @@ int ocf_submit_obj_flush_wait(ocf_data_obj_t obj)
env_atomic_set(&cntx.req_remaining, 1);
env_completion_init(&cntx.complete);
io = ocf_dobj_new_io(obj);
io = ocf_volume_new_io(volume);
if (!io)
return -ENOMEM;
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, &cntx, NULL, _ocf_obj_flush_end);
ocf_io_set_cmpl(io, &cntx, NULL, _ocf_volume_flush_end);
ocf_dobj_submit_flush(io);
ocf_volume_submit_flush(io);
env_completion_wait(&cntx.complete);
@@ -59,7 +59,7 @@ int ocf_submit_obj_flush_wait(ocf_data_obj_t obj)
}
static void ocf_submit_obj_discard_wait_io(struct ocf_io *io, int error)
static void ocf_submit_volume_discard_wait_io(struct ocf_io *io, int error)
{
struct ocf_submit_io_wait_context *cntx = io->priv1;
@@ -75,7 +75,7 @@ static void ocf_submit_obj_discard_wait_io(struct ocf_io *io, int error)
env_completion_complete(&cntx->complete);
}
int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
int ocf_submit_volume_discard_wait(ocf_volume_t volume, uint64_t addr,
uint64_t length)
{
struct ocf_submit_io_wait_context cntx = { };
@@ -87,7 +87,7 @@ int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
env_completion_init(&cntx.complete);
while (length) {
struct ocf_io *io = ocf_dobj_new_io(obj);
struct ocf_io *io = ocf_volume_new_io(volume);
if (!io) {
cntx.error = -ENOMEM;
@@ -100,8 +100,8 @@ int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
ocf_io_configure(io, addr, bytes, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, &cntx, NULL,
ocf_submit_obj_discard_wait_io);
ocf_dobj_submit_discard(io);
ocf_submit_volume_discard_wait_io);
ocf_volume_submit_discard(io);
addr += bytes;
length -= bytes;
@@ -115,7 +115,7 @@ int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
return cntx.error;
}
static void ocf_submit_obj_zeroes_wait_io(struct ocf_io *io, int error)
static void ocf_submit_volume_zeroes_wait_io(struct ocf_io *io, int error)
{
struct ocf_submit_io_wait_context *cntx = io->priv1;
@@ -125,7 +125,7 @@ static void ocf_submit_obj_zeroes_wait_io(struct ocf_io *io, int error)
env_completion_complete(&cntx->complete);
}
int ocf_submit_write_zeroes_wait(ocf_data_obj_t obj, uint64_t addr,
int ocf_submit_write_zeroes_wait(ocf_volume_t volume, uint64_t addr,
uint64_t length)
{
struct ocf_submit_io_wait_context cntx = { };
@@ -134,7 +134,7 @@ int ocf_submit_write_zeroes_wait(ocf_data_obj_t obj, uint64_t addr,
uint32_t step = 0;
struct ocf_io *io;
io = ocf_dobj_new_io(obj);
io = ocf_volume_new_io(volume);
if (!io)
return -ENOMEM;
@@ -145,8 +145,8 @@ int ocf_submit_write_zeroes_wait(ocf_data_obj_t obj, uint64_t addr,
ocf_io_configure(io, addr, bytes, OCF_WRITE, 0, 0);
ocf_io_set_cmpl(io, &cntx, NULL,
ocf_submit_obj_zeroes_wait_io);
ocf_dobj_submit_write_zeroes(io);
ocf_submit_volume_zeroes_wait_io);
ocf_volume_submit_write_zeroes(io);
addr += bytes;
length -= bytes;
@@ -171,7 +171,7 @@ int ocf_submit_cache_page(struct ocf_cache *cache, uint64_t addr,
int result = 0;
/* Allocate resources for IO */
io = ocf_dobj_new_io(&cache->device->obj);
io = ocf_volume_new_io(&cache->device->volume);
data = ctx_data_alloc(cache->owner, 1);
if (!io || !data) {
@@ -201,7 +201,7 @@ end:
return result;
}
static void ocf_submit_obj_req_cmpl(struct ocf_io *io, int error)
static void ocf_submit_volume_req_cmpl(struct ocf_io *io, int error)
{
struct ocf_request *req = io->priv1;
ocf_req_end_t callback = io->priv2;
@@ -242,7 +242,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
ocf_io_configure(io, addr, bytes, dir, class, flags);
ocf_io_set_queue(io, req->io_queue);
ocf_io_set_cmpl(io, req, callback, ocf_submit_obj_req_cmpl);
ocf_io_set_cmpl(io, req, callback, ocf_submit_volume_req_cmpl);
err = ocf_io_set_data(io, req->data, 0);
if (err) {
@@ -251,7 +251,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
goto update_stats;
}
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
total_bytes = req->byte_length;
goto update_stats;
@@ -290,7 +290,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
ocf_io_configure(io, addr, bytes, dir, class, flags);
ocf_io_set_queue(io, req->io_queue);
ocf_io_set_cmpl(io, req, callback, ocf_submit_obj_req_cmpl);
ocf_io_set_cmpl(io, req, callback, ocf_submit_volume_req_cmpl);
err = ocf_io_set_data(io, req->data, total_bytes);
if (err) {
@@ -300,7 +300,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
callback(req, err);
goto update_stats;
}
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
total_bytes += bytes;
}
@@ -311,7 +311,7 @@ update_stats:
env_atomic64_add(total_bytes, &cache_stats->read_bytes);
}
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
void ocf_submit_volume_req(ocf_volume_t volume, struct ocf_request *req,
ocf_req_end_t callback)
{
struct ocf_cache *cache = req->cache;
@@ -329,7 +329,7 @@ void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
else if (dir == OCF_READ)
env_atomic64_add(req->byte_length, &core_stats->read_bytes);
io = ocf_dobj_new_io(obj);
io = ocf_volume_new_io(volume);
if (!io) {
callback(req, -ENOMEM);
return;
@@ -338,14 +338,14 @@ void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
ocf_io_configure(io, req->byte_position, req->byte_length, dir,
class, flags);
ocf_io_set_queue(io, req->io_queue);
ocf_io_set_cmpl(io, req, callback, ocf_submit_obj_req_cmpl);
ocf_io_set_cmpl(io, req, callback, ocf_submit_volume_req_cmpl);
err = ocf_io_set_data(io, req->data, 0);
if (err) {
ocf_io_put(io);
callback(req, err);
return;
}
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
}
static void ocf_submit_io_wait_end(struct ocf_io *io, int error)
@@ -365,7 +365,7 @@ int ocf_submit_io_wait(struct ocf_io *io)
context.error = 0;
ocf_io_set_cmpl(io, &context, NULL, ocf_submit_io_wait_end);
ocf_dobj_submit_io(io);
ocf_volume_submit_io(io);
env_completion_wait(&context.complete);
return context.error;
}

View File

@@ -45,18 +45,18 @@ static inline int ocf_io_overlaps(uint32_t start1, uint32_t count1,
int ocf_submit_io_wait(struct ocf_io *io);
int ocf_submit_obj_flush_wait(ocf_data_obj_t obj);
int ocf_submit_volume_flush_wait(ocf_volume_t volume);
int ocf_submit_obj_discard_wait(ocf_data_obj_t obj, uint64_t addr,
int ocf_submit_volume_discard_wait(ocf_volume_t volume, uint64_t addr,
uint64_t length);
int ocf_submit_write_zeroes_wait(ocf_data_obj_t obj, uint64_t addr,
int ocf_submit_write_zeroes_wait(ocf_volume_t volume, uint64_t addr,
uint64_t length);
int ocf_submit_cache_page(struct ocf_cache *cache, uint64_t addr,
int dir, void *buffer);
void ocf_submit_obj_req(ocf_data_obj_t obj, struct ocf_request *req,
void ocf_submit_volume_req(ocf_volume_t volume, struct ocf_request *req,
ocf_req_end_t callback);
@@ -66,7 +66,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache,
static inline struct ocf_io *ocf_new_cache_io(struct ocf_cache *cache)
{
return ocf_dobj_new_io(&cache->device->obj);
return ocf_volume_new_io(&cache->device->volume);
}
static inline struct ocf_io *ocf_new_core_io(struct ocf_cache *cache,
@@ -74,7 +74,7 @@ static inline struct ocf_io *ocf_new_core_io(struct ocf_cache *cache,
{
ENV_BUG_ON(core_id >= OCF_CORE_MAX);
return ocf_dobj_new_io(&cache->core[core_id].obj);
return ocf_volume_new_io(&cache->core[core_id].volume);
}
#endif /* UTILS_IO_H_ */