Loading...
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
12struct rpc_xprt_iter_ops;
13struct 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
29struct 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
37struct 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
43extern struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
44 gfp_t gfp_flags);
45
46extern struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps);
47extern void xprt_switch_put(struct rpc_xprt_switch *xps);
48
49extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps);
50
51extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
52 struct rpc_xprt *xprt);
53extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
54 struct rpc_xprt *xprt);
55
56extern void xprt_iter_init(struct rpc_xprt_iter *xpi,
57 struct rpc_xprt_switch *xps);
58
59extern void xprt_iter_init_listall(struct rpc_xprt_iter *xpi,
60 struct rpc_xprt_switch *xps);
61
62extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi);
63
64extern struct rpc_xprt_switch *xprt_iter_xchg_switch(
65 struct rpc_xprt_iter *xpi,
66 struct rpc_xprt_switch *newswitch);
67
68extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi);
69extern struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi);
70extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi);
71
72extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
73 const struct sockaddr *sap);
74#endif
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
12struct rpc_xprt_iter_ops;
13struct rpc_sysfs_xprt_switch;
14struct rpc_xprt_switch {
15 spinlock_t xps_lock;
16 struct kref xps_kref;
17
18 unsigned int xps_id;
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;
24
25 struct net * xps_net;
26
27 const struct rpc_xprt_iter_ops *xps_iter_ops;
28
29 struct rpc_sysfs_xprt_switch *xps_sysfs;
30 struct rcu_head xps_rcu;
31};
32
33struct rpc_xprt_iter {
34 struct rpc_xprt_switch __rcu *xpi_xpswitch;
35 struct rpc_xprt * xpi_cursor;
36
37 const struct rpc_xprt_iter_ops *xpi_ops;
38};
39
40
41struct 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 *);
45};
46
47extern struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
48 gfp_t gfp_flags);
49
50extern struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps);
51extern void xprt_switch_put(struct rpc_xprt_switch *xps);
52
53extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps);
54
55extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
56 struct rpc_xprt *xprt);
57extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
58 struct rpc_xprt *xprt, bool offline);
59
60extern void xprt_iter_init(struct rpc_xprt_iter *xpi,
61 struct rpc_xprt_switch *xps);
62
63extern void xprt_iter_init_listall(struct rpc_xprt_iter *xpi,
64 struct rpc_xprt_switch *xps);
65
66extern void xprt_iter_init_listoffline(struct rpc_xprt_iter *xpi,
67 struct rpc_xprt_switch *xps);
68
69extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi);
70
71extern void xprt_iter_rewind(struct rpc_xprt_iter *xpi);
72
73extern struct rpc_xprt_switch *xprt_iter_xchg_switch(
74 struct rpc_xprt_iter *xpi,
75 struct rpc_xprt_switch *newswitch);
76
77extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi);
78extern struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi);
79extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi);
80
81extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
82 const struct sockaddr *sap);
83
84extern void xprt_multipath_cleanup_ids(void);
85
86#endif