diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-01 17:00:56 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-02 15:36:38 -0500 |
commit | 2446ab6070861aba2dd9229463ffbc40016a9f33 (patch) | |
tree | 2e366c3236788936b9f4f58c0787ae01c265f4a4 /include/linux | |
parent | a3ca5651cb5eebe2e56e510bbf5cd60abc301c9f (diff) |
SUNRPC: Use RCU to dereference the rpc_clnt.cl_xprt field
A migration event will replace the rpc_xprt used by an rpc_clnt. To
ensure this can be done safely, all references to cl_xprt must now use
a form of rcu_dereference().
Special care is taken with rpc_peeraddr2str(), which returns a pointer
to memory whose lifetime is the same as the rpc_xprt.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[ cel: fix lockdep splats and layering violations ]
[ cel: forward ported to 3.4 ]
[ cel: remove rpc_max_reqs(), add rpc_net_ns() ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/sunrpc/clnt.h | 4 | ||||
-rw-r--r-- | include/linux/sunrpc/debug.h | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index a4c62e95c720..e3d12b4a0314 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
@@ -35,7 +35,7 @@ struct rpc_clnt { | |||
35 | struct list_head cl_clients; /* Global list of clients */ | 35 | struct list_head cl_clients; /* Global list of clients */ |
36 | struct list_head cl_tasks; /* List of tasks */ | 36 | struct list_head cl_tasks; /* List of tasks */ |
37 | spinlock_t cl_lock; /* spinlock */ | 37 | spinlock_t cl_lock; /* spinlock */ |
38 | struct rpc_xprt * cl_xprt; /* transport */ | 38 | struct rpc_xprt __rcu * cl_xprt; /* transport */ |
39 | struct rpc_procinfo * cl_procinfo; /* procedure info */ | 39 | struct rpc_procinfo * cl_procinfo; /* procedure info */ |
40 | u32 cl_prog, /* RPC program number */ | 40 | u32 cl_prog, /* RPC program number */ |
41 | cl_vers, /* RPC version number */ | 41 | cl_vers, /* RPC version number */ |
@@ -156,6 +156,8 @@ struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, | |||
156 | int rpc_restart_call_prepare(struct rpc_task *); | 156 | int rpc_restart_call_prepare(struct rpc_task *); |
157 | int rpc_restart_call(struct rpc_task *); | 157 | int rpc_restart_call(struct rpc_task *); |
158 | void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); | 158 | void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); |
159 | int rpc_protocol(struct rpc_clnt *); | ||
160 | struct net * rpc_net_ns(struct rpc_clnt *); | ||
159 | size_t rpc_max_payload(struct rpc_clnt *); | 161 | size_t rpc_max_payload(struct rpc_clnt *); |
160 | void rpc_force_rebind(struct rpc_clnt *); | 162 | void rpc_force_rebind(struct rpc_clnt *); |
161 | size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); | 163 | size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); |
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h index b506936f4ce6..6cb2517bcf75 100644 --- a/include/linux/sunrpc/debug.h +++ b/include/linux/sunrpc/debug.h | |||
@@ -50,19 +50,32 @@ extern unsigned int nlm_debug; | |||
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #define dprintk(args...) dfprintk(FACILITY, ## args) | 52 | #define dprintk(args...) dfprintk(FACILITY, ## args) |
53 | #define dprintk_rcu(args...) dfprintk_rcu(FACILITY, ## args) | ||
53 | 54 | ||
54 | #undef ifdebug | 55 | #undef ifdebug |
55 | #ifdef RPC_DEBUG | 56 | #ifdef RPC_DEBUG |
56 | # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) | 57 | # define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) |
58 | |||
57 | # define dfprintk(fac, args...) \ | 59 | # define dfprintk(fac, args...) \ |
58 | do { \ | 60 | do { \ |
59 | ifdebug(fac) \ | 61 | ifdebug(fac) \ |
60 | printk(KERN_DEFAULT args); \ | 62 | printk(KERN_DEFAULT args); \ |
61 | } while (0) | 63 | } while (0) |
64 | |||
65 | # define dfprintk_rcu(fac, args...) \ | ||
66 | do { \ | ||
67 | ifdebug(fac) { \ | ||
68 | rcu_read_lock(); \ | ||
69 | printk(KERN_DEFAULT args); \ | ||
70 | rcu_read_unlock(); \ | ||
71 | } \ | ||
72 | } while (0) | ||
73 | |||
62 | # define RPC_IFDEBUG(x) x | 74 | # define RPC_IFDEBUG(x) x |
63 | #else | 75 | #else |
64 | # define ifdebug(fac) if (0) | 76 | # define ifdebug(fac) if (0) |
65 | # define dfprintk(fac, args...) do ; while (0) | 77 | # define dfprintk(fac, args...) do ; while (0) |
78 | # define dfprintk_rcu(fac, args...) do ; while (0) | ||
66 | # define RPC_IFDEBUG(x) | 79 | # define RPC_IFDEBUG(x) |
67 | #endif | 80 | #endif |
68 | 81 | ||