From efc5c8d4de60d394344506f7cfb188eaf04a4bac Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Thu, 1 Dec 2022 03:17:00 -0500 Subject: [PATCH] LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h The lustre_user.h header uses the non-standard strchrnul() function in userspace. This will always leads to LC_IOC_REMOVE_ENTRY configure check to fail, and in the end "lfs rm_entry" always returns -ENOTSUP. Implement an alternative approach to avoid external dependencies on the lustre_user.h header. Also, LC_IOC_REMOVE_ENTRY is itself unnecessary, the code can check for LL_IOC_REMOVE_ENTRY directly. Replace the NFS-specific -ENOTSUP error return code with -EOPNOTSUPP. Fix the compile test_400[ab] checks to not use "-std=c99" to verify that the uapi headers are usable without this dependency. Fixes: b59835f8b6 ("LU-13903 utils: have liblustreapi support Linux client") Fixes: 7a7309fa84 ("LU-13274 uapi: make lustre UAPI headers C99 compliant") Fixes: 6331eadbd6 ("LU-15420 uapi: avoid gcc-11 -Werror=stringop-overread") Signed-off-by: Lai Siyao Change-Id: If42743a2148c317b8a9b701ceb5d08bac5149f5f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49328 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- config/lustre-build.m4 | 1 - lustre/autoconf/lustre-core.m4 | 24 ------------------------ lustre/include/uapi/linux/lustre/lustre_user.h | 6 +++++- lustre/tests/sanity.sh | 15 ++++++++------- lustre/utils/liblustreapi_util.c | 4 ++-- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index c2577d8..afe606e 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -693,7 +693,6 @@ AS_IF([test "x$enable_utils" = xno], [enable_tests="no"]) AS_IF([test "x$enable_utils" = xyes], [ LC_OPENSSL_GETSEPOL LC_FID2PATH_ANON_UNION - LC_IOC_REMOVE_ENTRY ]) AS_IF([test "x$enable_tests" = xyes], [ LC_HAVE_LIBAIO diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index d82d30d..9063dd3 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -92,30 +92,6 @@ CFLAGS="$saved_flags" ]) # LC_FID2PATH_ANON_UNION # -# LC_IOC_REMOVE_ENTRY -# -AC_DEFUN([LC_IOC_REMOVE_ENTRY], [ -saved_flags="$CFLAGS" -CFLAGS="$CFLAGS -Werror" -AC_MSG_CHECKING([if ioctl IOC_REMOVE_ENTRY' is supported]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - #include - #include - - int main(void) { - return ioctl(0, LL_IOC_REMOVE_ENTRY, NULL); - } -])],[ - AC_DEFINE(HAVE_IOC_REMOVE_ENTRY, 1, - [IOC_REMOVE_ENTRY ioctl exists]) - AC_MSG_RESULT([yes]) -],[ - AC_MSG_RESULT([no]) -]) -CFLAGS="$saved_flags" -]) # LC_IOC_REMOVE_ENTRY - -# # LC_STACK_SIZE # # Ensure the stack size is at least 8k in Lustre server (all kernels) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 1b1e60a..36e1e70 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -2033,7 +2033,11 @@ static inline char *changelog_rec_name(const struct changelog_rec *rec) static inline char *changelog_rec_sname(const struct changelog_rec *rec) { - return strchrnul(changelog_rec_name(rec), '\0') + 1; + char *str = changelog_rec_name(rec); + + while (*str != '\0') + str++; + return str + 1; } static inline __kernel_size_t changelog_rec_snamelen(const struct changelog_rec *rec) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index aac7a2f..9ebd48b 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -25471,18 +25471,19 @@ test_400a() { # LU-1606, was conf-sanity test_74 local prefix=/usr/include/lustre local prog - # Oleg removes c files in his test rig so test if any c files exist - [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \ - skip_env "Needed c test files are missing" + # Oleg removes .c files in his test rig so test if any c files exist + [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] || + skip_env "Needed .c test files are missing" if ! [[ -d $prefix ]]; then # Assume we're running in tree and fixup the include path. - extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include" - extra_flags+=" -L$LUSTRE/utils/.lib" + extra_flags+=" -I$LUSTRE/../lnet/include/uapi" + extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include" + extra_flags+=" -L$LUSTRE/utils/.libs" fi for prog in $LUSTRE_TESTS_API_DIR/*.c; do - $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi || + $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi || error "client api broken" done rm -f $out @@ -25514,7 +25515,7 @@ test_400b() { # LU-1606, LU-5011 continue # lustre_ioctl.h is internal header fi - $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out || + $CC -Wall -Werror -include $header -c -x c /dev/null -o $out || error "cannot compile '$header'" done rm -f $out diff --git a/lustre/utils/liblustreapi_util.c b/lustre/utils/liblustreapi_util.c index ad69d93..e751bcbf 100644 --- a/lustre/utils/liblustreapi_util.c +++ b/lustre/utils/liblustreapi_util.c @@ -315,7 +315,7 @@ retry_open: int llapi_direntry_remove(char *dname) { -#ifdef HAVE_IOC_REMOVE_ENTRY +#ifdef LL_IOC_REMOVE_ENTRY char *dirpath = NULL; char *namepath = NULL; char *dir; @@ -351,7 +351,7 @@ out: close(fd); return rc; #else - return -ENOTSUP; + return -EOPNOTSUPP; #endif } -- 1.8.3.1