1 /* SPDX-License-Identifier: GPL-2.0 */
3 * RPC client multipathing definitions
5 * Copyright (c) 2015, 2016, Primary Data, Inc. All rights reserved.
7 * Trond Myklebust <trond.myklebust@primarydata.com>
9 #ifndef _NET_SUNRPC_XPRTMULTIPATH_H
10 #define _NET_SUNRPC_XPRTMULTIPATH_H
12 struct rpc_xprt_iter_ops;
13 struct rpc_sysfs_xprt_switch;
14 struct rpc_xprt_switch {
19 unsigned int xps_nxprts;
20 unsigned int xps_nactive;
21 unsigned int xps_nunique_destaddr_xprts;
22 atomic_long_t xps_queuelen;
23 struct list_head xps_xprt_list;
27 const struct rpc_xprt_iter_ops *xps_iter_ops;
29 struct rpc_sysfs_xprt_switch *xps_sysfs;
30 struct rcu_head xps_rcu;
33 struct rpc_xprt_iter {
34 struct rpc_xprt_switch __rcu *xpi_xpswitch;
35 struct rpc_xprt * xpi_cursor;
37 const struct rpc_xprt_iter_ops *xpi_ops;
41 struct rpc_xprt_iter_ops {
42 void (*xpi_rewind)(struct rpc_xprt_iter *);
43 struct rpc_xprt *(*xpi_xprt)(struct rpc_xprt_iter *);
44 struct rpc_xprt *(*xpi_next)(struct rpc_xprt_iter *);
47 extern struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
50 extern struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps);
51 extern void xprt_switch_put(struct rpc_xprt_switch *xps);
53 extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps);
55 extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
56 struct rpc_xprt *xprt);
57 extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
58 struct rpc_xprt *xprt);
60 extern void xprt_iter_init(struct rpc_xprt_iter *xpi,
61 struct rpc_xprt_switch *xps);
63 extern void xprt_iter_init_listall(struct rpc_xprt_iter *xpi,
64 struct rpc_xprt_switch *xps);
66 extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi);
68 extern struct rpc_xprt_switch *xprt_iter_xchg_switch(
69 struct rpc_xprt_iter *xpi,
70 struct rpc_xprt_switch *newswitch);
72 extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi);
73 extern struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi);
74 extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi);
76 extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
77 const struct sockaddr *sap);
79 extern void xprt_multipath_cleanup_ids(void);