]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/src/concurrency/ocf_cache_concurrency.h
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef OCF_CACHE_CONCURRENCY_H_
7 #define OCF_CACHE_CONCURRENCY_H_
11 * @brief OCF cache concurrency module
15 * @brief OCF cache concurrency module handle
17 struct ocf_cache_concurrency
;
20 * @brief Initialize OCF cache concurrency module
22 * @param cache - OCF cache instance
23 * @return 0 - Initialization successful, otherwise ERROR
25 int ocf_cache_concurrency_init(struct ocf_cache
*cache
);
28 * @biref De-Initialize OCF cache concurrency module
30 * @param cache - OCF cache instance
32 void ocf_cache_concurrency_deinit(struct ocf_cache
*cache
);
35 * @brief Get number of waiting (suspended) OCF requests in due to cache
38 * @param cache - OCF cache instance
40 * @return Number of suspended OCF requests
42 uint32_t ocf_cache_concurrency_suspended_no(struct ocf_cache
*cache
);
45 * @brief Return memory footprint conusmed by cache concurrency module
47 * @param cache - OCF cache instance
49 * @return Memory footprint of cache concurrency module
51 size_t ocf_cache_concurrency_size_of(struct ocf_cache
*cache
);
54 * @brief Lock OCF request for WRITE access (Lock all cache lines in map info)
56 * @note req->resume callback has to be set
58 * @param req - OCF request
60 * @retval OCF_LOCK_ACQUIRED - OCF request has been locked and can be processed
62 * @retval OCF_LOCK_NOT_ACQUIRED - OCF request lock not acquired, request was
63 * added into waiting list. When lock will be acquired req->resume be called
65 int ocf_req_trylock_wr(struct ocf_request
*req
);
68 * @brief Try complete lock of OCF request for WRITE access (Lock cache lines
69 * that marked as invalid)
71 * @param req - OCF request
73 * @note If request not locked it will be added into waiting list
75 * @retval OCF_LOCK_ACQUIRED - OCF request has been locked and can be processed
77 * @retval OCF_LOCK_NOT_ACQUIRED - OCF request lock not acquired, request was
78 * added into waiting list. When lock will be acquired req->resume be called
80 int ocf_req_retrylock_wr(struct ocf_request
*req
);
83 * @brief Lock OCF request for READ access (Lock all cache lines in map info)
85 * @note req->resume callback has to be set
87 * @param req - OCF request
89 * @retval OCF_LOCK_ACQUIRED - OCF request has been locked and can be processed
91 * @retval OCF_LOCK_NOT_ACQUIRED - OCF request lock not acquired, request was
92 * added into waiting list. When lock will be acquired req->resume be called
94 int ocf_req_trylock_rd(struct ocf_request
*req
);
97 * @brief Unlock OCF request from WRITE access
99 * @param req - OCF request
101 void ocf_req_unlock_wr(struct ocf_request
*req
);
104 * @brief Unlock OCF request from READ access
106 * @param req - OCF request
108 void ocf_req_unlock_rd(struct ocf_request
*req
);
111 * @brief Unlock OCF request from READ or WRITE access
113 * @param req - OCF request
115 void ocf_req_unlock(struct ocf_request
*req
);
118 * @Check if cache line is used.
120 * Cache line is used when:
121 * 1. It is locked for write or read access
123 * 2. There is set locked bit in metadata
125 * @param cache - OCF cache instance
126 * @param line - Cache line to be unlocked
128 * @retval true - cache line is used
129 * @retval false - cache line is not used
131 bool ocf_cache_line_is_used(struct ocf_cache
*cache
,
132 ocf_cache_line_t line
);
135 * @brief Check if for specified cache line there are waiters
136 * on the waiting list
138 * @param cache - OCF cache instance
139 * @param line - Cache line to be checked for waiters
141 * @retval true - there are waiters
142 * @retval false - No waiters
144 bool ocf_cache_line_are_waiters(struct ocf_cache
*cache
,
145 ocf_cache_line_t line
);
148 * @brief un_lock request map info entry from from WRITE or READ access.
150 * @param cache - OCF cache instance
151 * @param req - OCF request
152 * @param entry - request map entry number
154 void ocf_req_unlock_entry(struct ocf_cache
*cache
,
155 struct ocf_request
*req
, uint32_t entry
);
158 * @brief Release cache line read lock
160 * @param cache - OCF cache instance
161 * @param line - Cache line to be unlocked
163 void ocf_cache_line_unlock_rd(struct ocf_cache
*cache
, ocf_cache_line_t line
);
166 * @brief Attempt to lock cache line for read
168 * @param cache - OCF cache instance
169 * @param line - Cache line to be checked for waiters
171 * @retval true - read lock successfully acquired
172 * @retval false - failed to acquire read lock
174 bool ocf_cache_line_try_lock_rd(struct ocf_cache
*cache
, ocf_cache_line_t line
);
176 #endif /* OCF_CONCURRENCY_H_ */