Lines Matching refs:bundle
33 struct rxrpc_conn_bundle *bundle; in rxrpc_alloc_bundle() local
37 bundle = kzalloc(sizeof(struct rxrpc_conn_bundle), gfp); in rxrpc_alloc_bundle()
38 if (bundle) { in rxrpc_alloc_bundle()
39 INIT_LIST_HEAD(&bundle->unused_conns); in rxrpc_alloc_bundle()
40 INIT_LIST_HEAD(&bundle->avail_conns); in rxrpc_alloc_bundle()
41 INIT_LIST_HEAD(&bundle->busy_conns); in rxrpc_alloc_bundle()
42 init_waitqueue_head(&bundle->chanwait); in rxrpc_alloc_bundle()
43 atomic_set(&bundle->usage, 1); in rxrpc_alloc_bundle()
46 _leave(" = %p", bundle); in rxrpc_alloc_bundle()
47 return bundle; in rxrpc_alloc_bundle()
55 int rxrpc_cmp_bundle(const struct rxrpc_conn_bundle *bundle, in rxrpc_cmp_bundle() argument
58 return (bundle->service_id - service_id) ?: in rxrpc_cmp_bundle()
59 ((unsigned long) bundle->key - (unsigned long) key); in rxrpc_cmp_bundle()
71 struct rxrpc_conn_bundle *bundle, *candidate; in rxrpc_get_bundle() local
77 if (rx->trans == trans && rx->bundle) { in rxrpc_get_bundle()
78 atomic_inc(&rx->bundle->usage); in rxrpc_get_bundle()
79 return rx->bundle; in rxrpc_get_bundle()
88 bundle = rb_entry(p, struct rxrpc_conn_bundle, node); in rxrpc_get_bundle()
90 if (rxrpc_cmp_bundle(bundle, key, service_id) < 0) in rxrpc_get_bundle()
92 else if (rxrpc_cmp_bundle(bundle, key, service_id) > 0) in rxrpc_get_bundle()
117 bundle = rb_entry(parent, struct rxrpc_conn_bundle, node); in rxrpc_get_bundle()
119 if (rxrpc_cmp_bundle(bundle, key, service_id) < 0) in rxrpc_get_bundle()
121 else if (rxrpc_cmp_bundle(bundle, key, service_id) > 0) in rxrpc_get_bundle()
128 bundle = candidate; in rxrpc_get_bundle()
131 rb_link_node(&bundle->node, parent, pp); in rxrpc_get_bundle()
132 rb_insert_color(&bundle->node, &trans->bundles); in rxrpc_get_bundle()
135 if (!rx->bundle && rx->sk.sk_state == RXRPC_CLIENT_CONNECTED) { in rxrpc_get_bundle()
136 atomic_inc(&bundle->usage); in rxrpc_get_bundle()
137 rx->bundle = bundle; in rxrpc_get_bundle()
139 _leave(" = %p [new]", bundle); in rxrpc_get_bundle()
140 return bundle; in rxrpc_get_bundle()
144 atomic_inc(&bundle->usage); in rxrpc_get_bundle()
147 if (!rx->bundle && rx->sk.sk_state == RXRPC_CLIENT_CONNECTED) { in rxrpc_get_bundle()
148 atomic_inc(&bundle->usage); in rxrpc_get_bundle()
149 rx->bundle = bundle; in rxrpc_get_bundle()
151 _leave(" = %p [extant %d]", bundle, atomic_read(&bundle->usage)); in rxrpc_get_bundle()
152 return bundle; in rxrpc_get_bundle()
156 atomic_inc(&bundle->usage); in rxrpc_get_bundle()
160 if (!rx->bundle && rx->sk.sk_state == RXRPC_CLIENT_CONNECTED) { in rxrpc_get_bundle()
161 atomic_inc(&bundle->usage); in rxrpc_get_bundle()
162 rx->bundle = bundle; in rxrpc_get_bundle()
164 _leave(" = %p [second %d]", bundle, atomic_read(&bundle->usage)); in rxrpc_get_bundle()
165 return bundle; in rxrpc_get_bundle()
172 struct rxrpc_conn_bundle *bundle) in rxrpc_put_bundle() argument
174 _enter("%p,%p{%d}",trans, bundle, atomic_read(&bundle->usage)); in rxrpc_put_bundle()
176 if (atomic_dec_and_lock(&bundle->usage, &trans->client_lock)) { in rxrpc_put_bundle()
178 rb_erase(&bundle->node, &trans->bundles); in rxrpc_put_bundle()
180 ASSERT(list_empty(&bundle->unused_conns)); in rxrpc_put_bundle()
181 ASSERT(list_empty(&bundle->avail_conns)); in rxrpc_put_bundle()
182 ASSERT(list_empty(&bundle->busy_conns)); in rxrpc_put_bundle()
183 ASSERTCMP(bundle->num_conns, ==, 0); in rxrpc_put_bundle()
184 key_put(bundle->key); in rxrpc_put_bundle()
185 kfree(bundle); in rxrpc_put_bundle()
353 conn->bundle = NULL; in rxrpc_connect_exclusive()
425 struct rxrpc_conn_bundle *bundle, in rxrpc_connect_call() argument
437 return rxrpc_connect_exclusive(rx, trans, bundle->service_id, in rxrpc_connect_call()
443 if (!list_empty(&bundle->avail_conns)) { in rxrpc_connect_call()
445 conn = list_entry(bundle->avail_conns.next, in rxrpc_connect_call()
450 bundle->num_conns--; in rxrpc_connect_call()
455 &bundle->busy_conns); in rxrpc_connect_call()
465 if (!list_empty(&bundle->unused_conns)) { in rxrpc_connect_call()
467 conn = list_entry(bundle->unused_conns.next, in rxrpc_connect_call()
472 bundle->num_conns--; in rxrpc_connect_call()
482 list_move(&conn->bundle_link, &bundle->avail_conns); in rxrpc_connect_call()
487 _debug("get new conn [%d]", bundle->num_conns); in rxrpc_connect_call()
494 if (bundle->num_conns >= 20) { in rxrpc_connect_call()
502 add_wait_queue(&bundle->chanwait, &myself); in rxrpc_connect_call()
505 if (bundle->num_conns < 20 || in rxrpc_connect_call()
506 !list_empty(&bundle->unused_conns) || in rxrpc_connect_call()
507 !list_empty(&bundle->avail_conns)) in rxrpc_connect_call()
513 remove_wait_queue(&bundle->chanwait, &myself); in rxrpc_connect_call()
528 candidate->bundle = bundle; in rxrpc_connect_call()
529 candidate->service_id = bundle->service_id; in rxrpc_connect_call()
537 candidate->key = key_get(bundle->key); in rxrpc_connect_call()
553 list_add(&candidate->bundle_link, &bundle->unused_conns); in rxrpc_connect_call()
554 bundle->num_conns++; in rxrpc_connect_call()
555 atomic_inc(&bundle->usage); in rxrpc_connect_call()
605 remove_wait_queue(&bundle->chanwait, &myself); in rxrpc_connect_call()
825 if (conn->bundle) in rxrpc_destroy_connection()
826 rxrpc_put_bundle(conn->trans, conn->bundle); in rxrpc_destroy_connection()
875 if (conn->bundle) { in rxrpc_connection_reaper()
877 conn->bundle->num_conns--; in rxrpc_connection_reaper()