Extend alock API with entries_count method
Right now alock assumes that number of locks taken will equal number of core lines. This is not the case in pio, where only parts of metadata are under locks. If pio request overlaps locked and not-locked metadata section it will have different core lines number and awaited locks number. To remedy this discrepancy additional method which gets count of locks that will be taken/waited on is added to alock API. Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@@ -697,6 +697,7 @@ int ocf_alock_lock_rd(struct ocf_alock *alock,
|
||||
struct ocf_request *req, ocf_req_async_lock_cb cmpl)
|
||||
{
|
||||
int lock, status;
|
||||
uint32_t to_lock;
|
||||
|
||||
ENV_BUG_ON(env_atomic_read(&req->lock_remaining));
|
||||
req->alock_rw = OCF_READ;
|
||||
@@ -709,8 +710,10 @@ int ocf_alock_lock_rd(struct ocf_alock *alock,
|
||||
ENV_BUG_ON(env_atomic_read(&req->lock_remaining));
|
||||
ENV_BUG_ON(!cmpl);
|
||||
|
||||
to_lock = alock->cbs->get_entries_count(alock, req);
|
||||
|
||||
env_atomic_inc(&alock->waiting);
|
||||
env_atomic_set(&req->lock_remaining, req->core_line_count);
|
||||
env_atomic_set(&req->lock_remaining, to_lock);
|
||||
env_atomic_inc(&req->lock_remaining);
|
||||
|
||||
status = alock->cbs->lock_entries_slow(alock, req, OCF_READ, cmpl);
|
||||
@@ -734,6 +737,7 @@ int ocf_alock_lock_wr(struct ocf_alock *alock,
|
||||
struct ocf_request *req, ocf_req_async_lock_cb cmpl)
|
||||
{
|
||||
int lock, status;
|
||||
uint32_t to_lock;
|
||||
|
||||
ENV_BUG_ON(env_atomic_read(&req->lock_remaining));
|
||||
req->alock_rw = OCF_WRITE;
|
||||
@@ -745,8 +749,10 @@ int ocf_alock_lock_wr(struct ocf_alock *alock,
|
||||
ENV_BUG_ON(env_atomic_read(&req->lock_remaining));
|
||||
ENV_BUG_ON(!cmpl);
|
||||
|
||||
to_lock = alock->cbs->get_entries_count(alock, req);
|
||||
|
||||
env_atomic_inc(&alock->waiting);
|
||||
env_atomic_set(&req->lock_remaining, req->core_line_count);
|
||||
env_atomic_set(&req->lock_remaining, to_lock);
|
||||
env_atomic_inc(&req->lock_remaining);
|
||||
|
||||
status = alock->cbs->lock_entries_slow(alock, req, OCF_WRITE, cmpl);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef OCF_UTILS_ALOCK_H_
|
||||
@@ -26,10 +26,14 @@ typedef int (*ocf_cl_lock_fast)(struct ocf_alock *alock,
|
||||
typedef int (*ocf_cl_lock_slow)(struct ocf_alock *alock,
|
||||
struct ocf_request *req, int rw, ocf_req_async_lock_cb cmpl);
|
||||
|
||||
typedef uint32_t (*ocf_cl_lock_get_count)(struct ocf_alock *alock,
|
||||
struct ocf_request *req);
|
||||
|
||||
struct ocf_alock_lock_cbs
|
||||
{
|
||||
ocf_cl_lock_fast lock_entries_fast;
|
||||
ocf_cl_lock_slow lock_entries_slow;
|
||||
ocf_cl_lock_get_count get_entries_count;
|
||||
};
|
||||
|
||||
bool ocf_alock_trylock_one_rd(struct ocf_alock *alock,
|
||||
|
Reference in New Issue
Block a user