Whamcloud - gitweb
LU-12904 gss: struct cache_detail readers changed to writers 93/38193/3
authorShaun Tancheff <stancheff@cray.com>
Fri, 10 Apr 2020 05:50:25 +0000 (22:50 -0700)
committerOleg Drokin <green@whamcloud.com>
Sun, 19 Apr 2020 08:50:00 +0000 (08:50 +0000)
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 <stancheff@cray.com>
Change-Id: I7750303937cd6fc560e458efa79f25e521fefec7
Reviewed-on: https://review.whamcloud.com/38193
Reviewed-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
lustre/ptlrpc/gss/gss_svc_upcall.c

index cc346b6..08e49d0 100644 (file)
@@ -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 <linux/sunrpc/cache.h>
+
+       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
 
 #
index bd52446..a1058b1 100644 (file)
@@ -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");