commit
dc2b76e655
26
env/posix/ocf_env.h
vendored
26
env/posix/ocf_env.h
vendored
@ -189,7 +189,7 @@ static inline int env_mutex_init(env_mutex *mutex)
|
|||||||
|
|
||||||
static inline void env_mutex_lock(env_mutex *mutex)
|
static inline void env_mutex_lock(env_mutex *mutex)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&mutex->m);
|
ENV_BUG_ON(pthread_mutex_lock(&mutex->m));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int env_mutex_lock_interruptible(env_mutex *mutex)
|
static inline int env_mutex_lock_interruptible(env_mutex *mutex)
|
||||||
@ -205,7 +205,7 @@ static inline int env_mutex_trylock(env_mutex *mutex)
|
|||||||
|
|
||||||
static inline void env_mutex_unlock(env_mutex *mutex)
|
static inline void env_mutex_unlock(env_mutex *mutex)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&mutex->m);
|
ENV_BUG_ON(pthread_mutex_unlock(&mutex->m));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int env_mutex_is_locked(env_mutex *mutex)
|
static inline int env_mutex_is_locked(env_mutex *mutex)
|
||||||
@ -270,7 +270,7 @@ static inline void env_rwsem_up_read(env_rwsem *s)
|
|||||||
|
|
||||||
static inline void env_rwsem_down_read(env_rwsem *s)
|
static inline void env_rwsem_down_read(env_rwsem *s)
|
||||||
{
|
{
|
||||||
pthread_rwlock_rdlock(&s->lock);
|
ENV_BUG_ON(pthread_rwlock_rdlock(&s->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int env_rwsem_down_read_trylock(env_rwsem *s)
|
static inline int env_rwsem_down_read_trylock(env_rwsem *s)
|
||||||
@ -280,12 +280,12 @@ static inline int env_rwsem_down_read_trylock(env_rwsem *s)
|
|||||||
|
|
||||||
static inline void env_rwsem_up_write(env_rwsem *s)
|
static inline void env_rwsem_up_write(env_rwsem *s)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(&s->lock);
|
ENV_BUG_ON(pthread_rwlock_unlock(&s->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_rwsem_down_write(env_rwsem *s)
|
static inline void env_rwsem_down_write(env_rwsem *s)
|
||||||
{
|
{
|
||||||
pthread_rwlock_wrlock(&s->lock);
|
ENV_BUG_ON(pthread_rwlock_wrlock(&s->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int env_rwsem_down_write_trylock(env_rwsem *s)
|
static inline int env_rwsem_down_write_trylock(env_rwsem *s)
|
||||||
@ -486,17 +486,17 @@ typedef struct {
|
|||||||
|
|
||||||
static inline void env_spinlock_init(env_spinlock *l)
|
static inline void env_spinlock_init(env_spinlock *l)
|
||||||
{
|
{
|
||||||
pthread_spin_init(&l->lock, 0);
|
ENV_BUG_ON(pthread_spin_init(&l->lock, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_spinlock_lock(env_spinlock *l)
|
static inline void env_spinlock_lock(env_spinlock *l)
|
||||||
{
|
{
|
||||||
pthread_spin_lock(&l->lock);
|
ENV_BUG_ON(pthread_spin_lock(&l->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_spinlock_unlock(env_spinlock *l)
|
static inline void env_spinlock_unlock(env_spinlock *l)
|
||||||
{
|
{
|
||||||
pthread_spin_unlock(&l->lock);
|
ENV_BUG_ON(pthread_spin_unlock(&l->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_spinlock_lock_irq(env_spinlock *l)
|
static inline void env_spinlock_lock_irq(env_spinlock *l)
|
||||||
@ -525,27 +525,27 @@ typedef struct {
|
|||||||
|
|
||||||
static inline void env_rwlock_init(env_rwlock *l)
|
static inline void env_rwlock_init(env_rwlock *l)
|
||||||
{
|
{
|
||||||
pthread_rwlock_init(&l->lock, NULL);
|
ENV_BUG_ON(pthread_rwlock_init(&l->lock, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_rwlock_read_lock(env_rwlock *l)
|
static inline void env_rwlock_read_lock(env_rwlock *l)
|
||||||
{
|
{
|
||||||
pthread_rwlock_rdlock(&l->lock);
|
ENV_BUG_ON(pthread_rwlock_rdlock(&l->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_rwlock_read_unlock(env_rwlock *l)
|
static inline void env_rwlock_read_unlock(env_rwlock *l)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(&l->lock);
|
ENV_BUG_ON(pthread_rwlock_unlock(&l->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_rwlock_write_lock(env_rwlock *l)
|
static inline void env_rwlock_write_lock(env_rwlock *l)
|
||||||
{
|
{
|
||||||
pthread_rwlock_wrlock(&l->lock);
|
ENV_BUG_ON(pthread_rwlock_wrlock(&l->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void env_rwlock_write_unlock(env_rwlock *l)
|
static inline void env_rwlock_write_unlock(env_rwlock *l)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(&l->lock);
|
ENV_BUG_ON(pthread_rwlock_unlock(&l->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *** WAITQUEUE *** */
|
/* *** WAITQUEUE *** */
|
||||||
|
@ -672,8 +672,8 @@ static int _ocf_mngt_init_prepare_cache(struct ocf_cache_mngt_init_params *param
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cfg->name) {
|
if (cfg->name) {
|
||||||
ret = env_strncpy(cache_name, sizeof(cache_name),
|
ret = env_strncpy(cache_name, sizeof(cache_name) - 1,
|
||||||
cfg->name, sizeof(cache_name));
|
cfg->name, sizeof(cache_name) - 1);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
@ -1064,7 +1064,7 @@ uint64_t _ocf_mngt_calculate_ram_needed(ocf_cache_t cache,
|
|||||||
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
||||||
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed)
|
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed)
|
||||||
{
|
{
|
||||||
struct ocf_volume volume;
|
struct ocf_volume *volume = &cache->device->volume;
|
||||||
ocf_volume_type_t type;
|
ocf_volume_type_t type;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -1076,21 +1076,21 @@ int ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
|||||||
if (!type)
|
if (!type)
|
||||||
return -OCF_ERR_INVAL_VOLUME_TYPE;
|
return -OCF_ERR_INVAL_VOLUME_TYPE;
|
||||||
|
|
||||||
result = ocf_volume_init(&cache->device->volume, type,
|
result = ocf_volume_init(volume, type,
|
||||||
&cfg->uuid, false);
|
&cfg->uuid, false);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result = ocf_volume_open(&volume, cfg->volume_params);
|
result = ocf_volume_open(volume, cfg->volume_params);
|
||||||
if (result) {
|
if (result) {
|
||||||
ocf_volume_deinit(&volume);
|
ocf_volume_deinit(volume);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ram_needed = _ocf_mngt_calculate_ram_needed(cache, &volume);
|
*ram_needed = _ocf_mngt_calculate_ram_needed(cache, volume);
|
||||||
|
|
||||||
ocf_volume_close(&volume);
|
ocf_volume_close(volume);
|
||||||
ocf_volume_deinit(&volume);
|
ocf_volume_deinit(volume);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1149,7 +1149,7 @@ static void _ocf_mngt_attach_handle_error(
|
|||||||
env_vfree(cache->device);
|
env_vfree(cache->device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ocf_mngt_cache_init(ocf_cache_t cache,
|
static void _ocf_mngt_cache_init(ocf_cache_t cache,
|
||||||
struct ocf_cache_mngt_init_params *params)
|
struct ocf_cache_mngt_init_params *params)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1173,8 +1173,6 @@ static int _ocf_mngt_cache_init(ocf_cache_t cache,
|
|||||||
__init_cores(cache);
|
__init_cores(cache);
|
||||||
__init_metadata_version(cache);
|
__init_metadata_version(cache);
|
||||||
__init_partitions(cache);
|
__init_partitions(cache);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
||||||
@ -1213,9 +1211,7 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
|
|||||||
ocf_log(ctx, log_debug, "Metadata initialized\n");
|
ocf_log(ctx, log_debug, "Metadata initialized\n");
|
||||||
params.flags.metadata_inited = true;
|
params.flags.metadata_inited = true;
|
||||||
|
|
||||||
result = _ocf_mngt_cache_init(*cache, ¶ms);
|
_ocf_mngt_cache_init(*cache, ¶ms);
|
||||||
if (result)
|
|
||||||
goto _cache_mngt_init_instance_ERROR;
|
|
||||||
|
|
||||||
ocf_ctx_get(ctx);
|
ocf_ctx_get(ctx);
|
||||||
|
|
||||||
|
@ -892,10 +892,8 @@ int ocf_mngt_core_set_user_metadata(ocf_core_t core, void *data, size_t size)
|
|||||||
if (size > OCF_CORE_USER_DATA_SIZE)
|
if (size > OCF_CORE_USER_DATA_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
env_memcpy(core->conf_meta->user_data,
|
return env_memcpy(core->conf_meta->user_data,
|
||||||
OCF_CORE_USER_DATA_SIZE, data, size);
|
OCF_CORE_USER_DATA_SIZE, data, size);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
||||||
@ -906,10 +904,8 @@ int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
|
|||||||
if (size > sizeof(core->conf_meta->user_data))
|
if (size > sizeof(core->conf_meta->user_data))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
env_memcpy(data, size, core->conf_meta->user_data,
|
return env_memcpy(data, size, core->conf_meta->user_data,
|
||||||
OCF_CORE_USER_DATA_SIZE);
|
OCF_CORE_USER_DATA_SIZE);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _cache_mngt_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
|
static int _cache_mngt_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
|
||||||
|
@ -505,6 +505,7 @@ static void _ocf_mngt_flush_core(
|
|||||||
ocf_core_log(core, log_err, "Flushing operation aborted, "
|
ocf_core_log(core, log_err, "Flushing operation aborted, "
|
||||||
"no memory\n");
|
"no memory\n");
|
||||||
env_vfree(fc);
|
env_vfree(fc);
|
||||||
|
ocf_metadata_unlock(cache, OCF_METADATA_WR);
|
||||||
complete(context, -OCF_ERR_NO_MEM);
|
complete(context, -OCF_ERR_NO_MEM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -540,6 +541,7 @@ static void _ocf_mngt_flush_all_cores(
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
ocf_cache_log(cache, log_err, "Flushing operation aborted, "
|
ocf_cache_log(cache, log_err, "Flushing operation aborted, "
|
||||||
"no memory\n");
|
"no memory\n");
|
||||||
|
ocf_metadata_unlock(cache, OCF_METADATA_WR);
|
||||||
complete(context, ret);
|
complete(context, ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ ocf_cache_id_t ocf_cache_get_id(ocf_cache_t cache)
|
|||||||
int ocf_cache_set_name(ocf_cache_t cache, const char *src, size_t src_size)
|
int ocf_cache_set_name(ocf_cache_t cache, const char *src, size_t src_size)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(cache);
|
OCF_CHECK_NULL(cache);
|
||||||
return env_strncpy(cache->name, sizeof(cache->name), src, src_size);
|
return env_strncpy(cache->name, OCF_CACHE_NAME_SIZE - 1, src, src_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ocf_cache_get_name(ocf_cache_t cache)
|
const char *ocf_cache_get_name(ocf_cache_t cache)
|
||||||
|
@ -54,7 +54,7 @@ int ocf_core_set_name(ocf_core_t core, const char *src, size_t src_size)
|
|||||||
OCF_CHECK_NULL(core);
|
OCF_CHECK_NULL(core);
|
||||||
OCF_CHECK_NULL(src);
|
OCF_CHECK_NULL(src);
|
||||||
|
|
||||||
return env_strncpy(core->name, sizeof(core->name), src, src_size);
|
return env_strncpy(core->name, OCF_CORE_NAME_SIZE - 1, src, src_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ocf_core_get_name(ocf_core_t core)
|
const char *ocf_core_get_name(ocf_core_t core)
|
||||||
@ -76,7 +76,7 @@ bool ocf_core_is_valid(ocf_cache_t cache, ocf_core_id_t id)
|
|||||||
{
|
{
|
||||||
OCF_CHECK_NULL(cache);
|
OCF_CHECK_NULL(cache);
|
||||||
|
|
||||||
if (id > OCF_CORE_ID_MAX || id < OCF_CORE_ID_MIN)
|
if (id > OCF_CORE_ID_MAX)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!env_bit_test(id, cache->conf_meta->valid_core_bitmap))
|
if (!env_bit_test(id, cache->conf_meta->valid_core_bitmap))
|
||||||
|
@ -27,7 +27,7 @@ int ocf_cache_io_class_get_info(ocf_cache_t cache, uint32_t io_class,
|
|||||||
return -OCF_ERR_IO_CLASS_NOT_EXIST;
|
return -OCF_ERR_IO_CLASS_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env_strncpy(info->name, sizeof(info->name),
|
if (env_strncpy(info->name, OCF_IO_CLASS_NAME_MAX - 1,
|
||||||
cache->user_parts[part_id].config->name,
|
cache->user_parts[part_id].config->name,
|
||||||
sizeof(cache->user_parts[part_id].config->name))) {
|
sizeof(cache->user_parts[part_id].config->name))) {
|
||||||
return -OCF_ERR_INVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
@ -172,7 +172,7 @@ int ocf_core_io_class_get_stats(ocf_core_t core, ocf_part_id_t part_id,
|
|||||||
OCF_CHECK_NULL(core);
|
OCF_CHECK_NULL(core);
|
||||||
OCF_CHECK_NULL(stats);
|
OCF_CHECK_NULL(stats);
|
||||||
|
|
||||||
if (part_id < OCF_IO_CLASS_ID_MIN || part_id > OCF_IO_CLASS_ID_MAX)
|
if (part_id > OCF_IO_CLASS_ID_MAX)
|
||||||
return -OCF_ERR_INVAL;
|
return -OCF_ERR_INVAL;
|
||||||
|
|
||||||
cache = ocf_core_get_cache(core);
|
cache = ocf_core_get_cache(core);
|
||||||
|
@ -22,10 +22,11 @@ static void __set_cache_line_invalid(struct ocf_cache *cache, uint8_t start_bit,
|
|||||||
uint8_t end_bit, ocf_cache_line_t line,
|
uint8_t end_bit, ocf_cache_line_t line,
|
||||||
ocf_core_id_t core_id, ocf_part_id_t part_id)
|
ocf_core_id_t core_id, ocf_part_id_t part_id)
|
||||||
{
|
{
|
||||||
ocf_core_t core = ocf_cache_get_core(cache, core_id);
|
ocf_core_t core;
|
||||||
bool is_valid;
|
bool is_valid;
|
||||||
|
|
||||||
ENV_BUG_ON(core_id >= OCF_CORE_MAX);
|
ENV_BUG_ON(core_id >= OCF_CORE_MAX);
|
||||||
|
core = ocf_cache_get_core(cache, core_id);
|
||||||
|
|
||||||
if (metadata_clear_valid_sec_changed(cache, line, start_bit, end_bit,
|
if (metadata_clear_valid_sec_changed(cache, line, start_bit, end_bit,
|
||||||
&is_valid)) {
|
&is_valid)) {
|
||||||
|
@ -79,12 +79,10 @@ static int ocf_part_lst_cmp_valid(struct ocf_cache *cache,
|
|||||||
return v2 - v1;
|
return v2 - v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_part_init(struct ocf_cache *cache)
|
void ocf_part_init(struct ocf_cache *cache)
|
||||||
{
|
{
|
||||||
ocf_lst_init(cache, &cache->lst_part, OCF_IO_CLASS_MAX,
|
ocf_lst_init(cache, &cache->lst_part, OCF_IO_CLASS_MAX,
|
||||||
ocf_part_lst_getter_valid, ocf_part_lst_cmp_valid);
|
ocf_part_lst_getter_valid, ocf_part_lst_cmp_valid);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_part_move(struct ocf_request *req)
|
void ocf_part_move(struct ocf_request *req)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "../engine/cache_engine.h"
|
#include "../engine/cache_engine.h"
|
||||||
#include "../metadata/metadata_partition.h"
|
#include "../metadata/metadata_partition.h"
|
||||||
|
|
||||||
int ocf_part_init(struct ocf_cache *cache);
|
void ocf_part_init(struct ocf_cache *cache);
|
||||||
|
|
||||||
static inline bool ocf_part_is_valid(struct ocf_user_part *part)
|
static inline bool ocf_part_is_valid(struct ocf_user_part *part)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user