From dc128be9dd4e0a4bb59b2243612f298c6c6d3e70 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sun, 31 Jul 2022 10:06:08 -0400 Subject: [PATCH] LU-10973 lutf: Fix order of linking for python modules LUTF normally works but in some test cases at startup we got: ImportError: lustre/test/lutrf/src/_lnetconfig.so: undefined symbol: lustre_lnet_del_ni If you check the symbol is there. The issue is the linking order. We need to put the generated module name before all its dependencies. Also, remove cfs_expr_list_match from string.h, move the definition to nidstrings.c, and make it static. Test-Parameters: @lnet Change-Id: Ia57fbd9d5795d845ea14bc1416f968383afcba2b Signed-off-by: James Simmons Signed-off-by: Timothy Day Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46478 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Frank Sehr Reviewed-by: Cyril Bordage Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/util/string.h | 1 - libcfs/libcfs/util/nidstrings.c | 20 ++++++++++++++++++++ libcfs/libcfs/util/string.c | 20 -------------------- lustre/tests/lutf/src/Makefile.am | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/libcfs/include/libcfs/util/string.h b/libcfs/include/libcfs/util/string.h index 3ad5a95..dcfe29e 100644 --- a/libcfs/include/libcfs/util/string.h +++ b/libcfs/include/libcfs/util/string.h @@ -128,7 +128,6 @@ int cfs_str2num_check(char *str, int nob, unsigned *num, unsigned min, unsigned max); int cfs_human_readable2long(unsigned long *sizep, char *str); int cfs_expr2str(struct list_head *list, char *str, size_t size); -int cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list); int cfs_expr_list_print(char *buffer, int count, struct cfs_expr_list *expr_list); int cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max, diff --git a/libcfs/libcfs/util/nidstrings.c b/libcfs/libcfs/util/nidstrings.c index c9e31a4..636fa36 100644 --- a/libcfs/libcfs/util/nidstrings.c +++ b/libcfs/libcfs/util/nidstrings.c @@ -481,6 +481,26 @@ cfs_ip_addr_range_gen(__u32 *ip_list, int count, struct list_head *ip_addr_expr) } /** + * Matches value (\a value) against ranges expression list \a expr_list. + * + * \retval 1 if \a value matches + * \retval 0 otherwise + */ +static int +cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list) +{ + struct cfs_range_expr *expr; + + list_for_each_entry(expr, &expr_list->el_exprs, re_link) { + if (value >= expr->re_lo && value <= expr->re_hi && + ((value - expr->re_lo) % expr->re_stride) == 0) + return 1; + } + + return 0; +} + +/** * Matches address (\a addr) against address set encoded in \a list. * * \retval 1 if \a addr matches diff --git a/libcfs/libcfs/util/string.c b/libcfs/libcfs/util/string.c index 205f3c3..b3e3209 100644 --- a/libcfs/libcfs/util/string.c +++ b/libcfs/libcfs/util/string.c @@ -271,26 +271,6 @@ cfs_expr_list_print(char *buffer, int count, struct cfs_expr_list *expr_list) } /** - * Matches value (\a value) against ranges expression list \a expr_list. - * - * \retval 1 if \a value matches - * \retval 0 otherwise - */ -int -cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list) -{ - struct cfs_range_expr *expr; - - list_for_each_entry(expr, &expr_list->el_exprs, re_link) { - if (value >= expr->re_lo && value <= expr->re_hi && - ((value - expr->re_lo) % expr->re_stride) == 0) - return 1; - } - - return 0; -} - -/** * Convert express list (\a expr_list) to an array of all matched values * * \retval N N is total number of all matched values diff --git a/lustre/tests/lutf/src/Makefile.am b/lustre/tests/lutf/src/Makefile.am index 8c4d7d0..85273a2 100644 --- a/lustre/tests/lutf/src/Makefile.am +++ b/lustre/tests/lutf/src/Makefile.am @@ -103,7 +103,7 @@ dlc_glue: echo "building liblnetconfig_wrap.c" $(CC) $(SWIG_COMPFLAGS) $(PYTHON_CPPFLAGS) $(DLC_INCLUDES) $(LIBLNETCONFIG_WRAP_I) $(CYAML_SRC) echo "linking _lnetconfig.so" - $(CC) $(LIBLNETCONFIG) -lyaml -llnetconfig -Wl,--whole-archive $(LIBCFS) $(CYAML_OBJ) -Wl,--no-whole-archive -shared -o _lnetconfig.so $(LIBLNETCONFIG_WRAP_OBJ) $(PYTHON_EXTRA_LIBS) $(PYTHON_LIBS) + $(CC) -shared -o _lnetconfig.so $(LIBCFS) -lyaml $(LIBLNETCONFIG) -llnetconfig $(CYAML_OBJ) $(LIBLNETCONFIG_WRAP_OBJ) $(PYTHON_EXTRA_LIBS) $(PYTHON_LIBS) install-exec-local: $(mkinstalldirs) $(DESTDIR)$(libdir) -- 1.8.3.1