Whamcloud - gitweb
LU-18935 libcfs: cfs_num_min_max() returns wrong max value 56/58856/3
authorRajeev Mishra <rajeevm@hpe.com>
Tue, 16 May 2023 21:51:09 +0000 (21:51 +0000)
committerOleg Drokin <green@whamcloud.com>
Tue, 27 May 2025 04:05:42 +0000 (04:05 +0000)
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 <rajeevm@hpe.com>
Test-Parameters: testlist=sanity-sec.sh
Change-Id: I368f8563648c1819a89e76fa8974818b5f8f6111
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58856
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
libcfs/libcfs/util/nidstrings.c

index 6275299..196e398 100644 (file)
@@ -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)