Synchronization of collision table
Adding synchronization around metadata collision segment pages. This part of metadata is modified when cacheline is mapped/unmapped and when dirty status changes. Synchronization on page level is required on top of cacheline and hash bucket locks to assure metadata flush always reads consistent state when copying entire collision table memory page. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -72,6 +72,10 @@ static inline uint64_t ocf_lines_2_bytes(struct ocf_cache *cache,
|
||||
/**
|
||||
* @brief Set cache line invalid
|
||||
*
|
||||
* @note Collision page must be locked by the caller (either exclusive access
|
||||
* to collision table page OR write lock on metadata hash bucket combined with
|
||||
* shared access to the collision page)
|
||||
*
|
||||
* @param cache Cache instance
|
||||
* @param start_bit Start bit of cache line for which state will be set
|
||||
* @param end_bit End bit of cache line for which state will be set
|
||||
@@ -85,6 +89,10 @@ void set_cache_line_invalid(struct ocf_cache *cache, uint8_t start_bit,
|
||||
/**
|
||||
* @brief Set cache line invalid without flush
|
||||
*
|
||||
* @note Collision page must be locked by the caller (either exclusive access
|
||||
* to collision table page OR write lock on metadata hash bucket combined with
|
||||
* shared access to the collision page)
|
||||
*
|
||||
* @param cache Cache instance
|
||||
* @param start_bit Start bit of cache line for which state will be set
|
||||
* @param end_bit End bit of cache line for which state will be set
|
||||
@@ -96,6 +104,10 @@ void set_cache_line_invalid_no_flush(struct ocf_cache *cache, uint8_t start_bit,
|
||||
/**
|
||||
* @brief Set cache line valid
|
||||
*
|
||||
* @note Collision page must be locked by the caller (either exclusive access
|
||||
* to collision table page OR write lock on metadata hash bucket combined with
|
||||
* shared access to the collision page)
|
||||
*
|
||||
* @param cache Cache instance
|
||||
* @param start_bit Start bit of cache line for which state will be set
|
||||
* @param end_bit End bit of cache line for which state will be set
|
||||
@@ -108,6 +120,10 @@ void set_cache_line_valid(struct ocf_cache *cache, uint8_t start_bit,
|
||||
/**
|
||||
* @brief Set cache line clean
|
||||
*
|
||||
* @note Collision page must be locked by the caller (either exclusive access
|
||||
* to collision table page OR write lock on metadata hash bucket combined with
|
||||
* shared access to the collision page)
|
||||
*
|
||||
* @param cache Cache instance
|
||||
* @param start_bit Start bit of cache line for which state will be set
|
||||
* @param end_bit End bit of cache line for which state will be set
|
||||
@@ -120,6 +136,10 @@ void set_cache_line_clean(struct ocf_cache *cache, uint8_t start_bit,
|
||||
/**
|
||||
* @brief Set cache line dirty
|
||||
*
|
||||
* @note Collision page must be locked by the caller (either exclusive access
|
||||
* to collision table page OR write lock on metadata hash bucket combined with
|
||||
* shared access to the collision page)
|
||||
*
|
||||
* @param cache Cache instance
|
||||
* @param start_bit Start bit of cache line for which state will be set
|
||||
* @param end_bit End bit of cache line for which state will be set
|
||||
@@ -163,6 +183,10 @@ static inline void ocf_purge_eviction_policy(struct ocf_cache *cache,
|
||||
/**
|
||||
* @brief Set cache line clean and invalid and remove form lists
|
||||
*
|
||||
* @note Collision page must be locked by the caller (either exclusive access
|
||||
* to collision table page OR write lock on metadata hash bucket combined with
|
||||
* shared access to the collision page)
|
||||
*
|
||||
* @param cache Cache instance
|
||||
* @param start Start bit of range in cache line to purge
|
||||
* @param end End bit of range in cache line to purge
|
||||
@@ -224,8 +248,12 @@ static inline void ocf_purge_map_info(struct ocf_request *req)
|
||||
ocf_line_sectors(cache);
|
||||
}
|
||||
|
||||
ocf_metadata_start_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
_ocf_purge_cache_line_sec(cache, start_bit, end_bit, req,
|
||||
map_idx);
|
||||
ocf_metadata_end_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +301,11 @@ static inline void ocf_set_valid_map_info(struct ocf_request *req)
|
||||
start_bit = ocf_map_line_start_sector(req, map_idx);
|
||||
end_bit = ocf_map_line_end_sector(req, map_idx);
|
||||
|
||||
ocf_metadata_start_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
set_cache_line_valid(cache, start_bit, end_bit, req, map_idx);
|
||||
ocf_metadata_end_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,6 +316,7 @@ static inline void ocf_set_dirty_map_info(struct ocf_request *req)
|
||||
uint8_t end_bit;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
uint32_t count = req->core_line_count;
|
||||
struct ocf_map_info *map = req->map;
|
||||
|
||||
/* Set valid bits for sectors on the basis of map info
|
||||
*
|
||||
@@ -295,7 +328,12 @@ static inline void ocf_set_dirty_map_info(struct ocf_request *req)
|
||||
for (map_idx = 0; map_idx < count; map_idx++) {
|
||||
start_bit = ocf_map_line_start_sector(req, map_idx);
|
||||
end_bit = ocf_map_line_end_sector(req, map_idx);
|
||||
|
||||
ocf_metadata_start_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
set_cache_line_dirty(cache, start_bit, end_bit, req, map_idx);
|
||||
ocf_metadata_end_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,6 +344,7 @@ static inline void ocf_set_clean_map_info(struct ocf_request *req)
|
||||
uint8_t end_bit;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
uint32_t count = req->core_line_count;
|
||||
struct ocf_map_info *map = req->map;
|
||||
|
||||
/* Set valid bits for sectors on the basis of map info
|
||||
*
|
||||
@@ -317,7 +356,12 @@ static inline void ocf_set_clean_map_info(struct ocf_request *req)
|
||||
for (map_idx = 0; map_idx < count; map_idx++) {
|
||||
start_bit = ocf_map_line_start_sector(req, map_idx);
|
||||
end_bit = ocf_map_line_end_sector(req, map_idx);
|
||||
|
||||
ocf_metadata_start_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
set_cache_line_clean(cache, start_bit, end_bit, req, map_idx);
|
||||
ocf_metadata_end_collision_shared_access(cache, map[map_idx].
|
||||
coll_idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user