diff --git a/env/posix/ocf_env.h b/env/posix/ocf_env.h index d255174..c175c31 100644 --- a/env/posix/ocf_env.h +++ b/env/posix/ocf_env.h @@ -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) ({ \ diff --git a/inc/ocf_def.h b/inc/ocf_def.h index b5a4364..bdbe211 100644 --- a/inc/ocf_def.h +++ b/inc/ocf_def.h @@ -352,6 +352,6 @@ typedef enum { * @} */ -#define MAX_TRIM_RQ_SIZE (1 * MiB) +#define MAX_TRIM_RQ_SIZE (512 * KiB) #endif /* __OCF_DEF_H__ */ diff --git a/src/ocf_request.c b/src/ocf_request.c index 8584b71..d15ca01 100644 --- a/src/ocf_request.c +++ b/src/ocf_request.c @@ -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);