Lines Matching refs:xps

22 typedef struct rpc_xprt *(*xprt_switch_find_xprt_t)(struct rpc_xprt_switch *xps,
29 static void xprt_switch_add_xprt_locked(struct rpc_xprt_switch *xps, in xprt_switch_add_xprt_locked() argument
34 list_add_tail_rcu(&xprt->xprt_switch, &xps->xps_xprt_list); in xprt_switch_add_xprt_locked()
36 if (xps->xps_nxprts == 0) in xprt_switch_add_xprt_locked()
37 xps->xps_net = xprt->xprt_net; in xprt_switch_add_xprt_locked()
38 xps->xps_nxprts++; in xprt_switch_add_xprt_locked()
39 xps->xps_nactive++; in xprt_switch_add_xprt_locked()
49 void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps, in rpc_xprt_switch_add_xprt() argument
54 spin_lock(&xps->xps_lock); in rpc_xprt_switch_add_xprt()
55 if (xps->xps_net == xprt->xprt_net || xps->xps_net == NULL) in rpc_xprt_switch_add_xprt()
56 xprt_switch_add_xprt_locked(xps, xprt); in rpc_xprt_switch_add_xprt()
57 spin_unlock(&xps->xps_lock); in rpc_xprt_switch_add_xprt()
60 static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, in xprt_switch_remove_xprt_locked() argument
65 xps->xps_nactive--; in xprt_switch_remove_xprt_locked()
66 xps->xps_nxprts--; in xprt_switch_remove_xprt_locked()
67 if (xps->xps_nxprts == 0) in xprt_switch_remove_xprt_locked()
68 xps->xps_net = NULL; in xprt_switch_remove_xprt_locked()
80 void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, in rpc_xprt_switch_remove_xprt() argument
83 spin_lock(&xps->xps_lock); in rpc_xprt_switch_remove_xprt()
84 xprt_switch_remove_xprt_locked(xps, xprt); in rpc_xprt_switch_remove_xprt()
85 spin_unlock(&xps->xps_lock); in rpc_xprt_switch_remove_xprt()
100 struct rpc_xprt_switch *xps; in xprt_switch_alloc() local
102 xps = kmalloc(sizeof(*xps), gfp_flags); in xprt_switch_alloc()
103 if (xps != NULL) { in xprt_switch_alloc()
104 spin_lock_init(&xps->xps_lock); in xprt_switch_alloc()
105 kref_init(&xps->xps_kref); in xprt_switch_alloc()
106 xps->xps_nxprts = xps->xps_nactive = 0; in xprt_switch_alloc()
107 atomic_long_set(&xps->xps_queuelen, 0); in xprt_switch_alloc()
108 xps->xps_net = NULL; in xprt_switch_alloc()
109 INIT_LIST_HEAD(&xps->xps_xprt_list); in xprt_switch_alloc()
110 xps->xps_iter_ops = &rpc_xprt_iter_singular; in xprt_switch_alloc()
111 xprt_switch_add_xprt_locked(xps, xprt); in xprt_switch_alloc()
114 return xps; in xprt_switch_alloc()
117 static void xprt_switch_free_entries(struct rpc_xprt_switch *xps) in xprt_switch_free_entries() argument
119 spin_lock(&xps->xps_lock); in xprt_switch_free_entries()
120 while (!list_empty(&xps->xps_xprt_list)) { in xprt_switch_free_entries()
123 xprt = list_first_entry(&xps->xps_xprt_list, in xprt_switch_free_entries()
125 xprt_switch_remove_xprt_locked(xps, xprt); in xprt_switch_free_entries()
126 spin_unlock(&xps->xps_lock); in xprt_switch_free_entries()
128 spin_lock(&xps->xps_lock); in xprt_switch_free_entries()
130 spin_unlock(&xps->xps_lock); in xprt_switch_free_entries()
135 struct rpc_xprt_switch *xps = container_of(kref, in xprt_switch_free() local
138 xprt_switch_free_entries(xps); in xprt_switch_free()
139 kfree_rcu(xps, xps_rcu); in xprt_switch_free()
148 struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps) in xprt_switch_get() argument
150 if (xps != NULL && kref_get_unless_zero(&xps->xps_kref)) in xprt_switch_get()
151 return xps; in xprt_switch_get()
161 void xprt_switch_put(struct rpc_xprt_switch *xps) in xprt_switch_put() argument
163 if (xps != NULL) in xprt_switch_put()
164 kref_put(&xps->xps_kref, xprt_switch_free); in xprt_switch_put()
173 void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps) in rpc_xprt_switch_set_roundrobin() argument
175 if (READ_ONCE(xps->xps_iter_ops) != &rpc_xprt_iter_roundrobin) in rpc_xprt_switch_set_roundrobin()
176 WRITE_ONCE(xps->xps_iter_ops, &rpc_xprt_iter_roundrobin); in rpc_xprt_switch_set_roundrobin()
219 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_first_entry() local
221 if (xps == NULL) in xprt_iter_first_entry()
223 return xprt_switch_find_first_entry(&xps->xps_xprt_list); in xprt_iter_first_entry()
245 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_current_entry() local
248 if (xps == NULL) in xprt_iter_current_entry()
250 head = &xps->xps_xprt_list; in xprt_iter_current_entry()
251 if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2) in xprt_iter_current_entry()
256 bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, in rpc_xprt_switch_has_addr() argument
262 if (xps == NULL || sap == NULL) in rpc_xprt_switch_has_addr()
265 head = &xps->xps_xprt_list; in rpc_xprt_switch_has_addr()
294 struct rpc_xprt *xprt_switch_set_next_cursor(struct rpc_xprt_switch *xps, in xprt_switch_set_next_cursor() argument
301 pos = find_next(xps, old); in xprt_switch_set_next_cursor()
310 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_next_entry_multiple() local
312 if (xps == NULL) in xprt_iter_next_entry_multiple()
314 return xprt_switch_set_next_cursor(xps, &xpi->xpi_cursor, find_next); in xprt_iter_next_entry_multiple()
330 struct rpc_xprt *xprt_switch_find_next_entry_roundrobin(struct rpc_xprt_switch *xps, in xprt_switch_find_next_entry_roundrobin() argument
333 struct list_head *head = &xps->xps_xprt_list; in xprt_switch_find_next_entry_roundrobin()
344 xps_queuelen = atomic_long_read(&xps->xps_queuelen); in xprt_switch_find_next_entry_roundrobin()
345 nactive = READ_ONCE(xps->xps_nactive); in xprt_switch_find_next_entry_roundrobin()
362 struct rpc_xprt *xprt_switch_find_next_entry_all(struct rpc_xprt_switch *xps, in xprt_switch_find_next_entry_all() argument
365 return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur); in xprt_switch_find_next_entry_all()
391 struct rpc_xprt_switch *xps, in __xprt_iter_init() argument
394 rcu_assign_pointer(xpi->xpi_xpswitch, xprt_switch_get(xps)); in __xprt_iter_init()
409 struct rpc_xprt_switch *xps) in xprt_iter_init() argument
411 __xprt_iter_init(xpi, xps, NULL); in xprt_iter_init()
423 struct rpc_xprt_switch *xps) in xprt_iter_init_listall() argument
425 __xprt_iter_init(xpi, xps, &rpc_xprt_iter_listall); in xprt_iter_init_listall()