Lines Matching +full:1 +full:- +full:cell

1 // SPDX-License-Identifier: GPL-2.0-or-later
17 bool afs_begin_vlserver_operation(struct afs_vl_cursor *vc, struct afs_cell *cell, in afs_begin_vlserver_operation() argument
23 vc->cell = cell; in afs_begin_vlserver_operation()
24 vc->key = key; in afs_begin_vlserver_operation()
25 vc->cumul_error.error = -EDESTADDRREQ; in afs_begin_vlserver_operation()
26 vc->nr_iterations = -1; in afs_begin_vlserver_operation()
29 vc->cumul_error.error = -EINTR; in afs_begin_vlserver_operation()
30 vc->flags |= AFS_VL_CURSOR_STOP; in afs_begin_vlserver_operation()
34 vc->debug_id = atomic_inc_return(&debug_ids); in afs_begin_vlserver_operation()
44 struct afs_cell *cell = vc->cell; in afs_start_vl_iteration() local
47 if (cell->dns_source == DNS_RECORD_UNAVAILABLE || in afs_start_vl_iteration()
48 cell->dns_expiry <= ktime_get_real_seconds()) { in afs_start_vl_iteration()
49 dns_lookup_count = smp_load_acquire(&cell->dns_lookup_count); in afs_start_vl_iteration()
50 set_bit(AFS_CELL_FL_DO_LOOKUP, &cell->flags); in afs_start_vl_iteration()
51 afs_queue_cell(cell, afs_cell_trace_get_queue_dns); in afs_start_vl_iteration()
53 if (cell->dns_source == DNS_RECORD_UNAVAILABLE) { in afs_start_vl_iteration()
55 &cell->dns_lookup_count, in afs_start_vl_iteration()
56 smp_load_acquire(&cell->dns_lookup_count) in afs_start_vl_iteration()
58 vc->cumul_error.error = -ERESTARTSYS; in afs_start_vl_iteration()
64 if (cell->dns_status == DNS_LOOKUP_GOT_NOT_FOUND) { in afs_start_vl_iteration()
65 pr_warn("No record of cell %s\n", cell->name); in afs_start_vl_iteration()
66 vc->cumul_error.error = -ENOENT; in afs_start_vl_iteration()
70 if (cell->dns_source == DNS_RECORD_UNAVAILABLE) { in afs_start_vl_iteration()
71 vc->cumul_error.error = -EDESTADDRREQ; in afs_start_vl_iteration()
76 read_lock(&cell->vl_servers_lock); in afs_start_vl_iteration()
77 vc->server_list = afs_get_vlserverlist( in afs_start_vl_iteration()
78 rcu_dereference_protected(cell->vl_servers, in afs_start_vl_iteration()
79 lockdep_is_held(&cell->vl_servers_lock))); in afs_start_vl_iteration()
80 read_unlock(&cell->vl_servers_lock); in afs_start_vl_iteration()
81 if (!vc->server_list->nr_servers) in afs_start_vl_iteration()
84 vc->untried_servers = (1UL << vc->server_list->nr_servers) - 1; in afs_start_vl_iteration()
85 vc->server_index = -1; in afs_start_vl_iteration()
95 struct afs_addr_list *alist = vc->alist; in afs_select_vlserver()
99 s32 abort_code = vc->call_abort_code; in afs_select_vlserver()
100 int error = vc->call_error, i; in afs_select_vlserver()
102 vc->nr_iterations++; in afs_select_vlserver()
105 vc->debug_id, vc->nr_iterations, vc->server_index, vc->untried_servers, in afs_select_vlserver()
106 vc->addr_index, vc->addr_tried, in afs_select_vlserver()
109 if (vc->flags & AFS_VL_CURSOR_STOP) { in afs_select_vlserver()
114 if (vc->nr_iterations == 0) in afs_select_vlserver()
117 WRITE_ONCE(alist->addrs[vc->addr_index].last_error, error); in afs_select_vlserver()
124 vc->cumul_error.error = error; in afs_select_vlserver()
125 vc->flags |= AFS_VL_CURSOR_STOP; in afs_select_vlserver()
126 _leave(" = f [okay/local %d]", vc->cumul_error.error); in afs_select_vlserver()
129 case -ECONNABORTED: in afs_select_vlserver()
138 afs_prioritise_error(&vc->cumul_error, -EREMOTEIO, abort_code); in afs_select_vlserver()
139 //write_lock(&vc->cell->vl_servers_lock); in afs_select_vlserver()
140 //vc->server_list->weird_mask |= 1 << vc->server_index; in afs_select_vlserver()
141 //write_unlock(&vc->cell->vl_servers_lock); in afs_select_vlserver()
145 afs_prioritise_error(&vc->cumul_error, error, abort_code); in afs_select_vlserver()
149 case -ERFKILL: in afs_select_vlserver()
150 case -EADDRNOTAVAIL: in afs_select_vlserver()
151 case -ENETUNREACH: in afs_select_vlserver()
152 case -EHOSTUNREACH: in afs_select_vlserver()
153 case -EHOSTDOWN: in afs_select_vlserver()
154 case -ECONNREFUSED: in afs_select_vlserver()
155 case -ETIMEDOUT: in afs_select_vlserver()
156 case -ETIME: in afs_select_vlserver()
158 afs_prioritise_error(&vc->cumul_error, error, 0); in afs_select_vlserver()
161 case -ECONNRESET: in afs_select_vlserver()
163 afs_prioritise_error(&vc->cumul_error, error, 0); in afs_select_vlserver()
164 vc->flags |= AFS_VL_CURSOR_RETRY; in afs_select_vlserver()
167 case -EOPNOTSUPP: in afs_select_vlserver()
174 if (vc->call_responded && in afs_select_vlserver()
175 vc->addr_index != vc->alist->preferred && in afs_select_vlserver()
176 test_bit(alist->preferred, &vc->addr_tried)) in afs_select_vlserver()
177 WRITE_ONCE(alist->preferred, vc->addr_index); in afs_select_vlserver()
179 alist = vc->alist = NULL; in afs_select_vlserver()
181 afs_put_vlserverlist(vc->cell->net, vc->server_list); in afs_select_vlserver()
182 vc->server_list = NULL; in afs_select_vlserver()
183 if (vc->flags & AFS_VL_CURSOR_RETRIED) in afs_select_vlserver()
185 vc->flags |= AFS_VL_CURSOR_RETRIED; in afs_select_vlserver()
193 error = afs_send_vl_probes(vc->cell->net, vc->key, vc->server_list); in afs_select_vlserver()
195 afs_prioritise_error(&vc->cumul_error, error, 0); in afs_select_vlserver()
200 _debug("pick [%lx]", vc->untried_servers); in afs_select_vlserver()
203 error = afs_wait_for_vl_probes(vc->server_list, vc->untried_servers); in afs_select_vlserver()
205 afs_prioritise_error(&vc->cumul_error, error, 0); in afs_select_vlserver()
210 vc->server_index = vc->server_list->preferred; in afs_select_vlserver()
211 if (test_bit(vc->server_index, &vc->untried_servers)) in afs_select_vlserver()
214 vc->server_index = -1; in afs_select_vlserver()
216 for (i = 0; i < vc->server_list->nr_servers; i++) { in afs_select_vlserver()
217 struct afs_vlserver *s = vc->server_list->servers[i].server; in afs_select_vlserver()
219 if (!test_bit(i, &vc->untried_servers) || in afs_select_vlserver()
220 !test_bit(AFS_VLSERVER_FL_RESPONDING, &s->flags)) in afs_select_vlserver()
222 if (s->probe.rtt <= rtt) { in afs_select_vlserver()
223 vc->server_index = i; in afs_select_vlserver()
224 rtt = s->probe.rtt; in afs_select_vlserver()
228 if (vc->server_index == -1) in afs_select_vlserver()
232 _debug("use %d", vc->server_index); in afs_select_vlserver()
233 __clear_bit(vc->server_index, &vc->untried_servers); in afs_select_vlserver()
239 vlserver = vc->server_list->servers[vc->server_index].server; in afs_select_vlserver()
240 vc->server = vlserver; in afs_select_vlserver()
242 _debug("USING VLSERVER: %s", vlserver->name); in afs_select_vlserver()
244 read_lock(&vlserver->lock); in afs_select_vlserver()
245 alist = rcu_dereference_protected(vlserver->addresses, in afs_select_vlserver()
246 lockdep_is_held(&vlserver->lock)); in afs_select_vlserver()
247 vc->alist = afs_get_addrlist(alist, afs_alist_trace_get_vlrotate_set); in afs_select_vlserver()
248 read_unlock(&vlserver->lock); in afs_select_vlserver()
250 vc->addr_tried = 0; in afs_select_vlserver()
251 vc->addr_index = -1; in afs_select_vlserver()
257 set = READ_ONCE(alist->responded); in afs_select_vlserver()
258 failed = READ_ONCE(alist->probe_failed); in afs_select_vlserver()
259 vc->addr_index = READ_ONCE(alist->preferred); in afs_select_vlserver()
261 _debug("%lx-%lx-%lx,%d", set, failed, vc->addr_tried, vc->addr_index); in afs_select_vlserver()
263 set &= ~(failed | vc->addr_tried); in afs_select_vlserver()
268 if (!test_bit(vc->addr_index, &set)) in afs_select_vlserver()
269 vc->addr_index = __ffs(set); in afs_select_vlserver()
271 set_bit(vc->addr_index, &vc->addr_tried); in afs_select_vlserver()
272 vc->alist = alist; in afs_select_vlserver()
274 _debug("VL address %d/%d", vc->addr_index, alist->nr_addrs); in afs_select_vlserver()
276 vc->call_responded = false; in afs_select_vlserver()
277 _leave(" = t %pISpc", rxrpc_kernel_remote_addr(alist->addrs[vc->addr_index].peer)); in afs_select_vlserver()
283 if (vc->call_responded && in afs_select_vlserver()
284 vc->addr_index != alist->preferred && in afs_select_vlserver()
285 test_bit(alist->preferred, &vc->addr_tried)) in afs_select_vlserver()
286 WRITE_ONCE(alist->preferred, vc->addr_index); in afs_select_vlserver()
288 alist = vc->alist = NULL; in afs_select_vlserver()
295 if (vc->flags & AFS_VL_CURSOR_RETRY) in afs_select_vlserver()
298 for (i = 0; i < vc->server_list->nr_servers; i++) { in afs_select_vlserver()
299 struct afs_vlserver *s = vc->server_list->servers[i].server; in afs_select_vlserver()
301 if (test_bit(AFS_VLSERVER_FL_RESPONDING, &s->flags)) in afs_select_vlserver()
302 vc->cumul_error.responded = true; in afs_select_vlserver()
303 afs_prioritise_error(&vc->cumul_error, READ_ONCE(s->probe.error), in afs_select_vlserver()
304 s->probe.abort_code); in afs_select_vlserver()
309 if (vc->call_responded && in afs_select_vlserver()
310 vc->addr_index != alist->preferred && in afs_select_vlserver()
311 test_bit(alist->preferred, &vc->addr_tried)) in afs_select_vlserver()
312 WRITE_ONCE(alist->preferred, vc->addr_index); in afs_select_vlserver()
314 alist = vc->alist = NULL; in afs_select_vlserver()
316 vc->flags |= AFS_VL_CURSOR_STOP; in afs_select_vlserver()
317 _leave(" = f [failed %d]", vc->cumul_error.error); in afs_select_vlserver()
326 struct afs_cell *cell = vc->cell; in afs_vl_dump_edestaddrreq() local
336 pr_notice("CELL: %s err=%d\n", cell->name, cell->error); in afs_vl_dump_edestaddrreq()
338 cell->dns_source, cell->dns_status, cell->dns_lookup_count); in afs_vl_dump_edestaddrreq()
340 vc->untried_servers, vc->server_index, vc->nr_iterations, in afs_vl_dump_edestaddrreq()
341 vc->flags, vc->cumul_error.error); in afs_vl_dump_edestaddrreq()
343 vc->call_error, vc->call_abort_code, vc->call_responded); in afs_vl_dump_edestaddrreq()
345 if (vc->server_list) { in afs_vl_dump_edestaddrreq()
346 const struct afs_vlserver_list *sl = vc->server_list; in afs_vl_dump_edestaddrreq()
348 sl->nr_servers, sl->index); in afs_vl_dump_edestaddrreq()
349 for (i = 0; i < sl->nr_servers; i++) { in afs_vl_dump_edestaddrreq()
350 const struct afs_vlserver *s = sl->servers[i].server; in afs_vl_dump_edestaddrreq()
352 s->name, s->port, s->flags, s->probe.error); in afs_vl_dump_edestaddrreq()
353 if (s->addresses) { in afs_vl_dump_edestaddrreq()
355 rcu_dereference(s->addresses); in afs_vl_dump_edestaddrreq()
356 pr_notice("VC: - nr=%u/%u/%u pf=%u\n", in afs_vl_dump_edestaddrreq()
357 a->nr_ipv4, a->nr_addrs, a->max_addrs, in afs_vl_dump_edestaddrreq()
358 a->preferred); in afs_vl_dump_edestaddrreq()
359 pr_notice("VC: - R=%lx F=%lx\n", in afs_vl_dump_edestaddrreq()
360 a->responded, a->probe_failed); in afs_vl_dump_edestaddrreq()
361 if (a == vc->alist) in afs_vl_dump_edestaddrreq()
362 pr_notice("VC: - current\n"); in afs_vl_dump_edestaddrreq()
367 pr_notice("AC: t=%lx ax=%u\n", vc->addr_tried, vc->addr_index); in afs_vl_dump_edestaddrreq()
376 struct afs_net *net = vc->cell->net; in afs_end_vlserver_operation()
378 _enter("VC=%x+%x", vc->debug_id, vc->nr_iterations); in afs_end_vlserver_operation()
380 switch (vc->cumul_error.error) { in afs_end_vlserver_operation()
381 case -EDESTADDRREQ: in afs_end_vlserver_operation()
382 case -EADDRNOTAVAIL: in afs_end_vlserver_operation()
383 case -ENETUNREACH: in afs_end_vlserver_operation()
384 case -EHOSTUNREACH: in afs_end_vlserver_operation()
389 if (vc->alist) { in afs_end_vlserver_operation()
390 if (vc->call_responded && in afs_end_vlserver_operation()
391 vc->addr_index != vc->alist->preferred && in afs_end_vlserver_operation()
392 test_bit(vc->alist->preferred, &vc->addr_tried)) in afs_end_vlserver_operation()
393 WRITE_ONCE(vc->alist->preferred, vc->addr_index); in afs_end_vlserver_operation()
394 afs_put_addrlist(vc->alist, afs_alist_trace_put_vlrotate_end); in afs_end_vlserver_operation()
395 vc->alist = NULL; in afs_end_vlserver_operation()
397 afs_put_vlserverlist(net, vc->server_list); in afs_end_vlserver_operation()
398 return vc->cumul_error.error; in afs_end_vlserver_operation()