• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * RPC client multipathing definitions
4  *
5  * Copyright (c) 2015, 2016, Primary Data, Inc. All rights reserved.
6  *
7  * Trond Myklebust <trond.myklebust@primarydata.com>
8  */
9 #ifndef _NET_SUNRPC_XPRTMULTIPATH_H
10 #define _NET_SUNRPC_XPRTMULTIPATH_H
11 
12 struct rpc_xprt_iter_ops;
13 struct rpc_xprt_switch {
14 	spinlock_t		xps_lock;
15 	struct kref		xps_kref;
16 
17 	unsigned int		xps_nxprts;
18 	unsigned int		xps_nactive;
19 	atomic_long_t		xps_queuelen;
20 	struct list_head	xps_xprt_list;
21 
22 	struct net *		xps_net;
23 
24 	const struct rpc_xprt_iter_ops *xps_iter_ops;
25 
26 	struct rcu_head		xps_rcu;
27 };
28 
29 struct rpc_xprt_iter {
30 	struct rpc_xprt_switch __rcu *xpi_xpswitch;
31 	struct rpc_xprt *	xpi_cursor;
32 
33 	const struct rpc_xprt_iter_ops *xpi_ops;
34 };
35 
36 
37 struct rpc_xprt_iter_ops {
38 	void (*xpi_rewind)(struct rpc_xprt_iter *);
39 	struct rpc_xprt *(*xpi_xprt)(struct rpc_xprt_iter *);
40 	struct rpc_xprt *(*xpi_next)(struct rpc_xprt_iter *);
41 };
42 
43 extern struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
44 		gfp_t gfp_flags);
45 
46 extern struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps);
47 extern void xprt_switch_put(struct rpc_xprt_switch *xps);
48 
49 extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps);
50 
51 extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
52 		struct rpc_xprt *xprt);
53 extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
54 		struct rpc_xprt *xprt);
55 
56 extern void xprt_iter_init(struct rpc_xprt_iter *xpi,
57 		struct rpc_xprt_switch *xps);
58 
59 extern void xprt_iter_init_listall(struct rpc_xprt_iter *xpi,
60 		struct rpc_xprt_switch *xps);
61 
62 extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi);
63 
64 extern struct rpc_xprt_switch *xprt_iter_xchg_switch(
65 		struct rpc_xprt_iter *xpi,
66 		struct rpc_xprt_switch *newswitch);
67 
68 extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi);
69 extern struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi);
70 extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi);
71 
72 extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
73 		const struct sockaddr *sap);
74 #endif
75