Whamcloud - gitweb
LU-12400 ptlrpc: Sun RPC changes for RCU locking 83/38483/3
authorShaun Tancheff <stancheff@cray.com>
Mon, 4 May 2020 20:16:00 +0000 (13:16 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 May 2020 02:40:14 +0000 (02:40 +0000)
In kernel 4.20 SUNRPC cache_detail->hash_lock changed to spinlock_t

  Now that the reader functions are all RCU protected, use a regular
  spinlock rather than a reader/writer lock.

Linux-commit: 1863d77f15da0addcd293a1719fa5d3ef8cde3ca

This patch is back-ported from the following one:
Lustre-commit: 77d53777e32c80047cb75293d5f9a4c0d23bbea8
Lustre-change: https://review.whamcloud.com/35499

Test-Parameters: trivial
Cray-bug-id: LUS-7600
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Change-Id: If0df38337d5a2bb0ac4b8cb645dbe89f65e0f352
Reviewed-on: https://review.whamcloud.com/38483
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/ptlrpc/gss/gss_internal.h
lustre/ptlrpc/gss/gss_svc_upcall.c

index c9132ce..58184b7 100644 (file)
@@ -2658,6 +2658,31 @@ iterate_shared, [
 ]) # LC_FOPS_ITERATE_SHARED
 
 #
+# LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+#
+# kernel 4.20 commit 1863d77f15da0addcd293a1719fa5d3ef8cde3ca
+# SUNRPC: Replace the cache_detail->hash_lock with a regular spinlock
+#
+# Now that the reader functions are all RCU protected, use a regular
+# spinlock rather than a reader/writer lock.
+#
+AC_DEFUN([LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if cache_detail->hash_lock is a spinlock],
+hash_lock_isa_spinlock_t, [
+       #include <linux/sunrpc/cache.h>
+],[
+       spinlock_t *lock = &(((struct cache_detail *)0)->hash_lock);
+       spin_lock(lock);
+],[
+       AC_DEFINE(HAVE_CACHE_HASH_SPINLOCK, 1,
+               [if cache_detail->hash_lock is a spinlock])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+
+#
 # LC_HAVE_POSIX_ACL_VALID_USER_NS
 #
 # 4.8 posix_acl_valid takes struct user_namespace
@@ -3386,6 +3411,9 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_INODE_TIMESPEC64
        LC_XA_IS_VALUE
 
+       # 4.20
+       LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+
        # 5.1
        LC_HAS_LINUX_SELINUX_ENABLED
 
index 1ba01b3..c49a540 100644 (file)
@@ -358,6 +358,14 @@ static inline struct gss_sec_keyring *sec2gsec_keyring(struct ptlrpc_sec *sec)
         return container_of(sec2gsec(sec), struct gss_sec_keyring, gsk_base);
 }
 
+#ifdef HAVE_CACHE_HASH_SPINLOCK
+# define sunrpc_cache_lookup(c, i, h) sunrpc_cache_lookup_rcu((c), (i), (h))
+# define cache_read_lock(cdetail)   spin_lock(&((cdetail)->hash_lock))
+# define cache_read_unlock(cdetail) spin_unlock(&((cdetail)->hash_lock))
+#else /* ! HAVE_CACHE_HASH_SPINLOCK */
+# define cache_read_lock(cdetail)   read_lock(&((cdetail)->hash_lock))
+# define cache_read_unlock(cdetail) read_unlock(&((cdetail)->hash_lock))
+#endif
 
 #define GSS_CTX_INIT_MAX_LEN            (1024)
 
index 5e88332..bbb4a0b 100644 (file)
@@ -938,11 +938,11 @@ cache_check:
                if (first_check) {
                        first_check = 0;
 
-                       read_lock(&rsi_cache.hash_lock);
+                       cache_read_lock(&rsi_cache);
                        valid = test_bit(CACHE_VALID, &rsip->h.flags);
                        if (valid == 0)
                                set_current_state(TASK_INTERRUPTIBLE);
-                       read_unlock(&rsi_cache.hash_lock);
+                       cache_read_unlock(&rsi_cache);
 
                        if (valid == 0) {
                                unsigned long jiffies;