Lines Matching +full:zero +full:- +full:initialised

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()
96 * rpc_xprt_switch_get_main_xprt - Get the 'main' xprt for an xprt switch.
107 while (xprt && !xprt->main) { in rpc_xprt_switch_get_main_xprt()
131 xps->xps_id = id; in xprt_switch_alloc_id()
137 ida_free(&rpc_xprtswitch_ids, xps->xps_id); in xprt_switch_free_id()
141 * xprt_switch_alloc - Allocate a new struct rpc_xprt_switch
145 * On success, returns an initialised struct rpc_xprt_switch, containing
155 spin_lock_init(&xps->xps_lock); in xprt_switch_alloc()
156 kref_init(&xps->xps_kref); in xprt_switch_alloc()
158 xps->xps_nxprts = xps->xps_nactive = 0; in xprt_switch_alloc()
159 atomic_long_set(&xps->xps_queuelen, 0); in xprt_switch_alloc()
160 xps->xps_net = NULL; in xprt_switch_alloc()
161 INIT_LIST_HEAD(&xps->xps_xprt_list); in xprt_switch_alloc()
162 xps->xps_iter_ops = &rpc_xprt_iter_singular; in xprt_switch_alloc()
165 xps->xps_nunique_destaddr_xprts = 1; in xprt_switch_alloc()
174 spin_lock(&xps->xps_lock); in xprt_switch_free_entries()
175 while (!list_empty(&xps->xps_xprt_list)) { in xprt_switch_free_entries()
178 xprt = list_first_entry(&xps->xps_xprt_list, in xprt_switch_free_entries()
181 spin_unlock(&xps->xps_lock); in xprt_switch_free_entries()
183 spin_lock(&xps->xps_lock); in xprt_switch_free_entries()
185 spin_unlock(&xps->xps_lock); in xprt_switch_free_entries()
200 * xprt_switch_get - Return a reference to a rpc_xprt_switch
203 * Returns a reference to xps unless the refcount is already zero.
207 if (xps != NULL && kref_get_unless_zero(&xps->xps_kref)) in xprt_switch_get()
213 * xprt_switch_put - Release a reference to a rpc_xprt_switch
216 * Release the reference to xps, and free it once the refcount is zero.
221 kref_put(&xps->xps_kref, xprt_switch_free); in xprt_switch_put()
225 * rpc_xprt_switch_set_roundrobin - Set a round-robin policy on rpc_xprt_switch
228 * Sets a round-robin default policy for iterators acting on xps.
232 if (READ_ONCE(xps->xps_iter_ops) != &rpc_xprt_iter_roundrobin) in rpc_xprt_switch_set_roundrobin()
233 WRITE_ONCE(xps->xps_iter_ops, &rpc_xprt_iter_roundrobin); in rpc_xprt_switch_set_roundrobin()
239 if (xpi->xpi_ops != NULL) in xprt_iter_ops()
240 return xpi->xpi_ops; in xprt_iter_ops()
241 return rcu_dereference(xpi->xpi_xpswitch)->xps_iter_ops; in xprt_iter_ops()
252 WRITE_ONCE(xpi->xpi_cursor, NULL); in xprt_iter_default_rewind()
258 return (kref_read(&xprt->kref) != 0 && in xprt_is_active()
259 !test_bit(XPRT_OFFLINE, &xprt->state)); in xprt_is_active()
289 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_first_entry()
293 return xprt_switch_find_first_entry(&xps->xps_xprt_list); in xprt_iter_first_entry()
327 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in _xprt_iter_current_entry()
332 head = &xps->xps_xprt_list; in _xprt_iter_current_entry()
333 if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2) in _xprt_iter_current_entry()
335 return current_entry(head, xpi->xpi_cursor); in _xprt_iter_current_entry()
370 head = &xps->xps_xprt_list; in __rpc_xprt_switch_has_addr()
372 if (rpc_cmp_addr_port(sap, (struct sockaddr *)&pos->addr)) { in __rpc_xprt_switch_has_addr()
374 pos->address_strings[RPC_DISPLAY_ADDR]); in __rpc_xprt_switch_has_addr()
432 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); in xprt_iter_next_entry_multiple()
436 return xprt_switch_set_next_cursor(xps, &xpi->xpi_cursor, find_next); in xprt_iter_next_entry_multiple()
455 struct list_head *head = &xps->xps_xprt_list; in xprt_switch_find_next_entry_roundrobin()
465 xprt_queuelen = atomic_long_read(&xprt->queuelen); in xprt_switch_find_next_entry_roundrobin()
466 xps_queuelen = atomic_long_read(&xps->xps_queuelen); in xprt_switch_find_next_entry_roundrobin()
467 nactive = READ_ONCE(xps->xps_nactive); in xprt_switch_find_next_entry_roundrobin()
487 return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur, true); in xprt_switch_find_next_entry_all()
494 return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur, false); in xprt_switch_find_next_entry_offline()
512 * xprt_iter_rewind - Resets the xprt iterator
521 xprt_iter_ops(xpi)->xpi_rewind(xpi); in xprt_iter_rewind()
529 rcu_assign_pointer(xpi->xpi_xpswitch, xprt_switch_get(xps)); in __xprt_iter_init()
530 xpi->xpi_cursor = NULL; in __xprt_iter_init()
531 xpi->xpi_ops = ops; in __xprt_iter_init()
535 * xprt_iter_init - Initialise an xprt iterator
550 * xprt_iter_init_listall - Initialise an xprt iterator
570 * xprt_iter_xchg_switch - Atomically swap out the rpc_xprt_switch
574 * Swaps out the existing xpi->xpi_xpswitch with a new value.
582 oldswitch = xchg(&xpi->xpi_xpswitch, RCU_INITIALIZER(newswitch)); in xprt_iter_xchg_switch()
589 * xprt_iter_destroy - Destroys the xprt iterator
598 * xprt_iter_xprt - Returns the rpc_xprt pointed to by the cursor
608 return xprt_iter_ops(xpi)->xpi_xprt(xpi); in xprt_iter_xprt()
627 * xprt_iter_get_next - Returns the next rpc_xprt following the cursor
638 xprt = xprt_iter_get_helper(xpi, xprt_iter_ops(xpi)->xpi_next); in xprt_iter_get_next()
651 /* Policy for round-robin iteration of entries in the rpc_xprt_switch */
659 /* Policy for once-through iteration of entries in the rpc_xprt_switch */