Whamcloud - gitweb
LU-12400 ptlrpc: Sun RPC changes for RCU locking 99/35499/3
authorShaun Tancheff <stancheff@cray.com>
Sun, 14 Jul 2019 11:38:28 +0000 (06:38 -0500)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Sep 2019 23:03:30 +0000 (23:03 +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

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/35499
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.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 68c61f3..4950ea9 100644 (file)
@@ -2660,6 +2660,31 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_UAPI_LINUX_MOUNT_H
 
 #
+# 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_BIO_INTEGRITY_ENABLED
 #
 # 4.13 removed bio_integrity_enabled
@@ -3024,6 +3049,9 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 4.18
        LC_INODE_TIMESPEC64
 
+       # 4.20
+       LC_HAVE_SUNRPC_CACHE_HASH_LOCK_IS_A_SPINLOCK
+
        # 5.0
        LC_UAPI_LINUX_MOUNT_H
 
index 3a7a9d0..a55d782 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 58eb5e4..f5edaf0 100644 (file)
@@ -927,11 +927,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 timeout;