From cb070d9a7fc285996687eab774c6d0130d5d9347 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 14 May 2017 03:13:56 +0000 Subject: [PATCH] scst/include/backport.h: Add a backport of rcu_dereference_protected() This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7179 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/ft_sess.c | 16 ---------------- scst/include/backport.h | 5 +++++ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/fcst/ft_sess.c b/fcst/ft_sess.c index a11507c66..7486d1327 100644 --- a/fcst/ft_sess.c +++ b/fcst/ft_sess.c @@ -49,12 +49,8 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport) ft_format_wwn(name, sizeof(name), lport->wwpn); FT_SESS_DBG("create %s\n", name); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) tport = rcu_dereference_protected(lport->prov[FC_TYPE_FCP], lockdep_is_held(&ft_lport_lock)); -#else - tport = rcu_dereference(lport->prov[FC_TYPE_FCP]); -#endif if (tport) { FT_SESS_DBG("tport alloc %s - already setup\n", name); return tport; @@ -187,11 +183,7 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id) struct ft_sess *sess; rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) tport = rcu_dereference_protected(lport->prov[FC_TYPE_FCP], true); -#else - tport = rcu_dereference(lport->prov[FC_TYPE_FCP]); -#endif if (!tport) goto out; @@ -406,13 +398,9 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len, if (!(fcp_parm & FCP_SPPF_INIT_FCN)) return FC_SPP_RESP_CONF; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) tport = rcu_dereference_protected( rdata->local_port->prov[FC_TYPE_FCP], lockdep_is_held(&ft_lport_lock)); -#else - tport = rcu_dereference(rdata->local_port->prov[FC_TYPE_FCP]); -#endif if (!tport) { /* not a target for this local port */ return FC_SPP_RESP_CONF; @@ -492,12 +480,8 @@ static void ft_prlo(struct fc_rport_priv *rdata) struct ft_tport *tport; mutex_lock(&ft_lport_lock); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) tport = rcu_dereference_protected(rdata->local_port->prov[FC_TYPE_FCP], lockdep_is_held(&ft_lport_lock)); -#else - tport = rcu_dereference(rdata->local_port->prov[FC_TYPE_FCP]); -#endif if (!tport) { mutex_unlock(&ft_lport_lock); return; diff --git a/scst/include/backport.h b/scst/include/backport.h index de3baa95f..6f67ec001 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -525,6 +525,11 @@ static inline int __ratelimit(struct ratelimit_state *rs) /* */ +/* See also commit b62730baea32 */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) +#define rcu_dereference_protected(p, c) rcu_dereference(p) +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && !defined(kfree_rcu) typedef void (*rcu_callback_t)(struct rcu_head *); #define __is_kfree_rcu_offset(offset) ((offset) < 4096)