aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-22 16:16:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-22 16:16:21 -0400
commit01cde1538e1dff4254e340f606177a870131a01f (patch)
tree474c049c444e885ff83e808c36a94cceab5bf8a3 /include/linux/sunrpc
parent243d50678583100855862bc084b8b307eea67f68 (diff)
parentf35592a97460f57d1089fd674176e9f34ba311f2 (diff)
Merge tag 'nfs-for-4.6-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client updates from Trond Myklebust: "Highlights include: Features: - Add support for multiple NFSv4.1 callbacks in flight - Initial patchset for RPC multipath support - Adapt RPC/RDMA to use the new completion queue API Bugfixes and cleanups: - nfs4: nfs4_ff_layout_prepare_ds should return NULL if connection failed - Cleanups to remove nfs_inode_dio_wait and nfs4_file_fsync - Fix RPC/RDMA credit accounting - Properly handle RDMA_ERROR replies - xprtrdma: Do not wait if ib_post_send() fails - xprtrdma: Segment head and tail XDR buffers on page boundaries - xprtrdma cleanups for dprintk, physical_op_map and unused macros" * tag 'nfs-for-4.6-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (35 commits) nfs/blocklayout: make sure making a aligned read request nfs4: nfs4_ff_layout_prepare_ds should return NULL if connection failed nfs: remove nfs_inode_dio_wait nfs: remove nfs4_file_fsync xprtrdma: Use new CQ API for RPC-over-RDMA client send CQs xprtrdma: Use an anonymous union in struct rpcrdma_mw xprtrdma: Use new CQ API for RPC-over-RDMA client receive CQs xprtrdma: Serialize credit accounting again xprtrdma: Properly handle RDMA_ERROR replies rpcrdma: Add RPCRDMA_HDRLEN_ERR xprtrdma: Do not wait if ib_post_send() fails xprtrdma: Segment head and tail XDR buffers on page boundaries xprtrdma: Clean up dprintk format string containing a newline xprtrdma: Clean up physical_op_map() xprtrdma: Clean up unused RPCRDMA_INLINE_PAD_THRESH macro NFS add callback_ops to nfs4_proc_bind_conn_to_session_callback pnfs/NFSv4.1: Add multipath capabilities to pNFS flexfiles servers over NFSv3 SUNRPC: Allow addition of new transports to a struct rpc_clnt NFSv4.1: nfs4_proc_bind_conn_to_session must iterate over all connections SUNRPC: Make NFS swap work with multipath ...
Diffstat (limited to 'include/linux/sunrpc')
-rw-r--r--include/linux/sunrpc/clnt.h18
-rw-r--r--include/linux/sunrpc/rpc_rdma.h12
-rw-r--r--include/linux/sunrpc/sched.h32
-rw-r--r--include/linux/sunrpc/xprt.h22
-rw-r--r--include/linux/sunrpc/xprtmultipath.h69
-rw-r--r--include/linux/sunrpc/xprtrdma.h2
6 files changed, 120 insertions, 35 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 131032f15cc1..9a7ddbaf116e 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -25,6 +25,7 @@
25#include <asm/signal.h> 25#include <asm/signal.h>
26#include <linux/path.h> 26#include <linux/path.h>
27#include <net/ipv6.h> 27#include <net/ipv6.h>
28#include <linux/sunrpc/xprtmultipath.h>
28 29
29struct rpc_inode; 30struct rpc_inode;
30 31
@@ -67,6 +68,7 @@ struct rpc_clnt {
67#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 68#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
68 struct dentry *cl_debugfs; /* debugfs directory */ 69 struct dentry *cl_debugfs; /* debugfs directory */
69#endif 70#endif
71 struct rpc_xprt_iter cl_xpi;
70}; 72};
71 73
72/* 74/*
@@ -139,7 +141,6 @@ struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
139 struct rpc_xprt *xprt); 141 struct rpc_xprt *xprt);
140struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, 142struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
141 const struct rpc_program *, u32); 143 const struct rpc_program *, u32);
142void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
143struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); 144struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
144struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *, 145struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *,
145 rpc_authflavor_t); 146 rpc_authflavor_t);
@@ -181,6 +182,21 @@ size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
181const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); 182const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
182int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); 183int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t);
183 184
185int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt,
186 int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *),
187 void *data);
188
189int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt,
190 struct rpc_xprt_switch *xps,
191 struct rpc_xprt *xprt,
192 void *dummy);
193int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,
194 int (*setup)(struct rpc_clnt *,
195 struct rpc_xprt_switch *,
196 struct rpc_xprt *,
197 void *),
198 void *data);
199
184const char *rpc_proc_name(const struct rpc_task *task); 200const char *rpc_proc_name(const struct rpc_task *task);
185#endif /* __KERNEL__ */ 201#endif /* __KERNEL__ */
186#endif /* _LINUX_SUNRPC_CLNT_H */ 202#endif /* _LINUX_SUNRPC_CLNT_H */
diff --git a/include/linux/sunrpc/rpc_rdma.h b/include/linux/sunrpc/rpc_rdma.h
index f33c5a4d6fe4..3b1ff38f0c37 100644
--- a/include/linux/sunrpc/rpc_rdma.h
+++ b/include/linux/sunrpc/rpc_rdma.h
@@ -93,6 +93,12 @@ struct rpcrdma_msg {
93 __be32 rm_pempty[3]; /* 3 empty chunk lists */ 93 __be32 rm_pempty[3]; /* 3 empty chunk lists */
94 } rm_padded; 94 } rm_padded;
95 95
96 struct {
97 __be32 rm_err;
98 __be32 rm_vers_low;
99 __be32 rm_vers_high;
100 } rm_error;
101
96 __be32 rm_chunks[0]; /* read, write and reply chunks */ 102 __be32 rm_chunks[0]; /* read, write and reply chunks */
97 103
98 } rm_body; 104 } rm_body;
@@ -102,17 +108,13 @@ struct rpcrdma_msg {
102 * Smallest RPC/RDMA header: rm_xid through rm_type, then rm_nochunks 108 * Smallest RPC/RDMA header: rm_xid through rm_type, then rm_nochunks
103 */ 109 */
104#define RPCRDMA_HDRLEN_MIN (sizeof(__be32) * 7) 110#define RPCRDMA_HDRLEN_MIN (sizeof(__be32) * 7)
111#define RPCRDMA_HDRLEN_ERR (sizeof(__be32) * 5)
105 112
106enum rpcrdma_errcode { 113enum rpcrdma_errcode {
107 ERR_VERS = 1, 114 ERR_VERS = 1,
108 ERR_CHUNK = 2 115 ERR_CHUNK = 2
109}; 116};
110 117
111struct rpcrdma_err_vers {
112 uint32_t rdma_vers_low; /* Version range supported by peer */
113 uint32_t rdma_vers_high;
114};
115
116enum rpcrdma_proc { 118enum rpcrdma_proc {
117 RDMA_MSG = 0, /* An RPC call or reply msg */ 119 RDMA_MSG = 0, /* An RPC call or reply msg */
118 RDMA_NOMSG = 1, /* An RPC call or reply msg - separate body */ 120 RDMA_NOMSG = 1, /* An RPC call or reply msg - separate body */
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index d703f0ef37d8..05a1809c44d9 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -42,40 +42,43 @@ struct rpc_wait {
42 */ 42 */
43struct rpc_task { 43struct rpc_task {
44 atomic_t tk_count; /* Reference count */ 44 atomic_t tk_count; /* Reference count */
45 int tk_status; /* result of last operation */
45 struct list_head tk_task; /* global list of tasks */ 46 struct list_head tk_task; /* global list of tasks */
46 struct rpc_clnt * tk_client; /* RPC client */
47 struct rpc_rqst * tk_rqstp; /* RPC request */
48
49 /*
50 * RPC call state
51 */
52 struct rpc_message tk_msg; /* RPC call info */
53 47
54 /* 48 /*
55 * callback to be executed after waking up 49 * callback to be executed after waking up
56 * action next procedure for async tasks 50 * action next procedure for async tasks
57 * tk_ops caller callbacks
58 */ 51 */
59 void (*tk_callback)(struct rpc_task *); 52 void (*tk_callback)(struct rpc_task *);
60 void (*tk_action)(struct rpc_task *); 53 void (*tk_action)(struct rpc_task *);
61 const struct rpc_call_ops *tk_ops;
62 void * tk_calldata;
63 54
64 unsigned long tk_timeout; /* timeout for rpc_sleep() */ 55 unsigned long tk_timeout; /* timeout for rpc_sleep() */
65 unsigned long tk_runstate; /* Task run status */ 56 unsigned long tk_runstate; /* Task run status */
66 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could 57
67 * be any workqueue
68 */
69 struct rpc_wait_queue *tk_waitqueue; /* RPC wait queue we're on */ 58 struct rpc_wait_queue *tk_waitqueue; /* RPC wait queue we're on */
70 union { 59 union {
71 struct work_struct tk_work; /* Async task work queue */ 60 struct work_struct tk_work; /* Async task work queue */
72 struct rpc_wait tk_wait; /* RPC wait */ 61 struct rpc_wait tk_wait; /* RPC wait */
73 } u; 62 } u;
74 63
64 /*
65 * RPC call state
66 */
67 struct rpc_message tk_msg; /* RPC call info */
68 void * tk_calldata; /* Caller private data */
69 const struct rpc_call_ops *tk_ops; /* Caller callbacks */
70
71 struct rpc_clnt * tk_client; /* RPC client */
72 struct rpc_xprt * tk_xprt; /* Transport */
73
74 struct rpc_rqst * tk_rqstp; /* RPC request */
75
76 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could
77 * be any workqueue
78 */
75 ktime_t tk_start; /* RPC task init timestamp */ 79 ktime_t tk_start; /* RPC task init timestamp */
76 80
77 pid_t tk_owner; /* Process id for batching tasks */ 81 pid_t tk_owner; /* Process id for batching tasks */
78 int tk_status; /* result of last operation */
79 unsigned short tk_flags; /* misc flags */ 82 unsigned short tk_flags; /* misc flags */
80 unsigned short tk_timeouts; /* maj timeouts */ 83 unsigned short tk_timeouts; /* maj timeouts */
81 84
@@ -100,6 +103,7 @@ struct rpc_call_ops {
100struct rpc_task_setup { 103struct rpc_task_setup {
101 struct rpc_task *task; 104 struct rpc_task *task;
102 struct rpc_clnt *rpc_client; 105 struct rpc_clnt *rpc_client;
106 struct rpc_xprt *rpc_xprt;
103 const struct rpc_message *rpc_message; 107 const struct rpc_message *rpc_message;
104 const struct rpc_call_ops *callback_ops; 108 const struct rpc_call_ops *callback_ops;
105 void *callback_data; 109 void *callback_data;
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 69ef5b3ab038..fb0d212e0d3a 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -13,6 +13,7 @@
13#include <linux/socket.h> 13#include <linux/socket.h>
14#include <linux/in.h> 14#include <linux/in.h>
15#include <linux/ktime.h> 15#include <linux/ktime.h>
16#include <linux/kref.h>
16#include <linux/sunrpc/sched.h> 17#include <linux/sunrpc/sched.h>
17#include <linux/sunrpc/xdr.h> 18#include <linux/sunrpc/xdr.h>
18#include <linux/sunrpc/msg_prot.h> 19#include <linux/sunrpc/msg_prot.h>
@@ -166,7 +167,7 @@ enum xprt_transports {
166}; 167};
167 168
168struct rpc_xprt { 169struct rpc_xprt {
169 atomic_t count; /* Reference count */ 170 struct kref kref; /* Reference count */
170 struct rpc_xprt_ops * ops; /* transport methods */ 171 struct rpc_xprt_ops * ops; /* transport methods */
171 172
172 const struct rpc_timeout *timeout; /* timeout parms */ 173 const struct rpc_timeout *timeout; /* timeout parms */
@@ -197,6 +198,11 @@ struct rpc_xprt {
197 unsigned int bind_index; /* bind function index */ 198 unsigned int bind_index; /* bind function index */
198 199
199 /* 200 /*
201 * Multipath
202 */
203 struct list_head xprt_switch;
204
205 /*
200 * Connection of transports 206 * Connection of transports
201 */ 207 */
202 unsigned long bind_timeout, 208 unsigned long bind_timeout,
@@ -256,6 +262,7 @@ struct rpc_xprt {
256 struct dentry *debugfs; /* debugfs directory */ 262 struct dentry *debugfs; /* debugfs directory */
257 atomic_t inject_disconnect; 263 atomic_t inject_disconnect;
258#endif 264#endif
265 struct rcu_head rcu;
259}; 266};
260 267
261#if defined(CONFIG_SUNRPC_BACKCHANNEL) 268#if defined(CONFIG_SUNRPC_BACKCHANNEL)
@@ -318,24 +325,13 @@ int xprt_adjust_timeout(struct rpc_rqst *req);
318void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task); 325void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
319void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task); 326void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
320void xprt_release(struct rpc_task *task); 327void xprt_release(struct rpc_task *task);
328struct rpc_xprt * xprt_get(struct rpc_xprt *xprt);
321void xprt_put(struct rpc_xprt *xprt); 329void xprt_put(struct rpc_xprt *xprt);
322struct rpc_xprt * xprt_alloc(struct net *net, size_t size, 330struct rpc_xprt * xprt_alloc(struct net *net, size_t size,
323 unsigned int num_prealloc, 331 unsigned int num_prealloc,
324 unsigned int max_req); 332 unsigned int max_req);
325void xprt_free(struct rpc_xprt *); 333void xprt_free(struct rpc_xprt *);
326 334
327/**
328 * xprt_get - return a reference to an RPC transport.
329 * @xprt: pointer to the transport
330 *
331 */
332static inline struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
333{
334 if (atomic_inc_not_zero(&xprt->count))
335 return xprt;
336 return NULL;
337}
338
339static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) 335static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
340{ 336{
341 return p + xprt->tsh_size; 337 return p + xprt->tsh_size;
diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h
new file mode 100644
index 000000000000..5a9acffa41be
--- /dev/null
+++ b/include/linux/sunrpc/xprtmultipath.h
@@ -0,0 +1,69 @@
1/*
2 * RPC client multipathing definitions
3 *
4 * Copyright (c) 2015, 2016, Primary Data, Inc. All rights reserved.
5 *
6 * Trond Myklebust <trond.myklebust@primarydata.com>
7 */
8#ifndef _NET_SUNRPC_XPRTMULTIPATH_H
9#define _NET_SUNRPC_XPRTMULTIPATH_H
10
11struct rpc_xprt_iter_ops;
12struct rpc_xprt_switch {
13 spinlock_t xps_lock;
14 struct kref xps_kref;
15
16 unsigned int xps_nxprts;
17 struct list_head xps_xprt_list;
18
19 struct net * xps_net;
20
21 const struct rpc_xprt_iter_ops *xps_iter_ops;
22
23 struct rcu_head xps_rcu;
24};
25
26struct rpc_xprt_iter {
27 struct rpc_xprt_switch __rcu *xpi_xpswitch;
28 struct rpc_xprt * xpi_cursor;
29
30 const struct rpc_xprt_iter_ops *xpi_ops;
31};
32
33
34struct rpc_xprt_iter_ops {
35 void (*xpi_rewind)(struct rpc_xprt_iter *);
36 struct rpc_xprt *(*xpi_xprt)(struct rpc_xprt_iter *);
37 struct rpc_xprt *(*xpi_next)(struct rpc_xprt_iter *);
38};
39
40extern struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
41 gfp_t gfp_flags);
42
43extern struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps);
44extern void xprt_switch_put(struct rpc_xprt_switch *xps);
45
46extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps);
47
48extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
49 struct rpc_xprt *xprt);
50extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
51 struct rpc_xprt *xprt);
52
53extern void xprt_iter_init(struct rpc_xprt_iter *xpi,
54 struct rpc_xprt_switch *xps);
55
56extern void xprt_iter_init_listall(struct rpc_xprt_iter *xpi,
57 struct rpc_xprt_switch *xps);
58
59extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi);
60
61extern struct rpc_xprt_switch *xprt_iter_xchg_switch(
62 struct rpc_xprt_iter *xpi,
63 struct rpc_xprt_switch *newswitch);
64
65extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi);
66extern struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi);
67extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi);
68
69#endif
diff --git a/include/linux/sunrpc/xprtrdma.h b/include/linux/sunrpc/xprtrdma.h
index b7b279b54504..767190b01363 100644
--- a/include/linux/sunrpc/xprtrdma.h
+++ b/include/linux/sunrpc/xprtrdma.h
@@ -54,8 +54,6 @@
54 54
55#define RPCRDMA_DEF_INLINE (1024) /* default inline max */ 55#define RPCRDMA_DEF_INLINE (1024) /* default inline max */
56 56
57#define RPCRDMA_INLINE_PAD_THRESH (512)/* payload threshold to pad (bytes) */
58
59/* Memory registration strategies, by number. 57/* Memory registration strategies, by number.
60 * This is part of a kernel / user space API. Do not remove. */ 58 * This is part of a kernel / user space API. Do not remove. */
61enum rpcrdma_memreg { 59enum rpcrdma_memreg {