xprtmultipath.h (2295B)
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); 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_destroy(struct rpc_xprt_iter *xpi); 67 68extern struct rpc_xprt_switch *xprt_iter_xchg_switch( 69 struct rpc_xprt_iter *xpi, 70 struct rpc_xprt_switch *newswitch); 71 72extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi); 73extern struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi); 74extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi); 75 76extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, 77 const struct sockaddr *sap); 78 79extern void xprt_multipath_cleanup_ids(void); 80 81#endif