Whamcloud - gitweb
LU-18086 sec: fix warning message for insufficient memory 68/57368/3
authorSebastien Buisson <sbuisson@ddn.com>
Wed, 11 Dec 2024 10:21:00 +0000 (11:21 +0100)
committerOleg Drokin <green@whamcloud.com>
Thu, 2 Jan 2025 20:52:43 +0000 (20:52 +0000)
If even the very first pool cannot be allocated, then pool_order is 0.
So fix warning message in this case, as reported by Coverity:

CoverityID: 451725 ("Integer handling issues")
   In expression "0x1000UL << pool_order - 1", shifting by a negative
   amount has undefined behavior.  The shift amount, "pool_order - 1",
   is -1.

Fixes: 1a6ae4b3eb ("LU-18086 sec: do not allocate empty pools")
Test-Parameters: trivial
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I45a8cf45cae3a8ed07b170d852ec5e1d096da656
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57368
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/obdclass/page_pools.c

index 3a6d132..37d5090 100644 (file)
@@ -1080,7 +1080,8 @@ int obd_pool_init(void)
                 */
                if (!pool->opp_max_ptr_pages) {
                        CWARN("Cannot allocate pool %i, not enough memory. Max available compression chunk is %lu.\n",
-                             pool_order, PAGE_SIZE << (pool_order - 1));
+                             pool_order,
+                             pool_order ? PAGE_SIZE << (pool_order - 1) : 0);
                        pools_count = pool_order;
                        OBD_FREE(pool, sizeof(**page_pools));
                        break;