Change env_spinlock_init to non-void function
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
parent
8426d662cb
commit
b78557a2cc
4
env/posix/ocf_env.h
vendored
4
env/posix/ocf_env.h
vendored
@ -450,9 +450,9 @@ typedef struct {
|
||||
pthread_spinlock_t lock;
|
||||
} env_spinlock;
|
||||
|
||||
static inline void env_spinlock_init(env_spinlock *l)
|
||||
static inline int env_spinlock_init(env_spinlock *l)
|
||||
{
|
||||
ENV_BUG_ON(pthread_spin_init(&l->lock, 0));
|
||||
return pthread_spin_init(&l->lock, 0);
|
||||
}
|
||||
|
||||
static inline int env_spinlock_trylock(env_spinlock *l)
|
||||
|
@ -467,6 +467,7 @@ int cleaning_policy_alru_initialize(ocf_cache_t cache, int init_metadata)
|
||||
struct ocf_user_part *part;
|
||||
ocf_part_id_t part_id;
|
||||
struct alru_context *alru;
|
||||
int error = 0;
|
||||
unsigned i;
|
||||
|
||||
alru = env_vzalloc(sizeof(*alru));
|
||||
@ -475,8 +476,19 @@ int cleaning_policy_alru_initialize(ocf_cache_t cache, int init_metadata)
|
||||
return -OCF_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++)
|
||||
env_spinlock_init(&alru->list_lock[i]);
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
error = env_spinlock_init(&alru->list_lock[i]);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
while (i--)
|
||||
env_spinlock_destroy(&alru->list_lock[i]);
|
||||
env_vfree(alru);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
cache->cleaner.cleaning_policy_context = alru;
|
||||
|
||||
|
@ -110,13 +110,17 @@ int ocf_cache_line_concurrency_init(struct ocf_cache *cache)
|
||||
/* Init concurrency control table */
|
||||
for (i = 0; i < _WAITERS_LIST_ENTRIES; i++) {
|
||||
INIT_LIST_HEAD(&c->waiters_lsts[i].head);
|
||||
env_spinlock_init(&c->waiters_lsts[i].lock);
|
||||
error = env_spinlock_init(&c->waiters_lsts[i].lock);
|
||||
if (error)
|
||||
goto spinlock_err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
spinlock_err:
|
||||
while (i--)
|
||||
env_spinlock_destroy(&c->waiters_lsts[i].lock);
|
||||
ocf_cache_line_concurrency_init:
|
||||
|
||||
ocf_cache_log(cache, log_err, "Cannot initialize cache concurrency, "
|
||||
"ERROR %d", error);
|
||||
|
||||
|
@ -6,17 +6,32 @@
|
||||
#include "ocf_metadata_concurrency.h"
|
||||
#include "../metadata/metadata_misc.h"
|
||||
|
||||
void ocf_metadata_concurrency_init(struct ocf_metadata_lock *metadata_lock)
|
||||
int ocf_metadata_concurrency_init(struct ocf_metadata_lock *metadata_lock)
|
||||
{
|
||||
int err = 0;
|
||||
unsigned i;
|
||||
|
||||
env_spinlock_init(&metadata_lock->eviction);
|
||||
err = env_spinlock_init(&metadata_lock->eviction);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
//@TODO handle env_rwlock_init return val
|
||||
env_rwlock_init(&metadata_lock->status);
|
||||
env_rwsem_init(&metadata_lock->global);
|
||||
|
||||
for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
|
||||
env_spinlock_init(&metadata_lock->partition[i]);
|
||||
err = env_spinlock_init(&metadata_lock->partition[i]);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
while (i--)
|
||||
env_spinlock_destroy(&metadata_lock->partition[i]);
|
||||
return err;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void ocf_metadata_concurrency_deinit(struct ocf_metadata_lock *metadata_lock)
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define OCF_METADATA_RD 0
|
||||
#define OCF_METADATA_WR 1
|
||||
|
||||
void ocf_metadata_concurrency_init(struct ocf_metadata_lock *metadata_lock);
|
||||
int ocf_metadata_concurrency_init(struct ocf_metadata_lock *metadata_lock);
|
||||
|
||||
void ocf_metadata_concurrency_deinit(struct ocf_metadata_lock *metadata_lock);
|
||||
|
||||
|
@ -39,7 +39,14 @@ int ocf_metadata_init(struct ocf_cache *cache,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ocf_metadata_concurrency_init(&cache->metadata.lock);
|
||||
ret = ocf_metadata_concurrency_init(&cache->metadata.lock);
|
||||
if (ret) {
|
||||
if (cache->metadata.iface.deinit)
|
||||
cache->metadata.iface.deinit(cache);
|
||||
|
||||
ocf_metadata_io_deinit(cache);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -385,21 +385,28 @@ ocf_freelist_t ocf_freelist_init(struct ocf_cache *cache)
|
||||
freelist->lock = env_vzalloc(sizeof(freelist->lock[0]) * num);
|
||||
freelist->part = env_vzalloc(sizeof(freelist->part[0]) * num);
|
||||
|
||||
if (!freelist->lock || !freelist->part) {
|
||||
env_vfree(freelist->lock);
|
||||
env_vfree(freelist->part);
|
||||
env_vfree(freelist);
|
||||
return NULL;
|
||||
}
|
||||
if (!freelist->lock || !freelist->part)
|
||||
goto free_allocs;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
env_spinlock_init(&freelist->lock[i]);
|
||||
if (env_spinlock_init(&freelist->lock[i]))
|
||||
goto spinlock_err;
|
||||
|
||||
freelist->part[i].head = line_entries;
|
||||
freelist->part[i].tail = line_entries;
|
||||
env_atomic64_set(&freelist->part[i].curr_size, 0);
|
||||
}
|
||||
|
||||
return freelist;
|
||||
|
||||
spinlock_err:
|
||||
while (i--)
|
||||
env_spinlock_destroy(&freelist->lock[i]);
|
||||
free_allocs:
|
||||
env_vfree(freelist->lock);
|
||||
env_vfree(freelist->part);
|
||||
env_vfree(freelist);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ocf_freelist_deinit(ocf_freelist_t freelist)
|
||||
|
@ -32,7 +32,13 @@ int ocf_queue_create(ocf_cache_t cache, ocf_queue_t *queue,
|
||||
}
|
||||
|
||||
env_atomic_set(&tmp_queue->io_no, 0);
|
||||
env_spinlock_init(&tmp_queue->io_list_lock);
|
||||
result = env_spinlock_init(&tmp_queue->io_list_lock);
|
||||
if (result) {
|
||||
ocf_mngt_cache_put(cache);
|
||||
free(tmp_queue);
|
||||
return result;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&tmp_queue->io_list);
|
||||
env_atomic_set(&tmp_queue->ref_count, 1);
|
||||
tmp_queue->cache = cache;
|
||||
|
@ -146,7 +146,6 @@ ocf_error_t nhit_hash_init(uint64_t hash_size, nhit_hash_t *ctx)
|
||||
for (i_locks = 0; i_locks < new_ctx->hash_entries; i_locks++) {
|
||||
if (env_rwsem_init(&new_ctx->hash_locks[i_locks])) {
|
||||
result = -OCF_ERR_UNKNOWN;
|
||||
i_locks--;
|
||||
goto dealloc_locks;
|
||||
}
|
||||
}
|
||||
@ -163,14 +162,17 @@ ocf_error_t nhit_hash_init(uint64_t hash_size, nhit_hash_t *ctx)
|
||||
env_atomic_set(&new_ctx->ring_buffer[i].counter, 0);
|
||||
}
|
||||
|
||||
env_spinlock_init(&new_ctx->rb_pointer_lock);
|
||||
result = env_spinlock_init(&new_ctx->rb_pointer_lock);
|
||||
if (result)
|
||||
goto dealloc_locks;
|
||||
|
||||
new_ctx->rb_pointer = 0;
|
||||
|
||||
*ctx = new_ctx;
|
||||
return 0;
|
||||
|
||||
dealloc_locks:
|
||||
for (; i_locks >= 0; i_locks--)
|
||||
while (i_locks--)
|
||||
ENV_BUG_ON(env_rwsem_destroy(&new_ctx->hash_locks[i_locks]));
|
||||
env_vfree(new_ctx->hash_locks);
|
||||
dealloc_hash:
|
||||
|
@ -47,7 +47,12 @@ void _ocf_async_lock_run_waiters(struct ocf_async_lock *lock,
|
||||
|
||||
int ocf_async_lock_init(struct ocf_async_lock *lock, uint32_t waiter_priv_size)
|
||||
{
|
||||
env_spinlock_init(&lock->waiters_lock);
|
||||
int err = 0;
|
||||
|
||||
err = env_spinlock_init(&lock->waiters_lock);
|
||||
if (err);
|
||||
return err;
|
||||
|
||||
INIT_LIST_HEAD(&lock->waiters);
|
||||
lock->rd = 0;
|
||||
lock->wr = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user