Lock cachelines under hash bucket locks
.. or when holding exclusive global metadata lock. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
e02821d399
commit
cf5a92b527
@ -414,14 +414,16 @@ static int ocf_engine_evict(struct ocf_request *req)
|
|||||||
ocf_engine_unmapped_count(req));
|
ocf_engine_unmapped_count(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lock_clines(struct ocf_request *req, enum ocf_engine_lock_type lock,
|
static int lock_clines(struct ocf_request *req,
|
||||||
ocf_req_async_lock_cb cb)
|
const struct ocf_engine_callbacks *engine_cbs)
|
||||||
{
|
{
|
||||||
switch (lock) {
|
enum ocf_engine_lock_type lock_type = engine_cbs->get_lock_type(req);
|
||||||
|
|
||||||
|
switch (lock_type) {
|
||||||
case ocf_engine_lock_write:
|
case ocf_engine_lock_write:
|
||||||
return ocf_req_async_lock_wr(req, cb);
|
return ocf_req_async_lock_wr(req, engine_cbs->resume);
|
||||||
case ocf_engine_lock_read:
|
case ocf_engine_lock_read:
|
||||||
return ocf_req_async_lock_rd(req, cb);
|
return ocf_req_async_lock_rd(req, engine_cbs->resume);
|
||||||
default:
|
default:
|
||||||
return OCF_LOCK_ACQUIRED;
|
return OCF_LOCK_ACQUIRED;
|
||||||
}
|
}
|
||||||
@ -433,7 +435,6 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
|||||||
bool mapped;
|
bool mapped;
|
||||||
bool promote = true;
|
bool promote = true;
|
||||||
int lock = -ENOENT;
|
int lock = -ENOENT;
|
||||||
enum ocf_engine_lock_type lock_type;
|
|
||||||
struct ocf_metadata_lock *metadata_lock = &req->cache->metadata.lock;
|
struct ocf_metadata_lock *metadata_lock = &req->cache->metadata.lock;
|
||||||
|
|
||||||
/* Calculate hashes for hash-bucket locking */
|
/* Calculate hashes for hash-bucket locking */
|
||||||
@ -451,8 +452,7 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
|||||||
if (mapped) {
|
if (mapped) {
|
||||||
/* Request cachelines are already mapped, acquire cacheline
|
/* Request cachelines are already mapped, acquire cacheline
|
||||||
* lock */
|
* lock */
|
||||||
lock_type = engine_cbs->get_lock_type(req);
|
lock = lock_clines(req, engine_cbs);
|
||||||
lock = lock_clines(req, lock_type, engine_cbs->resume);
|
|
||||||
} else {
|
} else {
|
||||||
/* check if request should promote cachelines */
|
/* check if request should promote cachelines */
|
||||||
promote = ocf_promotion_req_should_promote(
|
promote = ocf_promotion_req_should_promote(
|
||||||
@ -469,6 +469,8 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
|||||||
* performed holding (at least) hash-bucket write lock */
|
* performed holding (at least) hash-bucket write lock */
|
||||||
ocf_req_hash_lock_upgrade(req);
|
ocf_req_hash_lock_upgrade(req);
|
||||||
ocf_engine_map(req);
|
ocf_engine_map(req);
|
||||||
|
if (!req->info.mapping_error)
|
||||||
|
lock = lock_clines(req, engine_cbs);
|
||||||
ocf_req_hash_unlock_wr(req);
|
ocf_req_hash_unlock_wr(req);
|
||||||
|
|
||||||
if (req->info.mapping_error) {
|
if (req->info.mapping_error) {
|
||||||
@ -482,14 +484,10 @@ int ocf_engine_prepare_clines(struct ocf_request *req,
|
|||||||
if (ocf_engine_evict(req) == LOOKUP_MAPPED)
|
if (ocf_engine_evict(req) == LOOKUP_MAPPED)
|
||||||
ocf_engine_map(req);
|
ocf_engine_map(req);
|
||||||
|
|
||||||
ocf_metadata_end_exclusive_access(metadata_lock);
|
if (!req->info.mapping_error)
|
||||||
}
|
lock = lock_clines(req, engine_cbs);
|
||||||
|
|
||||||
if (!req->info.mapping_error) {
|
ocf_metadata_end_exclusive_access(metadata_lock);
|
||||||
/* Request mapped successfully - acquire cacheline
|
|
||||||
* lock */
|
|
||||||
lock_type = engine_cbs->get_lock_type(req);
|
|
||||||
lock = lock_clines(req, lock_type, engine_cbs->resume);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user