Whamcloud - gitweb
LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h 28/49328/8
authorLai Siyao <lai.siyao@whamcloud.com>
Thu, 1 Dec 2022 08:17:00 +0000 (03:17 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 20 Dec 2022 16:32:02 +0000 (16:32 +0000)
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 <lai.siyao@whamcloud.com>
Change-Id: If42743a2148c317b8a9b701ceb5d08bac5149f5f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49328
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
config/lustre-build.m4
lustre/autoconf/lustre-core.m4
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/tests/sanity.sh
lustre/utils/liblustreapi_util.c

index c2577d8..afe606e 100644 (file)
@@ -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
index d82d30d..9063dd3 100644 (file)
@@ -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 <sys/ioctl.h>
-       #include <linux/lustre/lustre_ioctl.h>
-
-       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)
index 1b1e60a..36e1e70 100644 (file)
@@ -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)
index aac7a2f..9ebd48b 100755 (executable)
@@ -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
index ad69d93..e751bcb 100644 (file)
@@ -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
 }