Lines Matching +full:round +full:- +full:robin

1 // SPDX-License-Identifier: GPL-2.0
37 list_add_tail_rcu(&xprt->xprt_switch, &xps->xps_xprt_list); in xprt_switch_add_xprt_locked()
39 if (xps->xps_nxprts == 0) in xprt_switch_add_xprt_locked()
40 xps->xps_net = xprt->xprt_net; in xprt_switch_add_xprt_locked()
41 xps->xps_nxprts++; in xprt_switch_add_xprt_locked()
42 xps->xps_nactive++; in xprt_switch_add_xprt_locked()
46 * rpc_xprt_switch_add_xprt - Add a new rpc_xprt to an rpc_xprt_switch
57 spin_lock(&xps->xps_lock); in rpc_xprt_switch_add_xprt()
58 if (xps->xps_net == xprt->xprt_net || xps->xps_net == NULL) in rpc_xprt_switch_add_xprt()
60 spin_unlock(&xps->xps_lock); in rpc_xprt_switch_add_xprt()
69 if (!test_bit(XPRT_OFFLINE, &xprt->state) && offline) in xprt_switch_remove_xprt_locked()
70 xps->xps_nactive--; in xprt_switch_remove_xprt_locked()
71 xps->xps_nxprts--; in xprt_switch_remove_xprt_locked()
72 if (xps->xps_nxprts == 0) in xprt_switch_remove_xprt_locked()
73 xps->xps_net = NULL; in xprt_switch_remove_xprt_locked()
75 list_del_rcu(&xprt->xprt_switch); in xprt_switch_remove_xprt_locked()
79 * rpc_xprt_switch_remove_xprt - Removes an rpc_xprt from a rpc_xprt_switch
89 spin_lock(&xps->xps_lock); in rpc_xprt_switch_remove_xprt()
91 spin_unlock(&xps->xps_lock); in rpc_xprt_switch_remove_xprt()
110 xps->xps_id = id; in xprt_switch_alloc_id()
116 ida_free(&rpc_xprtswitch_ids, xps->xps_id); in xprt_switch_free_id()
120 * xprt_switch_alloc - Allocate a new struct rpc_xprt_switch
134 spin_lock_init(&xps->xps_lock); in xprt_switch_alloc()
135 kref_init(&xps->xps_kref); in xprt_switch_alloc()
137 xps->xps_nxprts = xps->xps_nactive = 0; in xprt_switch_alloc()
138 atomic_long_set(&xps->xps_queuelen, 0); in xprt_switch_alloc()
139 xps->xps_net = NULL; in xprt_switch_alloc()
140 INIT_LIST_HEAD(&xps->xps_xprt_list); in xprt_switch_alloc()
141 xps->xps_iter_ops = &rpc_xprt_iter_singular; in xprt_switch_alloc()
144 xps->xps_nunique_destaddr_xprts = 1; in xprt_switch_alloc()
153 spin_lock(&xps->xps_lock); in xprt_switch_free_entries()
154 while (!list_empty(&xps->xps_xprt_list)) { in xprt_switch_free_entries()
157 xprt = list_first_entry(&xps->xps_xprt_list, in xprt_switch_free_entries()
160 spin_unlock(&xps->xps_lock); in xprt_switch_free_entries()
162 spin_lock(&xps->xps_lock); in xprt_switch_free_entries()
164 spin_unlock(&xps->xps_lock); in xprt_switch_free_entries()
179 * xprt_switch_get - Return a reference to a rpc_xprt_switch
186 if (xps != NULL && kref_get_unless_zero(&xps->xps_kref)) in xprt_switch_get()
192 * xprt_switch_put - Release a reference to a rpc_xprt_switch
200 kref_put(&xps->xps_kref, xprt_switch_free); in xprt_switch_put()
204 * rpc_xprt_switch_set_roundrobin - Set a round-robin policy on rpc_xprt_switch
207 * Sets a round-robin default policy for iterators acting on xps.
211 if (READ_ONCE(xps->xps_iter_ops) != &rpc_xprt_iter_roundrobin) in rpc_xprt_switch_set_roundrobin()
212 WRITE_ONCE(xps->xps_iter_ops, &rpc_xprt_iter_roundrobin); in rpc_xprt_switch_set_roundrobin()
218 if (xpi->xpi_ops != NULL) in xprt_iter_ops()
219 return xpi->xpi_ops; in xprt_iter_ops()
220 return rcu_dereference(xpi->xpi_xpswitch)->xps_iter_ops; in xprt_iter_ops()
231 WRITE_ONCE(xpi->xpi_cursor, NULL); in xprt_iter_default_rewind()
237 return (kref_read(&xprt->kref) != 0 && in xprt_is_active()
238 !test_bit(XPRT_OFFLINE, &xprt->state)); in xprt_is_active()
268 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_first_entry()
272 return xprt_switch_find_first_entry(&xps->xps_xprt_list); in xprt_iter_first_entry()
306 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in _xprt_iter_current_entry()
311 head = &xps->xps_xprt_list; in _xprt_iter_current_entry()
312 if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2) in _xprt_iter_current_entry()
314 return current_entry(head, xpi->xpi_cursor); in _xprt_iter_current_entry()
348 head = &xps->xps_xprt_list; in rpc_xprt_switch_has_addr()
350 if (rpc_cmp_addr_port(sap, (struct sockaddr *)&pos->addr)) { in rpc_xprt_switch_has_addr()
352 pos->address_strings[RPC_DISPLAY_ADDR]); in rpc_xprt_switch_has_addr()
398 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_next_entry_multiple()
402 return xprt_switch_set_next_cursor(xps, &xpi->xpi_cursor, find_next); in xprt_iter_next_entry_multiple()
421 struct list_head *head = &xps->xps_xprt_list; in xprt_switch_find_next_entry_roundrobin()
431 xprt_queuelen = atomic_long_read(&xprt->queuelen); in xprt_switch_find_next_entry_roundrobin()
432 xps_queuelen = atomic_long_read(&xps->xps_queuelen); in xprt_switch_find_next_entry_roundrobin()
433 nactive = READ_ONCE(xps->xps_nactive); in xprt_switch_find_next_entry_roundrobin()
453 return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur, true); in xprt_switch_find_next_entry_all()
460 return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur, false); in xprt_switch_find_next_entry_offline()
478 * xprt_iter_rewind - Resets the xprt iterator
487 xprt_iter_ops(xpi)->xpi_rewind(xpi); in xprt_iter_rewind()
495 rcu_assign_pointer(xpi->xpi_xpswitch, xprt_switch_get(xps)); in __xprt_iter_init()
496 xpi->xpi_cursor = NULL; in __xprt_iter_init()
497 xpi->xpi_ops = ops; in __xprt_iter_init()
501 * xprt_iter_init - Initialise an xprt iterator
516 * xprt_iter_init_listall - Initialise an xprt iterator
536 * xprt_iter_xchg_switch - Atomically swap out the rpc_xprt_switch
540 * Swaps out the existing xpi->xpi_xpswitch with a new value.
548 oldswitch = xchg(&xpi->xpi_xpswitch, RCU_INITIALIZER(newswitch)); in xprt_iter_xchg_switch()
555 * xprt_iter_destroy - Destroys the xprt iterator
564 * xprt_iter_xprt - Returns the rpc_xprt pointed to by the cursor
574 return xprt_iter_ops(xpi)->xpi_xprt(xpi); in xprt_iter_xprt()
593 * xprt_iter_get_xprt - Returns the rpc_xprt pointed to by the cursor
604 xprt = xprt_iter_get_helper(xpi, xprt_iter_ops(xpi)->xpi_xprt); in xprt_iter_get_xprt()
610 * xprt_iter_get_next - Returns the next rpc_xprt following the cursor
621 xprt = xprt_iter_get_helper(xpi, xprt_iter_ops(xpi)->xpi_next); in xprt_iter_get_next()
634 /* Policy for round-robin iteration of entries in the rpc_xprt_switch */
642 /* Policy for once-through iteration of entries in the rpc_xprt_switch */