From: Shaun Tancheff Date: Sun, 14 Jul 2019 11:38:28 +0000 (-0500) Subject: LU-12400 ptlrpc: Sun RPC changes for RCU locking X-Git-Tag: 2.12.90~146 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=77d53777e32c80047cb75293d5f9a4c0d23bbea8 LU-12400 ptlrpc: Sun RPC changes for RCU locking 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 Change-Id: If0df38337d5a2bb0ac4b8cb645dbe89f65e0f352 Reviewed-on: https://review.whamcloud.com/35499 Tested-by: jenkins Reviewed-by: Petros Koutoupis Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 68c61f3..4950ea9 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + 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 diff --git a/lustre/ptlrpc/gss/gss_internal.h b/lustre/ptlrpc/gss/gss_internal.h index 3a7a9d0..a55d782 100644 --- a/lustre/ptlrpc/gss/gss_internal.h +++ b/lustre/ptlrpc/gss/gss_internal.h @@ -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) diff --git a/lustre/ptlrpc/gss/gss_svc_upcall.c b/lustre/ptlrpc/gss/gss_svc_upcall.c index 58eb5e4..f5edaf0 100644 --- a/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -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;