Add cache locking functions in trylock variant
- Add cache trylock and read trylock functions. - Introduce new error code -OCF_ERR_NO_LOCK. - Change trylock functions in env to return this code in case of lock contention. [ENV CHANGES REQUIRED] Following functions should return 0 on success or -OCF_ERR_NO_LOCK in case of lock contention: - env_mutex_trylock() - env_rwsem_up_read_trylock() - env_rwsem_up_write_trylock() Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -48,7 +48,7 @@ static inline void ocf_metadata_unlock(struct ocf_cache *cache, int rw)
|
||||
|
||||
static inline int ocf_metadata_try_lock(struct ocf_cache *cache, int rw)
|
||||
{
|
||||
int result = -1;
|
||||
int result = 0;
|
||||
|
||||
if (rw == OCF_METADATA_WR) {
|
||||
result = env_rwsem_down_write_trylock(
|
||||
@@ -60,7 +60,7 @@ static inline int ocf_metadata_try_lock(struct ocf_cache *cache, int rw)
|
||||
ENV_BUG();
|
||||
}
|
||||
|
||||
if (!result)
|
||||
if (result)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user