Introduce hash bucket locks
There is one RW lock per hash bucket. Write lock is required to map cacheline, read lock is sufficient for traversing. Hash bucket locks are always acquired under global metadata read lock. This assures mutual exclusion with eviction and management paths, where global metadata write lock is held. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -39,7 +39,7 @@ int ocf_metadata_init(struct ocf_cache *cache,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ocf_metadata_concurrency_init(cache);
|
||||
ocf_metadata_concurrency_init(&cache->metadata.lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void ocf_metadata_deinit(struct ocf_cache *cache)
|
||||
cache->metadata.iface.deinit(cache);
|
||||
}
|
||||
|
||||
ocf_metadata_concurrency_deinit(cache);
|
||||
ocf_metadata_concurrency_deinit(&cache->metadata.lock);
|
||||
|
||||
ocf_metadata_io_deinit(cache);
|
||||
}
|
||||
|
@@ -428,6 +428,15 @@ struct ocf_cache_line_settings {
|
||||
uint64_t sector_end;
|
||||
};
|
||||
|
||||
struct ocf_metadata_lock
|
||||
{
|
||||
env_rwsem global; /*!< global metadata lock (GML) */
|
||||
env_rwlock status; /*!< Fast lock for status bits */
|
||||
env_spinlock eviction; /*!< Fast lock for eviction policy */
|
||||
env_rwsem *hash; /*!< Hash bucket locks */
|
||||
uint32_t num_hash_entries; /*!< Hash bucket count */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Metadata control structure
|
||||
*/
|
||||
@@ -444,11 +453,7 @@ struct ocf_metadata {
|
||||
bool is_volatile;
|
||||
/*!< true if metadata used in volatile mode (RAM only) */
|
||||
|
||||
struct {
|
||||
env_rwsem collision; /*!< lock for collision table */
|
||||
env_rwlock status; /*!< Fast lock for status bits */
|
||||
env_spinlock eviction; /*!< Fast lock for eviction policy */
|
||||
} lock;
|
||||
struct ocf_metadata_lock lock;
|
||||
};
|
||||
|
||||
#endif /* __METADATA_STRUCTS_H__ */
|
||||
|
Reference in New Issue
Block a user