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:
@@ -18,21 +18,24 @@ typedef enum {
|
||||
/** Invalid input parameter value */
|
||||
OCF_ERR_INVAL = 1000000,
|
||||
|
||||
/** Invalid volume type */
|
||||
OCF_ERR_INVAL_VOLUME_TYPE,
|
||||
|
||||
/** Operation interrupted */
|
||||
OCF_ERR_INTR,
|
||||
|
||||
/** Out of memory */
|
||||
OCF_ERR_NO_MEM,
|
||||
|
||||
/** Lock not acquired */
|
||||
OCF_ERR_NO_LOCK,
|
||||
|
||||
/** Invalid volume type */
|
||||
OCF_ERR_INVAL_VOLUME_TYPE,
|
||||
|
||||
/** Unknown error occurred */
|
||||
OCF_ERR_UNKNOWN,
|
||||
|
||||
/*!< To many caches */
|
||||
OCF_ERR_TOO_MANY_CACHES,
|
||||
|
||||
/** Out of memory */
|
||||
OCF_ERR_NO_MEM,
|
||||
|
||||
/** Not enough RAM to start cache */
|
||||
OCF_ERR_NO_FREE_RAM,
|
||||
|
||||
|
||||
@@ -124,6 +124,34 @@ int ocf_mngt_cache_lock(ocf_cache_t cache);
|
||||
*/
|
||||
int ocf_mngt_cache_read_lock(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief Lock cache for management oparations (write lock, exclusive)
|
||||
*
|
||||
* @param[in] cache Handle to cache
|
||||
*
|
||||
* @retval 0 Cache successfully locked
|
||||
* @retval -OCF_ERR_CACHE_NOT_EXIST Can not lock cache - cache is already
|
||||
* stopping
|
||||
* @retval -OCF_ERR_CACHE_IN_USE Can not lock cache - cache is in use
|
||||
* @retval -OCF_ERR_NO_LOCK Lock not acquired
|
||||
*/
|
||||
int ocf_mngt_cache_trylock(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief Lock cache for read - assures cache config does not change while
|
||||
* lock is being held, while allowing other users to acquire
|
||||
* read lock in parallel.
|
||||
*
|
||||
* @param[in] cache Handle to cache
|
||||
*
|
||||
* @retval 0 Cache successfully locked
|
||||
* @retval -OCF_ERR_CACHE_NOT_EXIST Can not lock cache - cache is already
|
||||
* stopping
|
||||
* @retval -OCF_ERR_CACHE_IN_USE Can not lock cache - cache is in use
|
||||
* @retval -OCF_ERR_NO_LOCK Lock not acquired
|
||||
*/
|
||||
int ocf_mngt_cache_read_trylock(ocf_cache_t cache);
|
||||
|
||||
/**
|
||||
* @brief Write-unlock cache
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user