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:
Robert Baldyga
2019-03-01 15:52:05 +01:00
parent 71d30e948d
commit 9b9b965b55
7 changed files with 78 additions and 42 deletions

View File

@@ -247,7 +247,7 @@ static void ocf_cleaner_run_test01(void **state)
will_return(__wrap_ocf_mngt_is_cache_locked, 0);
expect_function_call(__wrap_env_rwsem_down_write_trylock);
will_return(__wrap_env_rwsem_down_write_trylock, 1);
will_return(__wrap_env_rwsem_down_write_trylock, 0);
expect_function_call(__wrap__ocf_cleaner_run_check_dirty_inactive);
will_return(__wrap__ocf_cleaner_run_check_dirty_inactive, 0);