From 14a18654a64ae05a94a4394d53b030ce91357e9a Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 9 Apr 2020 22:50:25 -0700 Subject: [PATCH] LU-12904 gss: struct cache_detail readers changed to writers Linux 5.3 changed struct cache_detail readers to writers SUNRPC: Track writers of the 'channel' file to improve ... kernel-commit: 64a38e840ce5940253208eaba40265c73decc4ee This patch is back-ported from the following one: Lustre-commit: 81fb8bc7d214394bbc504379a5a84441e871b60a Lustre-change: https://review.whamcloud.com/36580 Test-Parameters: trivial Cray-bug-id: LUS-8042 Signed-off-by: Shaun Tancheff Change-Id: I7750303937cd6fc560e458efa79f25e521fefec7 Reviewed-on: https://review.whamcloud.com/38193 Reviewed-by: Minh Diep Reviewed-by: Olaf Faaland-LLNL Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 25 +++++++++++++++++++++++++ lustre/ptlrpc/gss/gss_svc_upcall.c | 16 ++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index cc346b6..08e49d0 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -998,6 +998,29 @@ timer_setup, [ ]) # LIBCFS_TIMER_SETUP # +# LIBCFS_CACHE_DETAIL_WRITERS +# +# kernel v5.3-rc2-1-g64a38e840ce5 +# SUNRPC: Track writers of the 'channel' file to improve cache_listeners_exist +# +AC_DEFUN([LIBCFS_CACHE_DETAIL_WRITERS], [ +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_CHECK_COMPILE([if struct cache_detail has writers], +cache_detail_writers_atomic, [ + #include + + static struct cache_detail rsi_cache; +],[ + atomic_set(&rsi_cache.writers, 0); +],[ + AC_DEFINE(HAVE_CACHE_DETAIL_WRITERS, 1, + [struct cache_detail has writers]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) # LIBCFS_CACHE_DETAIL_WRITERS + +# # LIBCFS_PROG_LINUX # # LibCFS linux kernel checks @@ -1091,6 +1114,8 @@ LIBCFS_NEW_KERNEL_WRITE LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK # 4.15 LIBCFS_TIMER_SETUP +# 5.3 +LIBCFS_CACHE_DETAIL_WRITERS ]) # LIBCFS_PROG_LINUX # diff --git a/lustre/ptlrpc/gss/gss_svc_upcall.c b/lustre/ptlrpc/gss/gss_svc_upcall.c index bd52446..a1058b1 100644 --- a/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -162,6 +162,18 @@ static struct cache_detail rsi_cache; static struct rsi *rsi_update(struct rsi *new, struct rsi *old); static struct rsi *rsi_lookup(struct rsi *item); +#ifdef HAVE_CACHE_DETAIL_WRITERS +static inline int channel_users(struct cache_detail *cd) +{ + return atomic_read(&cd->writers); +} +#else +static inline int channel_users(struct cache_detail *cd) +{ + return atomic_read(&cd->readers); +} +#endif + static inline int rsi_hash(struct rsi *item) { return hash_mem((char *)item->in_handle.data, item->in_handle.len, @@ -1204,14 +1216,14 @@ int __init gss_init_svc_upcall(void) * Here we wait at minimum 1.5 seconds. */ for (i = 0; i < 6; i++) { - if (atomic_read(&rsi_cache.readers) > 0) + if (channel_users(&rsi_cache) > 0) break; set_current_state(TASK_UNINTERRUPTIBLE); LASSERT(msecs_to_jiffies(MSEC_PER_SEC / 4) > 0); schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC / 4)); } - if (atomic_read(&rsi_cache.readers) == 0) + if (channel_users(&rsi_cache) == 0) CWARN("Init channel is not opened by lsvcgssd, following " "request might be dropped until lsvcgssd is active\n"); -- 1.8.3.1