Whamcloud - gitweb
LU-15420 build: fixes to support building on Ubuntu 22.04 LTS 33/47133/5
authorJames Simmons <jsimmons@infradead.org>
Mon, 25 Apr 2022 17:42:32 +0000 (13:42 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 27 Jun 2022 04:57:19 +0000 (04:57 +0000)
Lustre uses the glibc stdarg.h instead of the kernel's version which
causes the following build issue.

lustre/include/lu_object.h:35,
/usr/lib/gcc/x86_64-linux-gnu/11/include/stdarg.h:52: note: this is the
location of the previous definition
        #define va_copy(d,s)    __builtin_va_copy(d,s)

The solution is to use the kernels version of stdarg.h

The second build issue :
update_trans.c:1608:30: error: ‘struct task_struct’ has no member named
                        ‘state’; did you mean ‘__state’?

is due Linux commit 2f064a59a11ff9bc22e52e9678bc601404c7cb34
(sched: Change task_struct::state). The state field was
changed and the barrier macros READ_ONCE()/WRITE_ONCE()
are used to access it now which is the proper thing to do.
Since the check in update_trans.c is equivalent to testing
if the kernel thread is not running, since TASK_RUNNING == 0,
we can just change the code to use task_is_running(). The
task_is_running() was introduced in 5.13.

Test-Parameters: trivial
Change-Id: Ib5985b187c3013fbc513e9962a5f27bed4996f5b
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/47133
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-misc.h
lustre/include/lu_object.h
lustre/target/update_trans.c

index b7e6521..b7e5c03 100644 (file)
@@ -1832,6 +1832,43 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_HAVE_CIPHER_HEADER
 
 #
 ]) # LIBCFS_HAVE_CIPHER_HEADER
 
 #
+# LIBCFS_HAVE_TASK_RUNNING
+#
+# Kernel 5.13-rc6 commit b03fbd4ff24c5f075e58eb19261d5f8b3e40d
+# introduced task_is_running() macro.
+#
+AC_DEFUN([LIBCFS_HAVE_TASK_IS_RUNNING], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if task_is_running() is defined],
+task_is_running, [
+       #include <linux/sched.h>
+],[
+       if (task_is_running(current))
+               schedule();
+],[
+       AC_DEFINE(HAVE_TASK_IS_RUNNING, 1,
+               [task_is_running() is defined])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_HAVE_TASK_IS_RUNNING
+
+#
+# LIBCFS_LINUX_STDARG_HEADER
+#
+# Kernel 5.14-rc5 commit c0891ac15f0428ffa81b2e818d416bdf3cb74ab6
+# isystem: ship and use stdarg.h
+#
+AC_DEFUN([LIBCFS_LINUX_STDARG_HEADER], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_LINUX_HEADER([linux/stdarg.h], [
+       AC_DEFINE(HAVE_LINUX_STDARG_HEADER, 1, [linux/stdarg.h is present])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_LINUX_STDARG_HEADER
+
+#
 # LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
 #
 # Kernel 5.14 commit f39650de687e35766572ac89dbcd16a5911e2f0a
 # LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
 #
 # Kernel 5.14 commit f39650de687e35766572ac89dbcd16a5911e2f0a
@@ -2034,7 +2071,10 @@ LIBCFS_HAVE_CRYPTO_SHA2_HEADER
 LIBCFS_HAVE_LIST_CMP_FUNC_T
 # 5.12
 LIBCFS_HAVE_CIPHER_HEADER
 LIBCFS_HAVE_LIST_CMP_FUNC_T
 # 5.12
 LIBCFS_HAVE_CIPHER_HEADER
+# 5.13
+LIBCFS_HAVE_TASK_IS_RUNNING
 # 5.14
 # 5.14
+LIBCFS_LINUX_STDARG_HEADER
 LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
 # 5.15
 LIBCFS_PARAM_SET_UINT_MINMAX
 LIBCFS_HAVE_PANIC_NOTIFIER_HEADER
 # 5.15
 LIBCFS_PARAM_SET_UINT_MINMAX
index b9963e4..faec22b 100644 (file)
@@ -150,6 +150,10 @@ void cfs_arch_init(void);
 #define sizeof_field(type, member)     FIELD_SIZEOF(type, member)
 #endif
 
 #define sizeof_field(type, member)     FIELD_SIZEOF(type, member)
 #endif
 
+#ifndef HAVE_TASK_IS_RUNNING
+#define task_is_running(task)          (task->state == TASK_RUNNING)
+#endif
+
 #ifdef HAVE_KALLSYMS_LOOKUP_NAME
 static inline void *cfs_kallsyms_lookup_name(const char *name)
 {
 #ifdef HAVE_KALLSYMS_LOOKUP_NAME
 static inline void *cfs_kallsyms_lookup_name(const char *name)
 {
index 14c9547..9ceabaf 100644 (file)
 #ifndef __LUSTRE_LU_OBJECT_H
 #define __LUSTRE_LU_OBJECT_H
 
 #ifndef __LUSTRE_LU_OBJECT_H
 #define __LUSTRE_LU_OBJECT_H
 
+#ifdef HAVE_LINUX_STDARG_HEADER
+#include <linux/stdarg.h>
+#else
 #include <stdarg.h>
 #include <stdarg.h>
+#endif
 #include <libcfs/libcfs.h>
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lu_ref.h>
 #include <libcfs/libcfs.h>
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lu_ref.h>
index b7ab00c..aa13f94 100644 (file)
@@ -1608,7 +1608,7 @@ static int distribute_txn_commit_thread(void *_arg)
                        top_multiple_thandle_put(tmt);
                }
 
                        top_multiple_thandle_put(tmt);
                }
 
-               if (current->state)
+               if (!task_is_running(current))
                        schedule();
 
                if (OBD_FAIL_PRECHECK(OBD_FAIL_OUT_OBJECT_MISS)) {
                        schedule();
 
                if (OBD_FAIL_PRECHECK(OBD_FAIL_OUT_OBJECT_MISS)) {