• Home
  • Raw
  • Download

Lines Matching refs:cell

55 	struct afs_cell *cell = NULL;  in afs_find_cell_locked()  local
67 cell = net->ws_cell; in afs_find_cell_locked()
68 if (!cell) in afs_find_cell_locked()
75 cell = rb_entry(p, struct afs_cell, net_node); in afs_find_cell_locked()
77 n = strncasecmp(cell->name, name, in afs_find_cell_locked()
78 min_t(size_t, cell->name_len, namesz)); in afs_find_cell_locked()
80 n = cell->name_len - namesz; in afs_find_cell_locked()
92 return afs_use_cell(cell, reason); in afs_find_cell_locked()
102 struct afs_cell *cell; in afs_find_cell() local
105 cell = afs_find_cell_locked(net, name, namesz, reason); in afs_find_cell()
107 return cell; in afs_find_cell()
119 struct afs_cell *cell; in afs_alloc_cell() local
143 cell = kzalloc(sizeof(struct afs_cell), GFP_KERNEL); in afs_alloc_cell()
144 if (!cell) { in afs_alloc_cell()
149 cell->name = kmalloc(namelen + 1, GFP_KERNEL); in afs_alloc_cell()
150 if (!cell->name) { in afs_alloc_cell()
151 kfree(cell); in afs_alloc_cell()
155 cell->net = net; in afs_alloc_cell()
156 cell->name_len = namelen; in afs_alloc_cell()
158 cell->name[i] = tolower(name[i]); in afs_alloc_cell()
159 cell->name[i] = 0; in afs_alloc_cell()
161 atomic_set(&cell->ref, 1); in afs_alloc_cell()
162 atomic_set(&cell->active, 0); in afs_alloc_cell()
163 INIT_WORK(&cell->manager, afs_manage_cell_work); in afs_alloc_cell()
164 cell->volumes = RB_ROOT; in afs_alloc_cell()
165 INIT_HLIST_HEAD(&cell->proc_volumes); in afs_alloc_cell()
166 seqlock_init(&cell->volume_lock); in afs_alloc_cell()
167 cell->fs_servers = RB_ROOT; in afs_alloc_cell()
168 seqlock_init(&cell->fs_lock); in afs_alloc_cell()
169 rwlock_init(&cell->vl_servers_lock); in afs_alloc_cell()
170 cell->flags = (1 << AFS_CELL_FL_CHECK_ALIAS); in afs_alloc_cell()
186 cell->dns_expiry = TIME64_MAX; in afs_alloc_cell()
194 cell->dns_expiry = ktime_get_real_seconds(); in afs_alloc_cell()
197 rcu_assign_pointer(cell->vl_servers, vllist); in afs_alloc_cell()
199 cell->dns_source = vllist->source; in afs_alloc_cell()
200 cell->dns_status = vllist->status; in afs_alloc_cell()
201 smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */ in afs_alloc_cell()
203 cell->debug_id = atomic_inc_return(&cell_debug_id); in afs_alloc_cell()
204 trace_afs_cell(cell->debug_id, 1, 0, afs_cell_trace_alloc); in afs_alloc_cell()
206 _leave(" = %p", cell); in afs_alloc_cell()
207 return cell; in afs_alloc_cell()
213 kfree(cell->name); in afs_alloc_cell()
214 kfree(cell); in afs_alloc_cell()
236 struct afs_cell *cell, *candidate, *cursor; in afs_lookup_cell() local
244 cell = afs_find_cell(net, name, namesz, afs_cell_trace_use_lookup); in afs_lookup_cell()
245 if (!IS_ERR(cell)) in afs_lookup_cell()
285 cell = candidate; in afs_lookup_cell()
287 atomic_set(&cell->active, 2); in afs_lookup_cell()
288 trace_afs_cell(cell->debug_id, atomic_read(&cell->ref), 2, afs_cell_trace_insert); in afs_lookup_cell()
289 rb_link_node_rcu(&cell->net_node, parent, pp); in afs_lookup_cell()
290 rb_insert_color(&cell->net_node, &net->cells); in afs_lookup_cell()
293 afs_queue_cell(cell, afs_cell_trace_get_queue_new); in afs_lookup_cell()
296 trace_afs_cell(cell->debug_id, atomic_read(&cell->ref), atomic_read(&cell->active), in afs_lookup_cell()
299 wait_var_event(&cell->state, in afs_lookup_cell()
301 state = smp_load_acquire(&cell->state); /* vs error */ in afs_lookup_cell()
307 ret = cell->error; in afs_lookup_cell()
311 _leave(" = %p [cell]", cell); in afs_lookup_cell()
312 return cell; in afs_lookup_cell()
316 cell = cursor; in afs_lookup_cell()
330 afs_unuse_cell(net, cell, afs_cell_trace_unuse_lookup); in afs_lookup_cell()
392 static int afs_update_cell(struct afs_cell *cell) in afs_update_cell() argument
400 _enter("%s", cell->name); in afs_update_cell()
402 vllist = afs_dns_query(cell, &expiry); in afs_update_cell()
406 _debug("%s: fail %d", cell->name, ret); in afs_update_cell()
432 _debug("%s: got list %d %d", cell->name, vllist->source, vllist->status); in afs_update_cell()
433 cell->dns_status = vllist->status; in afs_update_cell()
443 _debug("%s: status %d", cell->name, vllist->status); in afs_update_cell()
450 cell->dns_expiry = expiry; in afs_update_cell()
458 cell->dns_expiry = now + 10; in afs_update_cell()
462 cell->dns_expiry = expiry; in afs_update_cell()
468 write_lock(&cell->vl_servers_lock); in afs_update_cell()
469 p = rcu_dereference_protected(cell->vl_servers, true); in afs_update_cell()
471 rcu_assign_pointer(cell->vl_servers, vllist); in afs_update_cell()
472 cell->dns_source = vllist->source; in afs_update_cell()
475 write_unlock(&cell->vl_servers_lock); in afs_update_cell()
476 afs_put_vlserverlist(cell->net, old); in afs_update_cell()
479 smp_store_release(&cell->dns_lookup_count, in afs_update_cell()
480 cell->dns_lookup_count + 1); /* vs source/status */ in afs_update_cell()
481 wake_up_var(&cell->dns_lookup_count); in afs_update_cell()
491 struct afs_cell *cell = container_of(rcu, struct afs_cell, rcu); in afs_cell_destroy() local
492 struct afs_net *net = cell->net; in afs_cell_destroy()
495 _enter("%p{%s}", cell, cell->name); in afs_cell_destroy()
497 u = atomic_read(&cell->ref); in afs_cell_destroy()
499 trace_afs_cell(cell->debug_id, u, atomic_read(&cell->active), afs_cell_trace_free); in afs_cell_destroy()
501 afs_put_vlserverlist(net, rcu_access_pointer(cell->vl_servers)); in afs_cell_destroy()
502 afs_unuse_cell(net, cell->alias_of, afs_cell_trace_unuse_alias); in afs_cell_destroy()
503 key_put(cell->anonymous_key); in afs_cell_destroy()
504 kfree(cell->name); in afs_cell_destroy()
505 kfree(cell); in afs_cell_destroy()
540 struct afs_cell *afs_get_cell(struct afs_cell *cell, enum afs_cell_trace reason) in afs_get_cell() argument
544 if (atomic_read(&cell->ref) <= 0) in afs_get_cell()
547 u = atomic_inc_return(&cell->ref); in afs_get_cell()
548 trace_afs_cell(cell->debug_id, u, atomic_read(&cell->active), reason); in afs_get_cell()
549 return cell; in afs_get_cell()
555 void afs_put_cell(struct afs_cell *cell, enum afs_cell_trace reason) in afs_put_cell() argument
557 if (cell) { in afs_put_cell()
558 unsigned int debug_id = cell->debug_id; in afs_put_cell()
561 a = atomic_read(&cell->active); in afs_put_cell()
562 u = atomic_dec_return(&cell->ref); in afs_put_cell()
565 a = atomic_read(&cell->active); in afs_put_cell()
567 call_rcu(&cell->rcu, afs_cell_destroy); in afs_put_cell()
575 struct afs_cell *afs_use_cell(struct afs_cell *cell, enum afs_cell_trace reason) in afs_use_cell() argument
579 if (atomic_read(&cell->ref) <= 0) in afs_use_cell()
582 u = atomic_read(&cell->ref); in afs_use_cell()
583 a = atomic_inc_return(&cell->active); in afs_use_cell()
584 trace_afs_cell(cell->debug_id, u, a, reason); in afs_use_cell()
585 return cell; in afs_use_cell()
592 void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_trace reason) in afs_unuse_cell() argument
598 if (!cell) in afs_unuse_cell()
601 _enter("%s", cell->name); in afs_unuse_cell()
604 cell->last_inactive = now; in afs_unuse_cell()
606 if (cell->vl_servers->nr_servers) in afs_unuse_cell()
609 debug_id = cell->debug_id; in afs_unuse_cell()
610 u = atomic_read(&cell->ref); in afs_unuse_cell()
611 a = atomic_dec_return(&cell->active); in afs_unuse_cell()
622 void afs_see_cell(struct afs_cell *cell, enum afs_cell_trace reason) in afs_see_cell() argument
626 u = atomic_read(&cell->ref); in afs_see_cell()
627 a = atomic_read(&cell->active); in afs_see_cell()
628 trace_afs_cell(cell->debug_id, u, a, reason); in afs_see_cell()
634 void afs_queue_cell(struct afs_cell *cell, enum afs_cell_trace reason) in afs_queue_cell() argument
636 afs_get_cell(cell, reason); in afs_queue_cell()
637 if (!queue_work(afs_wq, &cell->manager)) in afs_queue_cell()
638 afs_put_cell(cell, afs_cell_trace_put_queue_fail); in afs_queue_cell()
644 static int afs_alloc_anon_key(struct afs_cell *cell) in afs_alloc_anon_key() argument
652 cp = cell->name; in afs_alloc_anon_key()
661 cell->anonymous_key = key; in afs_alloc_anon_key()
664 cell->anonymous_key, key_serial(cell->anonymous_key)); in afs_alloc_anon_key()
671 static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell) in afs_activate_cell() argument
677 if (!cell->anonymous_key) { in afs_activate_cell()
678 ret = afs_alloc_anon_key(cell); in afs_activate_cell()
684 cell->cache = fscache_acquire_cookie(afs_cache_netfs.primary_index, in afs_activate_cell()
686 cell->name, strlen(cell->name), in afs_activate_cell()
688 cell, 0, true); in afs_activate_cell()
690 ret = afs_proc_cell_setup(cell); in afs_activate_cell()
697 if (strcmp(cell->name, pcell->name) < 0) in afs_activate_cell()
701 cell->proc_link.pprev = p; in afs_activate_cell()
702 cell->proc_link.next = *p; in afs_activate_cell()
703 rcu_assign_pointer(*p, &cell->proc_link.next); in afs_activate_cell()
704 if (cell->proc_link.next) in afs_activate_cell()
705 cell->proc_link.next->pprev = &cell->proc_link.next; in afs_activate_cell()
707 afs_dynroot_mkdir(net, cell); in afs_activate_cell()
715 static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell) in afs_deactivate_cell() argument
717 _enter("%s", cell->name); in afs_deactivate_cell()
719 afs_proc_cell_remove(cell); in afs_deactivate_cell()
722 hlist_del_rcu(&cell->proc_link); in afs_deactivate_cell()
723 afs_dynroot_rmdir(net, cell); in afs_deactivate_cell()
727 fscache_relinquish_cookie(cell->cache, NULL, false); in afs_deactivate_cell()
728 cell->cache = NULL; in afs_deactivate_cell()
738 static void afs_manage_cell(struct afs_cell *cell) in afs_manage_cell() argument
740 struct afs_net *net = cell->net; in afs_manage_cell()
743 _enter("%s", cell->name); in afs_manage_cell()
746 _debug("state %u", cell->state); in afs_manage_cell()
747 switch (cell->state) { in afs_manage_cell()
752 if (atomic_try_cmpxchg_relaxed(&cell->active, &active, 0)) { in afs_manage_cell()
753 rb_erase(&cell->net_node, &net->cells); in afs_manage_cell()
754 trace_afs_cell(cell->debug_id, atomic_read(&cell->ref), 0, in afs_manage_cell()
756 smp_store_release(&cell->state, AFS_CELL_REMOVED); in afs_manage_cell()
759 if (cell->state == AFS_CELL_REMOVED) { in afs_manage_cell()
760 wake_up_var(&cell->state); in afs_manage_cell()
763 if (cell->state == AFS_CELL_FAILED) in afs_manage_cell()
765 smp_store_release(&cell->state, AFS_CELL_UNSET); in afs_manage_cell()
766 wake_up_var(&cell->state); in afs_manage_cell()
770 smp_store_release(&cell->state, AFS_CELL_ACTIVATING); in afs_manage_cell()
771 wake_up_var(&cell->state); in afs_manage_cell()
775 ret = afs_activate_cell(net, cell); in afs_manage_cell()
779 smp_store_release(&cell->state, AFS_CELL_ACTIVE); in afs_manage_cell()
780 wake_up_var(&cell->state); in afs_manage_cell()
784 if (atomic_read(&cell->active) > 1) { in afs_manage_cell()
785 if (test_and_clear_bit(AFS_CELL_FL_DO_LOOKUP, &cell->flags)) { in afs_manage_cell()
786 ret = afs_update_cell(cell); in afs_manage_cell()
788 cell->error = ret; in afs_manage_cell()
792 smp_store_release(&cell->state, AFS_CELL_DEACTIVATING); in afs_manage_cell()
793 wake_up_var(&cell->state); in afs_manage_cell()
797 if (atomic_read(&cell->active) > 1) in afs_manage_cell()
799 afs_deactivate_cell(net, cell); in afs_manage_cell()
800 smp_store_release(&cell->state, AFS_CELL_INACTIVE); in afs_manage_cell()
801 wake_up_var(&cell->state); in afs_manage_cell()
810 _debug("bad state %u", cell->state); in afs_manage_cell()
814 cell->error = ret; in afs_manage_cell()
815 afs_deactivate_cell(net, cell); in afs_manage_cell()
817 smp_store_release(&cell->state, AFS_CELL_FAILED); /* vs error */ in afs_manage_cell()
818 wake_up_var(&cell->state); in afs_manage_cell()
822 smp_store_release(&cell->state, AFS_CELL_ACTIVE); in afs_manage_cell()
823 wake_up_var(&cell->state); in afs_manage_cell()
828 _leave(" [done %u]", cell->state); in afs_manage_cell()
833 afs_put_volume(cell->net, cell->root_volume, afs_volume_trace_put_cell_root); in afs_manage_cell()
834 cell->root_volume = NULL; in afs_manage_cell()
835 afs_put_cell(cell, afs_cell_trace_put_destroy); in afs_manage_cell()
840 struct afs_cell *cell = container_of(work, struct afs_cell, manager); in afs_manage_cell_work() local
842 afs_manage_cell(cell); in afs_manage_cell_work()
843 afs_put_cell(cell, afs_cell_trace_put_queue_work); in afs_manage_cell_work()
875 struct afs_cell *cell = in afs_manage_cells() local
880 active = atomic_read(&cell->active); in afs_manage_cells()
881 trace_afs_cell(cell->debug_id, atomic_read(&cell->ref), in afs_manage_cells()
887 if (test_and_clear_bit(AFS_CELL_FL_NO_GC, &cell->flags)) { in afs_manage_cells()
888 active = atomic_dec_return(&cell->active); in afs_manage_cells()
889 trace_afs_cell(cell->debug_id, atomic_read(&cell->ref), in afs_manage_cells()
896 time64_t expire_at = cell->last_inactive; in afs_manage_cells()
898 read_lock(&cell->vl_servers_lock); in afs_manage_cells()
900 cell->vl_servers, in afs_manage_cells()
901 lockdep_is_held(&cell->vl_servers_lock)); in afs_manage_cells()
904 read_unlock(&cell->vl_servers_lock); in afs_manage_cells()
912 if (test_bit(AFS_CELL_FL_DO_LOOKUP, &cell->flags)) in afs_manage_cells()
917 afs_queue_cell(cell, afs_cell_trace_get_queue_manage); in afs_manage_cells()