Lines Matching +full:cell +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-or-later
38 read_seqbegin_or_lock(&net->fs_addr_lock, &seq); in afs_find_server()
40 if (srx->transport.family == AF_INET6) { in afs_find_server()
41 const struct sockaddr_in6 *a = &srx->transport.sin6, *b; in afs_find_server()
42 hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) { in afs_find_server()
43 alist = rcu_dereference(server->addresses); in afs_find_server()
44 for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { in afs_find_server()
45 b = &alist->addrs[i].transport.sin6; in afs_find_server()
46 diff = ((u16 __force)a->sin6_port - in afs_find_server()
47 (u16 __force)b->sin6_port); in afs_find_server()
49 diff = memcmp(&a->sin6_addr, in afs_find_server()
50 &b->sin6_addr, in afs_find_server()
57 const struct sockaddr_in *a = &srx->transport.sin, *b; in afs_find_server()
58 hlist_for_each_entry_rcu(server, &net->fs_addresses4, addr4_link) { in afs_find_server()
59 alist = rcu_dereference(server->addresses); in afs_find_server()
60 for (i = 0; i < alist->nr_ipv4; i++) { in afs_find_server()
61 b = &alist->addrs[i].transport.sin; in afs_find_server()
62 diff = ((u16 __force)a->sin_port - in afs_find_server()
63 (u16 __force)b->sin_port); in afs_find_server()
65 diff = ((u32 __force)a->sin_addr.s_addr - in afs_find_server()
66 (u32 __force)b->sin_addr.s_addr); in afs_find_server()
78 } while (need_seqretry(&net->fs_addr_lock, seq)); in afs_find_server()
80 done_seqretry(&net->fs_addr_lock, seq); in afs_find_server()
106 read_seqbegin_or_lock(&net->fs_lock, &seq); in afs_find_server_by_uuid()
108 p = net->fs_servers.rb_node; in afs_find_server_by_uuid()
112 diff = memcmp(uuid, &server->uuid, sizeof(*uuid)); in afs_find_server_by_uuid()
114 p = p->rb_left; in afs_find_server_by_uuid()
116 p = p->rb_right; in afs_find_server_by_uuid()
124 } while (need_seqretry(&net->fs_lock, seq)); in afs_find_server_by_uuid()
126 done_seqretry(&net->fs_lock, seq); in afs_find_server_by_uuid()
137 static struct afs_server *afs_install_server(struct afs_cell *cell, in afs_install_server() argument
142 struct afs_net *net = cell->net; in afs_install_server()
148 write_seqlock(&net->fs_lock); in afs_install_server()
151 pp = &net->fs_servers.rb_node; in afs_install_server()
155 _debug("- consider %p", p); in afs_install_server()
157 diff = memcmp(&candidate->uuid, &server->uuid, sizeof(uuid_t)); in afs_install_server()
159 pp = &(*pp)->rb_left; in afs_install_server()
161 pp = &(*pp)->rb_right; in afs_install_server()
163 if (server->cell == cell) in afs_install_server()
171 server->uuid_next, in afs_install_server()
172 lockdep_is_held(&net->fs_lock.lock)); in afs_install_server()
177 rcu_assign_pointer(server->uuid_next, candidate); in afs_install_server()
178 candidate->uuid_prev = server; in afs_install_server()
185 rb_link_node(&server->uuid_rb, p, pp); in afs_install_server()
186 rb_insert_color(&server->uuid_rb, &net->fs_servers); in afs_install_server()
187 hlist_add_head_rcu(&server->proc_link, &net->fs_proc); in afs_install_server()
190 write_seqlock(&net->fs_addr_lock); in afs_install_server()
191 alist = rcu_dereference_protected(server->addresses, in afs_install_server()
192 lockdep_is_held(&net->fs_addr_lock.lock)); in afs_install_server()
195 * it in the IPv4 and/or IPv6 reverse-map lists. in afs_install_server()
202 if (alist->nr_ipv4 > 0) in afs_install_server()
203 hlist_add_head_rcu(&server->addr4_link, &net->fs_addresses4); in afs_install_server()
204 if (alist->nr_addrs > alist->nr_ipv4) in afs_install_server()
205 hlist_add_head_rcu(&server->addr6_link, &net->fs_addresses6); in afs_install_server()
207 write_sequnlock(&net->fs_addr_lock); in afs_install_server()
211 write_sequnlock(&net->fs_lock); in afs_install_server()
218 static struct afs_server *afs_alloc_server(struct afs_cell *cell, in afs_alloc_server() argument
223 struct afs_net *net = cell->net; in afs_alloc_server()
231 refcount_set(&server->ref, 1); in afs_alloc_server()
232 atomic_set(&server->active, 1); in afs_alloc_server()
233 server->debug_id = atomic_inc_return(&afs_server_debug_id); in afs_alloc_server()
234 RCU_INIT_POINTER(server->addresses, alist); in afs_alloc_server()
235 server->addr_version = alist->version; in afs_alloc_server()
236 server->uuid = *uuid; in afs_alloc_server()
237 rwlock_init(&server->fs_lock); in afs_alloc_server()
238 INIT_WORK(&server->initcb_work, afs_server_init_callback_work); in afs_alloc_server()
239 init_waitqueue_head(&server->probe_wq); in afs_alloc_server()
240 INIT_LIST_HEAD(&server->probe_link); in afs_alloc_server()
241 spin_lock_init(&server->probe_lock); in afs_alloc_server()
242 server->cell = cell; in afs_alloc_server()
243 server->rtt = UINT_MAX; in afs_alloc_server()
246 trace_afs_server(server->debug_id, 1, 1, afs_server_trace_alloc); in afs_alloc_server()
258 static struct afs_addr_list *afs_vl_lookup_addrs(struct afs_cell *cell, in afs_vl_lookup_addrs() argument
265 ret = -ERESTARTSYS; in afs_vl_lookup_addrs()
266 if (afs_begin_vlserver_operation(&vc, cell, key)) { in afs_vl_lookup_addrs()
268 if (test_bit(AFS_VLSERVER_FL_IS_YFS, &vc.server->flags)) in afs_vl_lookup_addrs()
283 struct afs_server *afs_lookup_server(struct afs_cell *cell, struct key *key, in afs_lookup_server() argument
289 _enter("%p,%pU", cell->net, uuid); in afs_lookup_server()
291 server = afs_find_server_by_uuid(cell->net, uuid); in afs_lookup_server()
293 if (server->addr_version != addr_version) in afs_lookup_server()
294 set_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags); in afs_lookup_server()
298 alist = afs_vl_lookup_addrs(cell, key, uuid); in afs_lookup_server()
302 candidate = afs_alloc_server(cell, uuid, alist); in afs_lookup_server()
305 return ERR_PTR(-ENOMEM); in afs_lookup_server()
308 server = afs_install_server(cell, candidate); in afs_lookup_server()
314 * on the fileserver. This will make sure the repeat-probing in afs_lookup_server()
317 afs_fs_probe_fileserver(cell->net, server, key, true); in afs_lookup_server()
329 if (net->live) { in afs_set_server_timer()
331 if (timer_reduce(&net->fs_timer, jiffies + delay * HZ)) in afs_set_server_timer()
345 if (!queue_work(afs_wq, &net->fs_manager)) in afs_servers_timer()
358 __refcount_inc(&server->ref, &r); in afs_get_server()
359 a = atomic_read(&server->active); in afs_get_server()
360 trace_afs_server(server->debug_id, r + 1, a, reason); in afs_get_server()
373 if (!__refcount_inc_not_zero(&server->ref, &r)) in afs_maybe_use_server()
376 a = atomic_inc_return(&server->active); in afs_maybe_use_server()
377 trace_afs_server(server->debug_id, r + 1, a, reason); in afs_maybe_use_server()
382 * Get an active count on a server object.
389 __refcount_inc(&server->ref, &r); in afs_use_server()
390 a = atomic_inc_return(&server->active); in afs_use_server()
392 trace_afs_server(server->debug_id, r + 1, a, reason); in afs_use_server()
402 unsigned int a, debug_id = server->debug_id; in afs_put_server()
409 a = atomic_read(&server->active); in afs_put_server()
410 zero = __refcount_dec_and_test(&server->ref, &r); in afs_put_server()
411 trace_afs_server(debug_id, r - 1, a, reason); in afs_put_server()
417 * Drop an active count on a server object without updating the last-unused
424 unsigned int active = atomic_dec_return(&server->active); in afs_unuse_server_notime()
433 * Drop an active count on a server object.
439 server->unuse_time = ktime_get_real_seconds(); in afs_unuse_server()
448 trace_afs_server(server->debug_id, refcount_read(&server->ref), in afs_server_rcu()
449 atomic_read(&server->active), afs_server_trace_free); in afs_server_rcu()
450 afs_put_addrlist(rcu_access_pointer(server->addresses)); in afs_server_rcu()
456 call_rcu(&server->rcu, afs_server_rcu); in __afs_put_server()
462 struct afs_addr_list *alist = rcu_access_pointer(server->addresses); in afs_give_up_callbacks()
465 .index = alist->preferred, in afs_give_up_callbacks()
477 if (test_bit(AFS_SERVER_FL_MAY_HAVE_CB, &server->flags)) in afs_destroy_server()
480 flush_work(&server->initcb_work); in afs_destroy_server()
493 gc_list = server->gc_next; in afs_gc_servers()
495 write_seqlock(&net->fs_lock); in afs_gc_servers()
497 active = atomic_read(&server->active); in afs_gc_servers()
499 trace_afs_server(server->debug_id, refcount_read(&server->ref), in afs_gc_servers()
502 server->uuid_next, lockdep_is_held(&net->fs_lock.lock)); in afs_gc_servers()
503 prev = server->uuid_prev; in afs_gc_servers()
507 rb_erase(&server->uuid_rb, &net->fs_servers); in afs_gc_servers()
509 rb_replace_node_rcu(&server->uuid_rb, in afs_gc_servers()
510 &next->uuid_rb, in afs_gc_servers()
511 &net->fs_servers); in afs_gc_servers()
512 next->uuid_prev = NULL; in afs_gc_servers()
516 rcu_assign_pointer(prev->uuid_next, next); in afs_gc_servers()
518 next->uuid_prev = prev; in afs_gc_servers()
521 list_del(&server->probe_link); in afs_gc_servers()
522 hlist_del_rcu(&server->proc_link); in afs_gc_servers()
523 if (!hlist_unhashed(&server->addr4_link)) in afs_gc_servers()
524 hlist_del_rcu(&server->addr4_link); in afs_gc_servers()
525 if (!hlist_unhashed(&server->addr6_link)) in afs_gc_servers()
526 hlist_del_rcu(&server->addr6_link); in afs_gc_servers()
528 write_sequnlock(&net->fs_lock); in afs_gc_servers()
539 * Note also that we were given an increment on net->servers_outstanding by
548 bool purging = !net->live; in afs_manage_servers()
555 read_seqlock_excl(&net->fs_lock); in afs_manage_servers()
557 for (cursor = rb_first(&net->fs_servers); cursor; cursor = rb_next(cursor)) { in afs_manage_servers()
560 int active = atomic_read(&server->active); in afs_manage_servers()
562 _debug("manage %pU %u", &server->uuid, active); in afs_manage_servers()
565 trace_afs_server(server->debug_id, refcount_read(&server->ref), in afs_manage_servers()
568 pr_notice("Can't purge s=%08x\n", server->debug_id); in afs_manage_servers()
572 time64_t expire_at = server->unuse_time; in afs_manage_servers()
574 if (!test_bit(AFS_SERVER_FL_VL_FAIL, &server->flags) && in afs_manage_servers()
575 !test_bit(AFS_SERVER_FL_NOT_FOUND, &server->flags)) in afs_manage_servers()
578 server->gc_next = gc_list; in afs_manage_servers()
586 read_sequnlock_excl(&net->fs_lock); in afs_manage_servers()
595 if (next_manage - now <= 0) { in afs_manage_servers()
596 if (queue_work(afs_wq, &net->fs_manager)) in afs_manage_servers()
599 afs_set_server_timer(net, next_manage - now); in afs_manage_servers()
606 _leave(" [%d]", atomic_read(&net->servers_outstanding)); in afs_manage_servers()
612 if (!queue_work(afs_wq, &net->fs_manager)) in afs_queue_server_manager()
623 if (del_timer_sync(&net->fs_timer)) in afs_purge_servers()
629 atomic_dec(&net->servers_outstanding); in afs_purge_servers()
630 wait_var_event(&net->servers_outstanding, in afs_purge_servers()
631 !atomic_read(&net->servers_outstanding)); in afs_purge_servers()
645 trace_afs_server(server->debug_id, refcount_read(&server->ref), in afs_update_server_record()
646 atomic_read(&server->active), in afs_update_server_record()
649 alist = afs_vl_lookup_addrs(op->volume->cell, op->key, &server->uuid); in afs_update_server_record()
651 if ((PTR_ERR(alist) == -ERESTARTSYS || in afs_update_server_record()
652 PTR_ERR(alist) == -EINTR) && in afs_update_server_record()
653 (op->flags & AFS_OPERATION_UNINTR) && in afs_update_server_record()
654 server->addresses) { in afs_update_server_record()
658 op->error = PTR_ERR(alist); in afs_update_server_record()
659 _leave(" = f [%d]", op->error); in afs_update_server_record()
664 if (server->addr_version != alist->version) { in afs_update_server_record()
665 write_lock(&server->fs_lock); in afs_update_server_record()
666 discard = rcu_dereference_protected(server->addresses, in afs_update_server_record()
667 lockdep_is_held(&server->fs_lock)); in afs_update_server_record()
668 rcu_assign_pointer(server->addresses, alist); in afs_update_server_record()
669 server->addr_version = alist->version; in afs_update_server_record()
670 write_unlock(&server->fs_lock); in afs_update_server_record()
691 if (test_bit(AFS_SERVER_FL_UPDATING, &server->flags)) in afs_check_server_record()
693 if (test_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags)) in afs_check_server_record()
699 if (!test_and_set_bit_lock(AFS_SERVER_FL_UPDATING, &server->flags)) { in afs_check_server_record()
700 clear_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags); in afs_check_server_record()
702 clear_bit_unlock(AFS_SERVER_FL_UPDATING, &server->flags); in afs_check_server_record()
703 wake_up_bit(&server->flags, AFS_SERVER_FL_UPDATING); in afs_check_server_record()
709 ret = wait_on_bit(&server->flags, AFS_SERVER_FL_UPDATING, in afs_check_server_record()
710 (op->flags & AFS_OPERATION_UNINTR) ? in afs_check_server_record()
712 if (ret == -ERESTARTSYS) { in afs_check_server_record()
713 op->error = ret; in afs_check_server_record()
721 ret = -ESTALE; in afs_check_server_record()