Whamcloud - gitweb
LU-12904 gss: struct cache_detail readers changed to writers 80/36580/4
authorShaun Tancheff <stancheff@cray.com>
Tue, 17 Dec 2019 04:29:15 +0000 (22:29 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 3 Jan 2020 00:09:06 +0000 (00:09 +0000)
Linux 5.3 changed struct cache_detail readers to writers
SUNRPC: Track writers of the 'channel' file to improve ...

kernel-commit: 64a38e840ce5940253208eaba40265c73decc4ee

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/36580
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
lustre/ptlrpc/gss/gss_svc_upcall.c

index 9fd7e10..32c5caf 100644 (file)
@@ -1290,6 +1290,29 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_FORCE_SIG_WITH_TASK
 
 #
+# 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
@@ -1405,6 +1428,7 @@ LIBCFS_HAVE_IOV_ITER_TYPE
 LIBCFS_MM_TOTALRAM_PAGES_FUNC
 # 5.3
 LIBCFS_FORCE_SIG_WITH_TASK
+LIBCFS_CACHE_DETAIL_WRITERS
 ]) # LIBCFS_PROG_LINUX
 
 #
index f5edaf0..1c643ec 100644 (file)
@@ -163,6 +163,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,
@@ -1125,13 +1137,13 @@ 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);
                schedule_timeout(cfs_time_seconds(1) / 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");