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
This commit is contained in:
Bart Van Assche
2017-05-14 03:13:56 +00:00
parent b4118ea0f1
commit cb070d9a7f
2 changed files with 5 additions and 16 deletions
-16
View File
@@ -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;
+5
View File
@@ -525,6 +525,11 @@ static inline int __ratelimit(struct ratelimit_state *rs)
/* <linux/rcupdate.h> */
/* 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)