From a2844eb7d4ea15b8164f219aec1900037f0c506b Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 1 Oct 2015 14:59:15 -0400 Subject: [PATCH] LU-6215 ldlm: handle percpu_counter_init change in 3.18+ kernels Starting in 3.18 kernels the function percpu_counter_init() started to take memory allocation flags GFP_*. This patch detects and handles this new case thus enabling lustre servers to function up to 4.2.1 kernels. Change-Id: Ibdb716987c367dc6ea93f6f9747fb70fd7ac2cbb Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/16649 Reviewed-by: Bob Glossman Tested-by: Jenkins Reviewed-by: Frank Zago Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++ lustre/ldlm/ldlm_reclaim.c | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index ac3c74b..dbd055b 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1768,6 +1768,25 @@ EXTRA_KCFLAGS="$tmp_flags" ]) # LC_NFS_FILLDIR_USE_CTX # +# LC_PERCPU_COUNTER_INIT +# +# 3.18 For kernels 3.18 and after percpu_counter_init starts +# to pass a GFP_* memory allocation flag for internal +# memory allocation purposes. +# +AC_DEFUN([LC_PERCPU_COUNTER_INIT], [ +LB_CHECK_COMPILE([if percpu_counter_init uses GFP_* flag as argument], +percpu_counter_init, [ + #include +],[ + percpu_counter_init(NULL, 0, GFP_KERNEL); +],[ + AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_GFP_FLAG, 1, + [percpu_counter_init uses GFP_* flag]) +]) +]) # LC_PERCPU_COUNTER_INIT + +# # LC_KIOCB_HAS_NBYTES # # 3.19 kernel removed ki_nbytes from struct kiocb @@ -2067,6 +2086,7 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_KEY_MATCH_DATA # 3.18 + LC_PERCPU_COUNTER_INIT LC_NFS_FILLDIR_USE_CTX # 3.19 diff --git a/lustre/ldlm/ldlm_reclaim.c b/lustre/ldlm/ldlm_reclaim.c index d256c64..7fda5cf 100644 --- a/lustre/ldlm/ldlm_reclaim.c +++ b/lustre/ldlm/ldlm_reclaim.c @@ -370,7 +370,11 @@ int ldlm_reclaim_setup(void) ldlm_last_reclaim_age = LDLM_RECLAIM_AGE_MAX; ldlm_last_reclaim_time = cfs_time_current(); +#ifdef HAVE_PERCPU_COUNTER_INIT_GFP_FLAG + return percpu_counter_init(&ldlm_granted_total, 0, GFP_KERNEL); +#else return percpu_counter_init(&ldlm_granted_total, 0); +#endif } void ldlm_reclaim_cleanup(void) -- 1.8.3.1