From a593e1bf51993501de229f12b4bcfa37a4243cb0 Mon Sep 17 00:00:00 2001 From: Rajeev Mishra Date: Tue, 16 May 2023 21:51:09 +0000 Subject: [PATCH] LU-18935 libcfs: cfs_num_min_max() returns wrong max value The cfs_num_min_max() function is called using the nf_min_max function pointer. It returns the minimum and maximum values for a given range. However, if a network type uses cfs_num_min_max() to find the min and max of the range, it will encounter an issue where the start and end values of the range will be same. This occurs because cfs_num_min_max() was returning the same value for both the max and min Here's an example specific to the "kfi" type, which utilizes "cfs_num_min_max()" to find the minimum and maximum values. As a result of the bug, the start and end values of the range are the same. Added range for kfi type-- lctl nodemap_add_range --name alps --range [0-131071]@kfi show the range added lctl get_param nodemap.alps.ranges nodemap.alps.ranges= [ { id: 1, start_nid: 0@kfi, end_nid: 0@kfi } ] Signed-off-by: Rajeev Mishra Test-Parameters: testlist=sanity-sec.sh Change-Id: I368f8563648c1819a89e76fa8974818b5f8f6111 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58856 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Petros Koutoupis Reviewed-by: Chris Horn --- libcfs/libcfs/util/nidstrings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcfs/libcfs/util/nidstrings.c b/libcfs/libcfs/util/nidstrings.c index 6275299..196e398 100644 --- a/libcfs/libcfs/util/nidstrings.c +++ b/libcfs/libcfs/util/nidstrings.c @@ -2035,7 +2035,7 @@ static int cfs_num_min_max(struct list_head *nidlist, __u32 *min_nid, if (tmp_min_addr < min_addr || min_addr == 0) min_addr = tmp_min_addr; if (tmp_max_addr > max_addr) - max_addr = tmp_min_addr; + max_addr = tmp_max_addr; } } if (max_nid != NULL) -- 1.8.3.1