Merge pull request #345 from arutk/resize_discard_alloc

Fix discard request map allocation
This commit is contained in:
rafalste 2020-02-10 16:12:17 +01:00 committed by GitHub
commit 1dfae0d166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

2
env/posix/ocf_env.h vendored
View File

@ -71,6 +71,8 @@ typedef uint64_t sector_t;
#define ENV_BUG() assert(0)
#define ENV_BUG_ON(cond) do { if (cond) ENV_BUG(); } while (0)
#define ENV_BUILD_BUG_ON(cond) _Static_assert(!(cond), "static "\
"assertion failure")
/* MISC UTILITIES */
#define container_of(ptr, type, member) ({ \

View File

@ -352,6 +352,6 @@ typedef enum {
* @}
*/
#define MAX_TRIM_RQ_SIZE (1 * MiB)
#define MAX_TRIM_RQ_SIZE (512 * KiB)
#endif /* __OCF_DEF_H__ */

View File

@ -42,7 +42,7 @@ struct ocf_req_allocator {
static inline size_t ocf_req_sizeof_map(struct ocf_request *req)
{
uint32_t lines = req->alloc_core_line_count;
uint32_t lines = req->core_line_count;
size_t size = (lines * sizeof(struct ocf_map_info));
ENV_BUG_ON(lines == 0);
@ -224,6 +224,9 @@ int ocf_req_alloc_map(struct ocf_request *req)
int ocf_req_alloc_map_discard(struct ocf_request *req)
{
ENV_BUILD_BUG_ON(MAX_TRIM_RQ_SIZE / ocf_cache_line_size_4 *
sizeof(struct ocf_map_info) > 4 * KiB);
if (req->byte_length <= MAX_TRIM_RQ_SIZE)
return ocf_req_alloc_map(req);