From c04adbcd76725a360f411f09c63df785bf7db426 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 25 Apr 2022 13:42:32 -0400 Subject: [PATCH] LU-15420 build: fixes to support building on Ubuntu 22.04 LTS MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.whamcloud.com/47133 Reviewed-by: Jian Yu Reviewed-by: Shaun Tancheff Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 40 ++++++++++++++++++++++++++++++++ libcfs/include/libcfs/linux/linux-misc.h | 4 ++++ lustre/include/lu_object.h | 4 ++++ lustre/target/update_trans.c | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index b7e6521..b7e5c03 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1832,6 +1832,43 @@ EXTRA_KCFLAGS="$tmp_flags" ]) # 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 +],[ + 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 @@ -2034,7 +2071,10 @@ LIBCFS_HAVE_CRYPTO_SHA2_HEADER LIBCFS_HAVE_LIST_CMP_FUNC_T # 5.12 LIBCFS_HAVE_CIPHER_HEADER +# 5.13 +LIBCFS_HAVE_TASK_IS_RUNNING # 5.14 +LIBCFS_LINUX_STDARG_HEADER LIBCFS_HAVE_PANIC_NOTIFIER_HEADER # 5.15 LIBCFS_PARAM_SET_UINT_MINMAX diff --git a/libcfs/include/libcfs/linux/linux-misc.h b/libcfs/include/libcfs/linux/linux-misc.h index b9963e4..faec22b 100644 --- a/libcfs/include/libcfs/linux/linux-misc.h +++ b/libcfs/include/libcfs/linux/linux-misc.h @@ -150,6 +150,10 @@ void cfs_arch_init(void); #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) { diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 14c9547..9ceabaf 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -32,7 +32,11 @@ #ifndef __LUSTRE_LU_OBJECT_H #define __LUSTRE_LU_OBJECT_H +#ifdef HAVE_LINUX_STDARG_HEADER +#include +#else #include +#endif #include #include #include diff --git a/lustre/target/update_trans.c b/lustre/target/update_trans.c index b7ab00c..aa13f94 100644 --- a/lustre/target/update_trans.c +++ b/lustre/target/update_trans.c @@ -1608,7 +1608,7 @@ static int distribute_txn_commit_thread(void *_arg) top_multiple_thandle_put(tmt); } - if (current->state) + if (!task_is_running(current)) schedule(); if (OBD_FAIL_PRECHECK(OBD_FAIL_OUT_OBJECT_MISS)) { -- 1.8.3.1