From 4753374b1b93c08e5e68dda9b3e1bcee0a37a327 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Wed, 28 Dec 2022 13:45:18 +0100 Subject: [PATCH] Change CAS_BIO_MAX_VECS value Previously when user tried to allocate to big bio he recieved NULL. As the behavior was changed to `BUG()` passing out of range value is no longer legal. Limiting the requested bio size to BIO_MAX_PAGES (on the older kernels) or to BIO_MAX_VECS (on the newer ones) eliminates the problem as the macros represent the max possible value. Signed-off-by: Michal Mielewczyk --- configure.d/1_bio_max_vecs.conf | 4 ++-- modules/cas_cache/volume/vol_blk_utils.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.d/1_bio_max_vecs.conf b/configure.d/1_bio_max_vecs.conf index 08de2c9..369f83d 100644 --- a/configure.d/1_bio_max_vecs.conf +++ b/configure.d/1_bio_max_vecs.conf @@ -20,9 +20,9 @@ check() { apply() { case "$1" in "1") - ;; + add_define "CAS_BIO_MAX_VECS ((uint32_t)BIO_MAX_VECS)" ;; "2") - add_define "BIO_MAX_VECS ((uint32_t)(-1))" ;; + add_define "CAS_BIO_MAX_VECS ((uint32_t)BIO_MAX_PAGES)" ;; *) exit 1 esac diff --git a/modules/cas_cache/volume/vol_blk_utils.h b/modules/cas_cache/volume/vol_blk_utils.h index 34a3e15..ddbad01 100644 --- a/modules/cas_cache/volume/vol_blk_utils.h +++ b/modules/cas_cache/volume/vol_blk_utils.h @@ -1,5 +1,5 @@ /* -* Copyright(c) 2012-2021 Intel Corporation +* Copyright(c) 2012-2022 Intel Corporation * SPDX-License-Identifier: BSD-3-Clause */ @@ -90,7 +90,7 @@ static inline uint32_t cas_io_iter_size_done(struct bio_vec_iter *iter) static inline uint32_t cas_io_iter_size_left(struct bio_vec_iter *iter) { if (iter->idx < iter->vec_size) - return min(iter->vec_size - iter->idx, BIO_MAX_VECS); + return min(iter->vec_size - iter->idx, CAS_BIO_MAX_VECS); return 0; /* TODO UNITTEST */ }