1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Multipath support for RPC
4 *
5 * Copyright (c) 2015, 2016, Primary Data, Inc. All rights reserved.
6 *
7 * Trond Myklebust <trond.myklebust@primarydata.com>
8 *
9 */
10 #include <linux/atomic.h>
11 #include <linux/types.h>
12 #include <linux/kref.h>
13 #include <linux/list.h>
14 #include <linux/rcupdate.h>
15 #include <linux/rculist.h>
16 #include <linux/slab.h>
17 #include <linux/spinlock.h>
18 #include <linux/sunrpc/xprt.h>
19 #include <linux/sunrpc/addr.h>
20 #include <linux/sunrpc/xprtmultipath.h>
21
22 #include "sysfs.h"
23
24 typedef struct rpc_xprt *(*xprt_switch_find_xprt_t)(struct rpc_xprt_switch *xps,
25 const struct rpc_xprt *cur);
26
27 static const struct rpc_xprt_iter_ops rpc_xprt_iter_singular;
28 static const struct rpc_xprt_iter_ops rpc_xprt_iter_roundrobin;
29 static const struct rpc_xprt_iter_ops rpc_xprt_iter_listall;
30
xprt_switch_add_xprt_locked(struct rpc_xprt_switch * xps,struct rpc_xprt * xprt)31 static void xprt_switch_add_xprt_locked(struct rpc_xprt_switch *xps,
32 struct rpc_xprt *xprt)
33 {
34 if (unlikely(xprt_get(xprt) == NULL))
35 return;
36 list_add_tail_rcu(&xprt->xprt_switch, &xps->xps_xprt_list);
37 smp_wmb();
38 if (xps->xps_nxprts == 0)
39 xps->xps_net = xprt->xprt_net;
40 xps->xps_nxprts++;
41 xps->xps_nactive++;
42 }
43
44 /**
45 * rpc_xprt_switch_add_xprt - Add a new rpc_xprt to an rpc_xprt_switch
46 * @xps: pointer to struct rpc_xprt_switch
47 * @xprt: pointer to struct rpc_xprt
48 *
49 * Adds xprt to the end of the list of struct rpc_xprt in xps.
50 */
rpc_xprt_switch_add_xprt(struct rpc_xprt_switch * xps,struct rpc_xprt * xprt)51 void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
52 struct rpc_xprt *xprt)
53 {
54 if (xprt == NULL)
55 return;
56 spin_lock(&xps->xps_lock);
57 if (xps->xps_net == xprt->xprt_net || xps->xps_net == NULL)
58 xprt_switch_add_xprt_locked(xps, xprt);
59 spin_unlock(&xps->xps_lock);
60 rpc_sysfs_xprt_setup(xps, xprt, GFP_KERNEL);
61 }
62
xprt_switch_remove_xprt_locked(struct rpc_xprt_switch * xps,struct rpc_xprt * xprt)63 static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps,
64 struct rpc_xprt *xprt)
65 {
66 if (unlikely(xprt == NULL))
67 return;
68 if (!test_bit(XPRT_OFFLINE, &xprt->state))
69 xps->xps_nactive--;
70 xps->xps_nxprts--;
71 if (xps->xps_nxprts == 0)
72 xps->xps_net = NULL;
73 smp_wmb();
74 list_del_rcu(&xprt->xprt_switch);
75 }
76
77 /**
78 * rpc_xprt_switch_remove_xprt - Removes an rpc_xprt from a rpc_xprt_switch
79 * @xps: pointer to struct rpc_xprt_switch
80 * @xprt: pointer to struct rpc_xprt
81 *
82 * Removes xprt from the list of struct rpc_xprt in xps.
83 */
rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch * xps,struct rpc_xprt * xprt)84 void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
85 struct rpc_xprt *xprt)
86 {
87 spin_lock(&xps->xps_lock);
88 xprt_switch_remove_xprt_locked(xps, xprt);
89 spin_unlock(&xps->xps_lock);
90 xprt_put(xprt);
91 }
92
93 static DEFINE_IDA(rpc_xprtswitch_ids);
94
xprt_multipath_cleanup_ids(void)95 void xprt_multipath_cleanup_ids(void)
96 {
97 ida_destroy(&rpc_xprtswitch_ids);
98 }
99
xprt_switch_alloc_id(struct rpc_xprt_switch * xps,gfp_t gfp_flags)100 static int xprt_switch_alloc_id(struct rpc_xprt_switch *xps, gfp_t gfp_flags)
101 {
102 int id;
103
104 id = ida_simple_get(&rpc_xprtswitch_ids, 0, 0, gfp_flags);
105 if (id < 0)
106 return id;
107
108 xps->xps_id = id;
109 return 0;
110 }
111
xprt_switch_free_id(struct rpc_xprt_switch * xps)112 static void xprt_switch_free_id(struct rpc_xprt_switch *xps)
113 {
114 ida_simple_remove(&rpc_xprtswitch_ids, xps->xps_id);
115 }
116
117 /**
118 * xprt_switch_alloc - Allocate a new struct rpc_xprt_switch
119 * @xprt: pointer to struct rpc_xprt
120 * @gfp_flags: allocation flags
121 *
122 * On success, returns an initialised struct rpc_xprt_switch, containing
123 * the entry xprt. Returns NULL on failure.
124 */
xprt_switch_alloc(struct rpc_xprt * xprt,gfp_t gfp_flags)125 struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt,
126 gfp_t gfp_flags)
127 {
128 struct rpc_xprt_switch *xps;
129
130 xps = kmalloc(sizeof(*xps), gfp_flags);
131 if (xps != NULL) {
132 spin_lock_init(&xps->xps_lock);
133 kref_init(&xps->xps_kref);
134 xprt_switch_alloc_id(xps, gfp_flags);
135 xps->xps_nxprts = xps->xps_nactive = 0;
136 atomic_long_set(&xps->xps_queuelen, 0);
137 xps->xps_net = NULL;
138 INIT_LIST_HEAD(&xps->xps_xprt_list);
139 xps->xps_iter_ops = &rpc_xprt_iter_singular;
140 rpc_sysfs_xprt_switch_setup(xps, xprt, gfp_flags);
141 xprt_switch_add_xprt_locked(xps, xprt);
142 xps->xps_nunique_destaddr_xprts = 1;
143 rpc_sysfs_xprt_setup(xps, xprt, gfp_flags);
144 }
145
146 return xps;
147 }
148
xprt_switch_free_entries(struct rpc_xprt_switch * xps)149 static void xprt_switch_free_entries(struct rpc_xprt_switch *xps)
150 {
151 spin_lock(&xps->xps_lock);
152 while (!list_empty(&xps->xps_xprt_list)) {
153 struct rpc_xprt *xprt;
154
155 xprt = list_first_entry(&xps->xps_xprt_list,
156 struct rpc_xprt, xprt_switch);
157 xprt_switch_remove_xprt_locked(xps, xprt);
158 spin_unlock(&xps->xps_lock);
159 xprt_put(xprt);
160 spin_lock(&xps->xps_lock);
161 }
162 spin_unlock(&xps->xps_lock);
163 }
164
xprt_switch_free(struct kref * kref)165 static void xprt_switch_free(struct kref *kref)
166 {
167 struct rpc_xprt_switch *xps = container_of(kref,
168 struct rpc_xprt_switch, xps_kref);
169
170 xprt_switch_free_entries(xps);
171 rpc_sysfs_xprt_switch_destroy(xps);
172 xprt_switch_free_id(xps);
173 kfree_rcu(xps, xps_rcu);
174 }
175
176 /**
177 * xprt_switch_get - Return a reference to a rpc_xprt_switch
178 * @xps: pointer to struct rpc_xprt_switch
179 *
180 * Returns a reference to xps unless the refcount is already zero.
181 */
xprt_switch_get(struct rpc_xprt_switch * xps)182 struct rpc_xprt_switch *xprt_switch_get(struct rpc_xprt_switch *xps)
183 {
184 if (xps != NULL && kref_get_unless_zero(&xps->xps_kref))
185 return xps;
186 return NULL;
187 }
188
189 /**
190 * xprt_switch_put - Release a reference to a rpc_xprt_switch
191 * @xps: pointer to struct rpc_xprt_switch
192 *
193 * Release the reference to xps, and free it once the refcount is zero.
194 */
xprt_switch_put(struct rpc_xprt_switch * xps)195 void xprt_switch_put(struct rpc_xprt_switch *xps)
196 {
197 if (xps != NULL)
198 kref_put(&xps->xps_kref, xprt_switch_free);
199 }
200
201 /**
202 * rpc_xprt_switch_set_roundrobin - Set a round-robin policy on rpc_xprt_switch
203 * @xps: pointer to struct rpc_xprt_switch
204 *
205 * Sets a round-robin default policy for iterators acting on xps.
206 */
rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch * xps)207 void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps)
208 {
209 if (READ_ONCE(xps->xps_iter_ops) != &rpc_xprt_iter_roundrobin)
210 WRITE_ONCE(xps->xps_iter_ops, &rpc_xprt_iter_roundrobin);
211 }
212
213 static
xprt_iter_ops(const struct rpc_xprt_iter * xpi)214 const struct rpc_xprt_iter_ops *xprt_iter_ops(const struct rpc_xprt_iter *xpi)
215 {
216 if (xpi->xpi_ops != NULL)
217 return xpi->xpi_ops;
218 return rcu_dereference(xpi->xpi_xpswitch)->xps_iter_ops;
219 }
220
221 static
xprt_iter_no_rewind(struct rpc_xprt_iter * xpi)222 void xprt_iter_no_rewind(struct rpc_xprt_iter *xpi)
223 {
224 }
225
226 static
xprt_iter_default_rewind(struct rpc_xprt_iter * xpi)227 void xprt_iter_default_rewind(struct rpc_xprt_iter *xpi)
228 {
229 WRITE_ONCE(xpi->xpi_cursor, NULL);
230 }
231
232 static
xprt_is_active(const struct rpc_xprt * xprt)233 bool xprt_is_active(const struct rpc_xprt *xprt)
234 {
235 return (kref_read(&xprt->kref) != 0 &&
236 !test_bit(XPRT_OFFLINE, &xprt->state));
237 }
238
239 static
xprt_switch_find_first_entry(struct list_head * head)240 struct rpc_xprt *xprt_switch_find_first_entry(struct list_head *head)
241 {
242 struct rpc_xprt *pos;
243
244 list_for_each_entry_rcu(pos, head, xprt_switch) {
245 if (xprt_is_active(pos))
246 return pos;
247 }
248 return NULL;
249 }
250
251 static
xprt_iter_first_entry(struct rpc_xprt_iter * xpi)252 struct rpc_xprt *xprt_iter_first_entry(struct rpc_xprt_iter *xpi)
253 {
254 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
255
256 if (xps == NULL)
257 return NULL;
258 return xprt_switch_find_first_entry(&xps->xps_xprt_list);
259 }
260
261 static
xprt_switch_find_current_entry(struct list_head * head,const struct rpc_xprt * cur)262 struct rpc_xprt *xprt_switch_find_current_entry(struct list_head *head,
263 const struct rpc_xprt *cur)
264 {
265 struct rpc_xprt *pos;
266 bool found = false;
267
268 list_for_each_entry_rcu(pos, head, xprt_switch) {
269 if (cur == pos)
270 found = true;
271 if (found && xprt_is_active(pos))
272 return pos;
273 }
274 return NULL;
275 }
276
277 static
xprt_iter_current_entry(struct rpc_xprt_iter * xpi)278 struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi)
279 {
280 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
281 struct list_head *head;
282
283 if (xps == NULL)
284 return NULL;
285 head = &xps->xps_xprt_list;
286 if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2)
287 return xprt_switch_find_first_entry(head);
288 return xprt_switch_find_current_entry(head, xpi->xpi_cursor);
289 }
290
291 static
__rpc_xprt_switch_has_addr(struct rpc_xprt_switch * xps,const struct sockaddr * sap)292 bool __rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
293 const struct sockaddr *sap)
294 {
295 struct list_head *head;
296 struct rpc_xprt *pos;
297
298 if (xps == NULL || sap == NULL)
299 return false;
300
301 head = &xps->xps_xprt_list;
302 list_for_each_entry_rcu(pos, head, xprt_switch) {
303 if (rpc_cmp_addr_port(sap, (struct sockaddr *)&pos->addr)) {
304 pr_info("RPC: addr %s already in xprt switch\n",
305 pos->address_strings[RPC_DISPLAY_ADDR]);
306 return true;
307 }
308 }
309 return false;
310 }
311
rpc_xprt_switch_has_addr(struct rpc_xprt_switch * xps,const struct sockaddr * sap)312 bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
313 const struct sockaddr *sap)
314 {
315 bool res;
316
317 rcu_read_lock();
318 res = __rpc_xprt_switch_has_addr(xps, sap);
319 rcu_read_unlock();
320
321 return res;
322 }
323
324 static
xprt_switch_find_next_entry(struct list_head * head,const struct rpc_xprt * cur)325 struct rpc_xprt *xprt_switch_find_next_entry(struct list_head *head,
326 const struct rpc_xprt *cur)
327 {
328 struct rpc_xprt *pos, *prev = NULL;
329 bool found = false;
330
331 list_for_each_entry_rcu(pos, head, xprt_switch) {
332 if (cur == prev)
333 found = true;
334 if (found && xprt_is_active(pos))
335 return pos;
336 prev = pos;
337 }
338 return NULL;
339 }
340
341 static
xprt_switch_set_next_cursor(struct rpc_xprt_switch * xps,struct rpc_xprt ** cursor,xprt_switch_find_xprt_t find_next)342 struct rpc_xprt *xprt_switch_set_next_cursor(struct rpc_xprt_switch *xps,
343 struct rpc_xprt **cursor,
344 xprt_switch_find_xprt_t find_next)
345 {
346 struct rpc_xprt *pos, *old;
347
348 old = smp_load_acquire(cursor);
349 pos = find_next(xps, old);
350 smp_store_release(cursor, pos);
351 return pos;
352 }
353
354 static
xprt_iter_next_entry_multiple(struct rpc_xprt_iter * xpi,xprt_switch_find_xprt_t find_next)355 struct rpc_xprt *xprt_iter_next_entry_multiple(struct rpc_xprt_iter *xpi,
356 xprt_switch_find_xprt_t find_next)
357 {
358 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
359
360 if (xps == NULL)
361 return NULL;
362 return xprt_switch_set_next_cursor(xps, &xpi->xpi_cursor, find_next);
363 }
364
365 static
__xprt_switch_find_next_entry_roundrobin(struct list_head * head,const struct rpc_xprt * cur)366 struct rpc_xprt *__xprt_switch_find_next_entry_roundrobin(struct list_head *head,
367 const struct rpc_xprt *cur)
368 {
369 struct rpc_xprt *ret;
370
371 ret = xprt_switch_find_next_entry(head, cur);
372 if (ret != NULL)
373 return ret;
374 return xprt_switch_find_first_entry(head);
375 }
376
377 static
xprt_switch_find_next_entry_roundrobin(struct rpc_xprt_switch * xps,const struct rpc_xprt * cur)378 struct rpc_xprt *xprt_switch_find_next_entry_roundrobin(struct rpc_xprt_switch *xps,
379 const struct rpc_xprt *cur)
380 {
381 struct list_head *head = &xps->xps_xprt_list;
382 struct rpc_xprt *xprt;
383 unsigned int nactive;
384
385 for (;;) {
386 unsigned long xprt_queuelen, xps_queuelen;
387
388 xprt = __xprt_switch_find_next_entry_roundrobin(head, cur);
389 if (!xprt)
390 break;
391 xprt_queuelen = atomic_long_read(&xprt->queuelen);
392 xps_queuelen = atomic_long_read(&xps->xps_queuelen);
393 nactive = READ_ONCE(xps->xps_nactive);
394 /* Exit loop if xprt_queuelen <= average queue length */
395 if (xprt_queuelen * nactive <= xps_queuelen)
396 break;
397 cur = xprt;
398 }
399 return xprt;
400 }
401
402 static
xprt_iter_next_entry_roundrobin(struct rpc_xprt_iter * xpi)403 struct rpc_xprt *xprt_iter_next_entry_roundrobin(struct rpc_xprt_iter *xpi)
404 {
405 return xprt_iter_next_entry_multiple(xpi,
406 xprt_switch_find_next_entry_roundrobin);
407 }
408
409 static
xprt_switch_find_next_entry_all(struct rpc_xprt_switch * xps,const struct rpc_xprt * cur)410 struct rpc_xprt *xprt_switch_find_next_entry_all(struct rpc_xprt_switch *xps,
411 const struct rpc_xprt *cur)
412 {
413 return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur);
414 }
415
416 static
xprt_iter_next_entry_all(struct rpc_xprt_iter * xpi)417 struct rpc_xprt *xprt_iter_next_entry_all(struct rpc_xprt_iter *xpi)
418 {
419 return xprt_iter_next_entry_multiple(xpi,
420 xprt_switch_find_next_entry_all);
421 }
422
423 /*
424 * xprt_iter_rewind - Resets the xprt iterator
425 * @xpi: pointer to rpc_xprt_iter
426 *
427 * Resets xpi to ensure that it points to the first entry in the list
428 * of transports.
429 */
430 static
xprt_iter_rewind(struct rpc_xprt_iter * xpi)431 void xprt_iter_rewind(struct rpc_xprt_iter *xpi)
432 {
433 rcu_read_lock();
434 xprt_iter_ops(xpi)->xpi_rewind(xpi);
435 rcu_read_unlock();
436 }
437
__xprt_iter_init(struct rpc_xprt_iter * xpi,struct rpc_xprt_switch * xps,const struct rpc_xprt_iter_ops * ops)438 static void __xprt_iter_init(struct rpc_xprt_iter *xpi,
439 struct rpc_xprt_switch *xps,
440 const struct rpc_xprt_iter_ops *ops)
441 {
442 rcu_assign_pointer(xpi->xpi_xpswitch, xprt_switch_get(xps));
443 xpi->xpi_cursor = NULL;
444 xpi->xpi_ops = ops;
445 }
446
447 /**
448 * xprt_iter_init - Initialise an xprt iterator
449 * @xpi: pointer to rpc_xprt_iter
450 * @xps: pointer to rpc_xprt_switch
451 *
452 * Initialises the iterator to use the default iterator ops
453 * as set in xps. This function is mainly intended for internal
454 * use in the rpc_client.
455 */
xprt_iter_init(struct rpc_xprt_iter * xpi,struct rpc_xprt_switch * xps)456 void xprt_iter_init(struct rpc_xprt_iter *xpi,
457 struct rpc_xprt_switch *xps)
458 {
459 __xprt_iter_init(xpi, xps, NULL);
460 }
461
462 /**
463 * xprt_iter_init_listall - Initialise an xprt iterator
464 * @xpi: pointer to rpc_xprt_iter
465 * @xps: pointer to rpc_xprt_switch
466 *
467 * Initialises the iterator to iterate once through the entire list
468 * of entries in xps.
469 */
xprt_iter_init_listall(struct rpc_xprt_iter * xpi,struct rpc_xprt_switch * xps)470 void xprt_iter_init_listall(struct rpc_xprt_iter *xpi,
471 struct rpc_xprt_switch *xps)
472 {
473 __xprt_iter_init(xpi, xps, &rpc_xprt_iter_listall);
474 }
475
476 /**
477 * xprt_iter_xchg_switch - Atomically swap out the rpc_xprt_switch
478 * @xpi: pointer to rpc_xprt_iter
479 * @newswitch: pointer to a new rpc_xprt_switch or NULL
480 *
481 * Swaps out the existing xpi->xpi_xpswitch with a new value.
482 */
xprt_iter_xchg_switch(struct rpc_xprt_iter * xpi,struct rpc_xprt_switch * newswitch)483 struct rpc_xprt_switch *xprt_iter_xchg_switch(struct rpc_xprt_iter *xpi,
484 struct rpc_xprt_switch *newswitch)
485 {
486 struct rpc_xprt_switch __rcu *oldswitch;
487
488 /* Atomically swap out the old xpswitch */
489 oldswitch = xchg(&xpi->xpi_xpswitch, RCU_INITIALIZER(newswitch));
490 if (newswitch != NULL)
491 xprt_iter_rewind(xpi);
492 return rcu_dereference_protected(oldswitch, true);
493 }
494
495 /**
496 * xprt_iter_destroy - Destroys the xprt iterator
497 * @xpi: pointer to rpc_xprt_iter
498 */
xprt_iter_destroy(struct rpc_xprt_iter * xpi)499 void xprt_iter_destroy(struct rpc_xprt_iter *xpi)
500 {
501 xprt_switch_put(xprt_iter_xchg_switch(xpi, NULL));
502 }
503
504 /**
505 * xprt_iter_xprt - Returns the rpc_xprt pointed to by the cursor
506 * @xpi: pointer to rpc_xprt_iter
507 *
508 * Returns a pointer to the struct rpc_xprt that is currently
509 * pointed to by the cursor.
510 * Caller must be holding rcu_read_lock().
511 */
xprt_iter_xprt(struct rpc_xprt_iter * xpi)512 struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi)
513 {
514 WARN_ON_ONCE(!rcu_read_lock_held());
515 return xprt_iter_ops(xpi)->xpi_xprt(xpi);
516 }
517
518 static
xprt_iter_get_helper(struct rpc_xprt_iter * xpi,struct rpc_xprt * (* fn)(struct rpc_xprt_iter *))519 struct rpc_xprt *xprt_iter_get_helper(struct rpc_xprt_iter *xpi,
520 struct rpc_xprt *(*fn)(struct rpc_xprt_iter *))
521 {
522 struct rpc_xprt *ret;
523
524 do {
525 ret = fn(xpi);
526 if (ret == NULL)
527 break;
528 ret = xprt_get(ret);
529 } while (ret == NULL);
530 return ret;
531 }
532
533 /**
534 * xprt_iter_get_xprt - Returns the rpc_xprt pointed to by the cursor
535 * @xpi: pointer to rpc_xprt_iter
536 *
537 * Returns a reference to the struct rpc_xprt that is currently
538 * pointed to by the cursor.
539 */
xprt_iter_get_xprt(struct rpc_xprt_iter * xpi)540 struct rpc_xprt *xprt_iter_get_xprt(struct rpc_xprt_iter *xpi)
541 {
542 struct rpc_xprt *xprt;
543
544 rcu_read_lock();
545 xprt = xprt_iter_get_helper(xpi, xprt_iter_ops(xpi)->xpi_xprt);
546 rcu_read_unlock();
547 return xprt;
548 }
549
550 /**
551 * xprt_iter_get_next - Returns the next rpc_xprt following the cursor
552 * @xpi: pointer to rpc_xprt_iter
553 *
554 * Returns a reference to the struct rpc_xprt that immediately follows the
555 * entry pointed to by the cursor.
556 */
xprt_iter_get_next(struct rpc_xprt_iter * xpi)557 struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi)
558 {
559 struct rpc_xprt *xprt;
560
561 rcu_read_lock();
562 xprt = xprt_iter_get_helper(xpi, xprt_iter_ops(xpi)->xpi_next);
563 rcu_read_unlock();
564 return xprt;
565 }
566
567 /* Policy for always returning the first entry in the rpc_xprt_switch */
568 static
569 const struct rpc_xprt_iter_ops rpc_xprt_iter_singular = {
570 .xpi_rewind = xprt_iter_no_rewind,
571 .xpi_xprt = xprt_iter_first_entry,
572 .xpi_next = xprt_iter_first_entry,
573 };
574
575 /* Policy for round-robin iteration of entries in the rpc_xprt_switch */
576 static
577 const struct rpc_xprt_iter_ops rpc_xprt_iter_roundrobin = {
578 .xpi_rewind = xprt_iter_default_rewind,
579 .xpi_xprt = xprt_iter_current_entry,
580 .xpi_next = xprt_iter_next_entry_roundrobin,
581 };
582
583 /* Policy for once-through iteration of entries in the rpc_xprt_switch */
584 static
585 const struct rpc_xprt_iter_ops rpc_xprt_iter_listall = {
586 .xpi_rewind = xprt_iter_default_rewind,
587 .xpi_xprt = xprt_iter_current_entry,
588 .xpi_next = xprt_iter_next_entry_all,
589 };
590