Renaming hash bucket locking functions
1. new abbreviated previx: ocf_hb (HB stands for hash bucket) 2. clear distinction between functions requiring caller to hold metadata shared global lock ("naked") vs the ones which acquire global lock on its own ("prot" for protected) 3. clear distinction between hash bucket locking functions accepting hash bucket id ("id"), core line and lba ("cline") and entire request ("req"). Resulting naming scheme: ocf_hb_(id/cline/req)_(prot/naked)_(lock/unlock/trylock)_(rd/wr) Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -434,17 +434,17 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req,
|
||||
/* requests to disabled partitions go in pass-through */
|
||||
if (!ocf_part_is_enabled(&req->cache->user_parts[req->part_id])) {
|
||||
ocf_req_set_mapping_error(req);
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
return lock_status;
|
||||
}
|
||||
|
||||
if (!ocf_part_has_space(req)) {
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
goto eviction;
|
||||
}
|
||||
|
||||
/* Mapping must be performed holding (at least) hash-bucket write lock */
|
||||
ocf_req_hash_lock_upgrade(req);
|
||||
ocf_hb_req_prot_lock_upgrade(req);
|
||||
|
||||
ocf_engine_map(req);
|
||||
|
||||
@@ -455,11 +455,11 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req,
|
||||
* Don't try to evict, just return error to caller */
|
||||
ocf_req_set_mapping_error(req);
|
||||
}
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
return lock_status;
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
|
||||
eviction:
|
||||
ocf_metadata_start_exclusive_access(metadata_lock);
|
||||
@@ -505,7 +505,7 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
||||
/* Read-lock hash buckets associated with request target core & LBAs
|
||||
* (core lines) to assure that cache mapping for these core lines does
|
||||
* not change during traversation */
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Traverse to check if request is mapped fully */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -513,7 +513,7 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
||||
mapped = ocf_engine_is_mapped(req);
|
||||
if (mapped) {
|
||||
lock = lock_clines(req, engine_cbs);
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
return lock;
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
||||
req->cache->promotion_policy, req);
|
||||
if (!promote) {
|
||||
ocf_req_set_mapping_error(req);
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
return lock;
|
||||
}
|
||||
|
||||
@@ -676,11 +676,11 @@ static int _ocf_engine_refresh(struct ocf_request *req)
|
||||
int result;
|
||||
|
||||
/* Check under metadata RD lock */
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
result = ocf_engine_check(req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
if (result == 0) {
|
||||
|
||||
|
@@ -170,7 +170,7 @@ int _ocf_discard_step_do(struct ocf_request *req)
|
||||
if (ocf_engine_mapped_count(req)) {
|
||||
/* There are mapped cache line, need to remove them */
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Remove mapped cache lines from metadata */
|
||||
ocf_purge_map_info(req);
|
||||
@@ -181,16 +181,16 @@ int _ocf_discard_step_do(struct ocf_request *req)
|
||||
_ocf_discard_step_complete);
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Even if no cachelines are mapped they could be tracked in promotion
|
||||
* policy. RD lock suffices. */
|
||||
ocf_promotion_req_purge(req->cache->promotion_policy, req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
OCF_DEBUG_RQ(req, "Discard");
|
||||
_ocf_discard_step_complete(req, 0);
|
||||
@@ -228,7 +228,7 @@ static int _ocf_discard_step(struct ocf_request *req)
|
||||
0));
|
||||
|
||||
ocf_req_hash(req);
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Travers to check if request is mapped fully */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -240,7 +240,7 @@ static int _ocf_discard_step(struct ocf_request *req)
|
||||
lock = OCF_LOCK_ACQUIRED;
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
if (lock >= 0) {
|
||||
if (OCF_LOCK_ACQUIRED == lock) {
|
||||
|
@@ -72,14 +72,14 @@ static int _ocf_read_fast_do(struct ocf_request *req)
|
||||
if (ocf_engine_needs_repart(req)) {
|
||||
OCF_DEBUG_RQ(req, "Re-Part");
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Probably some cache lines are assigned into wrong
|
||||
* partition. Need to move it to new one
|
||||
*/
|
||||
ocf_part_move(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
/* Submit IO */
|
||||
@@ -119,7 +119,7 @@ int ocf_read_fast(struct ocf_request *req)
|
||||
/*- Metadata RD access -----------------------------------------------*/
|
||||
|
||||
ocf_req_hash(req);
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Traverse request to cache if there is hit */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -133,7 +133,7 @@ int ocf_read_fast(struct ocf_request *req)
|
||||
lock = ocf_req_async_lock_rd(req, ocf_engine_on_resume);
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
if (hit && part_has_space) {
|
||||
OCF_DEBUG_RQ(req, "Fast path success");
|
||||
@@ -189,7 +189,7 @@ int ocf_write_fast(struct ocf_request *req)
|
||||
/*- Metadata RD access -----------------------------------------------*/
|
||||
|
||||
ocf_req_hash(req);
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Traverse request to cache if there is hit */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -203,7 +203,7 @@ int ocf_write_fast(struct ocf_request *req)
|
||||
lock = ocf_req_async_lock_wr(req, ocf_engine_on_resume);
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
if (mapped && part_has_space) {
|
||||
if (lock >= 0) {
|
||||
|
@@ -43,9 +43,9 @@ static int _ocf_invalidate_do(struct ocf_request *req)
|
||||
|
||||
ENV_BUG_ON(env_atomic_read(&req->req_remaining));
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
ocf_purge_map_info(req);
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
|
||||
env_atomic_inc(&req->req_remaining);
|
||||
|
||||
|
@@ -56,10 +56,10 @@ int ocf_read_pt_do(struct ocf_request *req)
|
||||
ocf_req_get(req);
|
||||
|
||||
if (req->info.dirty_any) {
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
/* Need to clean, start it */
|
||||
ocf_engine_clean(req);
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
/* Do not processing, because first we need to clean request */
|
||||
ocf_req_put(req);
|
||||
@@ -70,14 +70,14 @@ int ocf_read_pt_do(struct ocf_request *req)
|
||||
if (ocf_engine_needs_repart(req)) {
|
||||
OCF_DEBUG_RQ(req, "Re-Part");
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Probably some cache lines are assigned into wrong
|
||||
* partition. Need to move it to new one
|
||||
*/
|
||||
ocf_part_move(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
/* Submit read IO to the core */
|
||||
@@ -115,7 +115,7 @@ int ocf_read_pt(struct ocf_request *req)
|
||||
req->io_if = &_io_if_pt_resume;
|
||||
|
||||
ocf_req_hash(req);
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Traverse request to check if there are mapped cache lines */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -134,7 +134,7 @@ int ocf_read_pt(struct ocf_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
if (use_cache) {
|
||||
/*
|
||||
|
@@ -151,12 +151,12 @@ static int _ocf_read_generic_do(struct ocf_request *req)
|
||||
|
||||
if (ocf_engine_is_miss(req)) {
|
||||
if (req->info.dirty_any) {
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Request is dirty need to clean request */
|
||||
ocf_engine_clean(req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
|
||||
/* We need to clean request before processing, return */
|
||||
ocf_req_put(req);
|
||||
@@ -164,25 +164,25 @@ static int _ocf_read_generic_do(struct ocf_request *req)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Set valid status bits map */
|
||||
ocf_set_valid_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
}
|
||||
|
||||
if (ocf_engine_needs_repart(req)) {
|
||||
OCF_DEBUG_RQ(req, "Re-Part");
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Probably some cache lines are assigned into wrong
|
||||
* partition. Need to move it to new one
|
||||
*/
|
||||
ocf_part_move(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
OCF_DEBUG_RQ(req, "Submit");
|
||||
|
@@ -23,12 +23,12 @@ int ocf_write_wa(struct ocf_request *req)
|
||||
|
||||
ocf_req_hash(req);
|
||||
|
||||
ocf_req_hash_lock_rd(req); /*- Metadata RD access -----------------------*/
|
||||
ocf_hb_req_prot_lock_rd(req); /*- Metadata RD access -----------------------*/
|
||||
|
||||
/* Traverse request to check if there are mapped cache lines */
|
||||
ocf_engine_traverse(req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req); /*- END Metadata RD access -----------------*/
|
||||
ocf_hb_req_prot_unlock_rd(req); /*- END Metadata RD access -----------------*/
|
||||
|
||||
if (ocf_engine_is_hit(req)) {
|
||||
ocf_req_clear(req);
|
||||
|
@@ -28,20 +28,20 @@ static const struct ocf_io_if _io_if_wb_resume = {
|
||||
static void _ocf_write_wb_update_bits(struct ocf_request *req)
|
||||
{
|
||||
if (ocf_engine_is_miss(req)) {
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
/* Update valid status bits */
|
||||
ocf_set_valid_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
}
|
||||
|
||||
if (!ocf_engine_is_dirty_all(req)) {
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* set dirty bits, and mark if metadata flushing is required */
|
||||
ocf_set_dirty_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
ocf_req_set_cleaning_hot(req);
|
||||
@@ -127,14 +127,14 @@ static inline void _ocf_write_wb_submit(struct ocf_request *req)
|
||||
if (ocf_engine_needs_repart(req)) {
|
||||
OCF_DEBUG_RQ(req, "Re-Part");
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Probably some cache lines are assigned into wrong
|
||||
* partition. Need to move it to new one
|
||||
*/
|
||||
ocf_part_move(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
OCF_DEBUG_RQ(req, "Submit Data");
|
||||
|
@@ -96,12 +96,12 @@ static int ocf_write_wi_update_and_flush_metadata(struct ocf_request *req)
|
||||
|
||||
env_atomic_set(&req->req_remaining, 1); /* One core IO */
|
||||
|
||||
ocf_req_hash_lock_wr(req); /*- Metadata WR access ---------------*/
|
||||
ocf_hb_req_prot_lock_wr(req); /*- Metadata WR access ---------------*/
|
||||
|
||||
/* Remove mapped cache lines from metadata */
|
||||
ocf_purge_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req); /*- END Metadata WR access ---------*/
|
||||
ocf_hb_req_prot_unlock_wr(req); /*- END Metadata WR access ---------*/
|
||||
|
||||
if (req->info.flush_metadata) {
|
||||
/* Request was dirty and need to flush metadata */
|
||||
@@ -191,7 +191,7 @@ int ocf_write_wi(struct ocf_request *req)
|
||||
&_io_if_wi_core_write;
|
||||
|
||||
ocf_req_hash(req);
|
||||
ocf_req_hash_lock_rd(req); /*- Metadata READ access, No eviction --------*/
|
||||
ocf_hb_req_prot_lock_rd(req); /*- Metadata READ access, No eviction --------*/
|
||||
|
||||
/* Travers to check if request is mapped fully */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -203,7 +203,7 @@ int ocf_write_wi(struct ocf_request *req)
|
||||
lock = OCF_LOCK_ACQUIRED;
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_rd(req); /*- END Metadata READ access----------------*/
|
||||
ocf_hb_req_prot_unlock_rd(req); /*- END Metadata READ access----------------*/
|
||||
|
||||
if (lock >= 0) {
|
||||
if (lock == OCF_LOCK_ACQUIRED) {
|
||||
|
@@ -213,7 +213,7 @@ int ocf_read_wo(struct ocf_request *req)
|
||||
req->io_if = &_io_if_wo_resume;
|
||||
|
||||
ocf_req_hash(req);
|
||||
ocf_req_hash_lock_rd(req); /*- Metadata RD access -----------------------*/
|
||||
ocf_hb_req_prot_lock_rd(req); /*- Metadata RD access -----------------------*/
|
||||
|
||||
/* Traverse request to check if there are mapped cache lines */
|
||||
ocf_engine_traverse(req);
|
||||
@@ -225,7 +225,7 @@ int ocf_read_wo(struct ocf_request *req)
|
||||
lock = ocf_req_async_lock_rd(req, ocf_engine_on_resume);
|
||||
}
|
||||
|
||||
ocf_req_hash_unlock_rd(req); /*- END Metadata RD access -----------------*/
|
||||
ocf_hb_req_prot_unlock_rd(req); /*- END Metadata RD access -----------------*/
|
||||
|
||||
if (lock >= 0) {
|
||||
if (lock != OCF_LOCK_ACQUIRED) {
|
||||
|
@@ -98,16 +98,16 @@ static inline void _ocf_write_wt_submit(struct ocf_request *req)
|
||||
static void _ocf_write_wt_update_bits(struct ocf_request *req)
|
||||
{
|
||||
if (ocf_engine_is_miss(req)) {
|
||||
ocf_req_hash_lock_rd(req);
|
||||
ocf_hb_req_prot_lock_rd(req);
|
||||
|
||||
/* Update valid status bits */
|
||||
ocf_set_valid_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_rd(req);
|
||||
ocf_hb_req_prot_unlock_rd(req);
|
||||
}
|
||||
|
||||
if (req->info.dirty_any) {
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Writes goes to SDD and HDD, need to update status bits from
|
||||
* dirty to clean
|
||||
@@ -115,20 +115,20 @@ static void _ocf_write_wt_update_bits(struct ocf_request *req)
|
||||
|
||||
ocf_set_clean_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
|
||||
if (ocf_engine_needs_repart(req)) {
|
||||
OCF_DEBUG_RQ(req, "Re-Part");
|
||||
|
||||
ocf_req_hash_lock_wr(req);
|
||||
ocf_hb_req_prot_lock_wr(req);
|
||||
|
||||
/* Probably some cache lines are assigned into wrong
|
||||
* partition. Need to move it to new one
|
||||
*/
|
||||
ocf_part_move(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req);
|
||||
ocf_hb_req_prot_unlock_wr(req);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,12 +23,12 @@ static int ocf_zero_purge(struct ocf_request *req)
|
||||
} else {
|
||||
/* There are mapped cache line, need to remove them */
|
||||
|
||||
ocf_req_hash_lock_wr(req); /*- Metadata WR access ---------------*/
|
||||
ocf_hb_req_prot_lock_wr(req); /*- Metadata WR access ---------------*/
|
||||
|
||||
/* Remove mapped cache lines from metadata */
|
||||
ocf_purge_map_info(req);
|
||||
|
||||
ocf_req_hash_unlock_wr(req); /*- END Metadata WR access ---------*/
|
||||
ocf_hb_req_prot_unlock_wr(req); /*- END Metadata WR access ---------*/
|
||||
}
|
||||
|
||||
ocf_req_unlock_wr(req);
|
||||
|
Reference in New Issue
Block a user