Lines Matching refs:op
18 void afs_clear_server_states(struct afs_operation *op) in afs_clear_server_states() argument
22 if (op->server_states) { in afs_clear_server_states()
23 for (i = 0; i < op->server_list->nr_servers; i++) in afs_clear_server_states()
24 afs_put_endpoint_state(op->server_states[i].endpoint_state, in afs_clear_server_states()
26 kfree(op->server_states); in afs_clear_server_states()
34 static bool afs_start_fs_iteration(struct afs_operation *op, in afs_start_fs_iteration() argument
41 trace_afs_rotate(op, afs_rotate_trace_start, 0); in afs_start_fs_iteration()
43 read_lock(&op->volume->servers_lock); in afs_start_fs_iteration()
44 op->server_list = afs_get_serverlist( in afs_start_fs_iteration()
45 rcu_dereference_protected(op->volume->servers, in afs_start_fs_iteration()
46 lockdep_is_held(&op->volume->servers_lock))); in afs_start_fs_iteration()
47 read_unlock(&op->volume->servers_lock); in afs_start_fs_iteration()
49 op->server_states = kcalloc(op->server_list->nr_servers, sizeof(op->server_states[0]), in afs_start_fs_iteration()
51 if (!op->server_states) { in afs_start_fs_iteration()
52 afs_op_nomem(op); in afs_start_fs_iteration()
53 trace_afs_rotate(op, afs_rotate_trace_nomem, 0); in afs_start_fs_iteration()
58 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_start_fs_iteration()
60 struct afs_server_state *s = &op->server_states[i]; in afs_start_fs_iteration()
62 server = op->server_list->servers[i].server; in afs_start_fs_iteration()
69 afs_get_address_preferences(op->net, estate->addresses); in afs_start_fs_iteration()
74 op->untried_servers = (1UL << op->server_list->nr_servers) - 1; in afs_start_fs_iteration()
75 op->server_index = -1; in afs_start_fs_iteration()
80 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_start_fs_iteration()
81 server = op->server_list->servers[i].server; in afs_start_fs_iteration()
83 op->server_index = i; in afs_start_fs_iteration()
92 if (op->flags & AFS_OPERATION_CUR_ONLY) { in afs_start_fs_iteration()
93 afs_op_set_error(op, -ESTALE); in afs_start_fs_iteration()
94 trace_afs_rotate(op, afs_rotate_trace_stale_lock, 0); in afs_start_fs_iteration()
114 static void afs_busy(struct afs_operation *op, u32 abort_code) in afs_busy() argument
126 op->volume->vid, op->volume->name, &op->server->uuid, m); in afs_busy()
132 static bool afs_sleep_and_retry(struct afs_operation *op) in afs_sleep_and_retry() argument
134 trace_afs_rotate(op, afs_rotate_trace_busy_sleep, 0); in afs_sleep_and_retry()
135 if (!(op->flags & AFS_OPERATION_UNINTR)) { in afs_sleep_and_retry()
138 afs_op_set_error(op, -ERESTARTSYS); in afs_sleep_and_retry()
152 bool afs_select_fileserver(struct afs_operation *op) in afs_select_fileserver() argument
156 struct afs_vnode *vnode = op->file[0].vnode; in afs_select_fileserver()
158 s32 abort_code = op->call_abort_code; in afs_select_fileserver()
160 int error = op->call_error, addr_index, i, j; in afs_select_fileserver()
162 op->nr_iterations++; in afs_select_fileserver()
165 op->debug_id, op->nr_iterations, op->volume->vid, in afs_select_fileserver()
166 op->server_index, op->untried_servers, in afs_select_fileserver()
167 op->addr_index, op->addr_tried, in afs_select_fileserver()
170 if (op->flags & AFS_OPERATION_STOP) { in afs_select_fileserver()
171 trace_afs_rotate(op, afs_rotate_trace_stopped, 0); in afs_select_fileserver()
176 if (op->nr_iterations == 0) in afs_select_fileserver()
179 WRITE_ONCE(op->estate->addresses->addrs[op->addr_index].last_error, error); in afs_select_fileserver()
180 trace_afs_rotate(op, afs_rotate_trace_iter, op->call_error); in afs_select_fileserver()
183 switch (op->call_error) { in afs_select_fileserver()
186 &op->server_list->servers[op->server_index].flags); in afs_select_fileserver()
188 &op->server_list->servers[op->server_index].flags); in afs_select_fileserver()
189 op->cumul_error.responded = true; in afs_select_fileserver()
197 error = afs_update_volume_state(op); in afs_select_fileserver()
200 afs_sleep_and_retry(op); in afs_select_fileserver()
203 afs_op_set_error(op, error); in afs_select_fileserver()
209 afs_op_set_error(op, error); in afs_select_fileserver()
210 op->flags |= AFS_OPERATION_STOP; in afs_select_fileserver()
211 trace_afs_rotate(op, afs_rotate_trace_stop, error); in afs_select_fileserver()
224 trace_afs_rotate(op, afs_rotate_trace_aborted, abort_code); in afs_select_fileserver()
225 op->cumul_error.responded = true; in afs_select_fileserver()
238 if (op->flags & AFS_OPERATION_VNOVOL) { in afs_select_fileserver()
239 afs_op_accumulate_error(op, -EREMOTEIO, abort_code); in afs_select_fileserver()
243 write_lock(&op->volume->servers_lock); in afs_select_fileserver()
244 op->server_list->vnovol_mask |= 1 << op->server_index; in afs_select_fileserver()
245 write_unlock(&op->volume->servers_lock); in afs_select_fileserver()
247 set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags); in afs_select_fileserver()
248 error = afs_check_volume_status(op->volume, op); in afs_select_fileserver()
250 afs_op_set_error(op, error); in afs_select_fileserver()
254 if (test_bit(AFS_VOLUME_DELETED, &op->volume->flags)) { in afs_select_fileserver()
255 afs_op_set_error(op, -ENOMEDIUM); in afs_select_fileserver()
262 if (rcu_access_pointer(op->volume->servers) == op->server_list) { in afs_select_fileserver()
263 afs_op_accumulate_error(op, -EREMOTEIO, abort_code); in afs_select_fileserver()
268 op->flags |= AFS_OPERATION_VNOVOL; in afs_select_fileserver()
277 afs_op_accumulate_error(op, -EREMOTEIO, abort_code); in afs_select_fileserver()
308 afs_op_accumulate_error(op, -ETIMEDOUT, abort_code); in afs_select_fileserver()
323 &op->server_list->servers[op->server_index].flags)) { in afs_select_fileserver()
324 afs_busy(op, abort_code); in afs_select_fileserver()
326 &op->server_list->servers[op->server_index].flags); in afs_select_fileserver()
328 if (op->flags & AFS_OPERATION_NO_VSLEEP) { in afs_select_fileserver()
329 afs_op_set_error(op, -EADV); in afs_select_fileserver()
349 if (op->flags & AFS_OPERATION_NO_VSLEEP) { in afs_select_fileserver()
350 afs_op_set_error(op, -EBUSY); in afs_select_fileserver()
354 &op->server_list->servers[op->server_index].flags)) { in afs_select_fileserver()
355 afs_busy(op, abort_code); in afs_select_fileserver()
357 &op->server_list->servers[op->server_index].flags); in afs_select_fileserver()
360 if (op->flags & AFS_OPERATION_CUR_ONLY) { in afs_select_fileserver()
361 if (!afs_sleep_and_retry(op)) in afs_select_fileserver()
369 op->flags |= AFS_OPERATION_VBUSY; in afs_select_fileserver()
380 if (op->flags & AFS_OPERATION_VMOVED) { in afs_select_fileserver()
381 afs_op_set_error(op, -EREMOTEIO); in afs_select_fileserver()
384 op->flags |= AFS_OPERATION_VMOVED; in afs_select_fileserver()
386 set_bit(AFS_VOLUME_WAIT, &op->volume->flags); in afs_select_fileserver()
387 set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags); in afs_select_fileserver()
388 error = afs_check_volume_status(op->volume, op); in afs_select_fileserver()
390 afs_op_set_error(op, error); in afs_select_fileserver()
403 if (rcu_access_pointer(op->volume->servers) == op->server_list) { in afs_select_fileserver()
404 afs_op_accumulate_error(op, -ENOMEDIUM, abort_code); in afs_select_fileserver()
412 afs_op_accumulate_error(op, -EREMOTEIO, abort_code); in afs_select_fileserver()
413 if (op->volume->type != AFSVL_RWVOL) in afs_select_fileserver()
423 afs_op_set_error(op, -ENOSPC); in afs_select_fileserver()
432 afs_op_set_error(op, -EDQUOT); in afs_select_fileserver()
436 afs_op_accumulate_error(op, error, abort_code); in afs_select_fileserver()
439 &op->server_list->servers[op->server_index].flags); in afs_select_fileserver()
441 &op->server_list->servers[op->server_index].flags); in afs_select_fileserver()
447 if (afs_op_error(op) != -EDESTADDRREQ) in afs_select_fileserver()
457 afs_op_accumulate_error(op, error, 0); in afs_select_fileserver()
462 op->type ? op->type->name : "???", op->debug_id); in afs_select_fileserver()
466 afs_op_set_error(op, error); in afs_select_fileserver()
471 trace_afs_rotate(op, afs_rotate_trace_restart, 0); in afs_select_fileserver()
473 op->estate = NULL; in afs_select_fileserver()
474 op->server = NULL; in afs_select_fileserver()
475 afs_clear_server_states(op); in afs_select_fileserver()
476 op->server_states = NULL; in afs_select_fileserver()
477 afs_put_serverlist(op->net, op->server_list); in afs_select_fileserver()
478 op->server_list = NULL; in afs_select_fileserver()
481 ASSERTCMP(op->estate, ==, NULL); in afs_select_fileserver()
485 error = afs_check_volume_status(op->volume, op); in afs_select_fileserver()
486 trace_afs_rotate(op, afs_rotate_trace_check_vol_status, error); in afs_select_fileserver()
488 afs_op_set_error(op, error); in afs_select_fileserver()
492 if (!afs_start_fs_iteration(op, vnode)) in afs_select_fileserver()
495 _debug("__ VOL %llx __", op->volume->vid); in afs_select_fileserver()
498 _debug("pick [%lx]", op->untried_servers); in afs_select_fileserver()
499 ASSERTCMP(op->estate, ==, NULL); in afs_select_fileserver()
501 error = afs_wait_for_fs_probes(op, op->server_states, in afs_select_fileserver()
502 !(op->flags & AFS_OPERATION_UNINTR)); in afs_select_fileserver()
505 trace_afs_rotate(op, afs_rotate_trace_probe_none, 0); in afs_select_fileserver()
508 trace_afs_rotate(op, afs_rotate_trace_probe_response, 0); in afs_select_fileserver()
511 trace_afs_rotate(op, afs_rotate_trace_probe_superseded, 0); in afs_select_fileserver()
514 trace_afs_rotate(op, afs_rotate_trace_probe_error, error); in afs_select_fileserver()
515 afs_op_set_error(op, error); in afs_select_fileserver()
523 if (op->server) { in afs_select_fileserver()
524 _debug("server %u", op->server_index); in afs_select_fileserver()
525 if (test_bit(op->server_index, &op->untried_servers)) in afs_select_fileserver()
527 op->server = NULL; in afs_select_fileserver()
532 op->server_index = -1; in afs_select_fileserver()
534 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_select_fileserver()
536 struct afs_server_entry *se = &op->server_list->servers[i]; in afs_select_fileserver()
540 if (!test_bit(i, &op->untried_servers) || in afs_select_fileserver()
544 es = op->server_states[i].endpoint_state; in afs_select_fileserver()
547 afs_get_address_preferences_rcu(op->net, sal); in afs_select_fileserver()
554 op->server_index = i; in afs_select_fileserver()
561 if (op->server_index == -1) in afs_select_fileserver()
565 trace_afs_rotate(op, afs_rotate_trace_selected_server, best_prio); in afs_select_fileserver()
566 _debug("use %d prio %u", op->server_index, best_prio); in afs_select_fileserver()
567 __clear_bit(op->server_index, &op->untried_servers); in afs_select_fileserver()
573 ASSERTCMP(op->estate, ==, NULL); in afs_select_fileserver()
574 server = op->server_list->servers[op->server_index].server; in afs_select_fileserver()
576 if (!afs_check_server_record(op, server, op->key)) in afs_select_fileserver()
581 op->flags |= AFS_OPERATION_RETRY_SERVER; in afs_select_fileserver()
582 op->server = server; in afs_select_fileserver()
590 op->addr_tried = 0; in afs_select_fileserver()
591 op->addr_index = -1; in afs_select_fileserver()
597 op->estate = op->server_states[op->server_index].endpoint_state; in afs_select_fileserver()
598 set = READ_ONCE(op->estate->responsive_set); in afs_select_fileserver()
599 failed = READ_ONCE(op->estate->failed_set); in afs_select_fileserver()
600 _debug("iterate ES=%x rs=%lx fs=%lx", op->estate->probe_seq, set, failed); in afs_select_fileserver()
601 set &= ~(failed | op->addr_tried); in afs_select_fileserver()
602 trace_afs_rotate(op, afs_rotate_trace_iterate_addr, set); in afs_select_fileserver()
606 alist = op->estate->addresses; in afs_select_fileserver()
620 op->addr_index = addr_index; in afs_select_fileserver()
621 set_bit(addr_index, &op->addr_tried); in afs_select_fileserver()
623 op->volsync.creation = TIME64_MIN; in afs_select_fileserver()
624 op->volsync.update = TIME64_MIN; in afs_select_fileserver()
625 op->call_responded = false; in afs_select_fileserver()
627 op->server_index, addr_index, alist->nr_addrs, in afs_select_fileserver()
628 rxrpc_kernel_remote_addr(alist->addrs[op->addr_index].peer)); in afs_select_fileserver()
633 error = afs_wait_for_one_fs_probe(op->server, op->estate, op->addr_tried, in afs_select_fileserver()
634 !(op->flags & AFS_OPERATION_UNINTR)); in afs_select_fileserver()
643 trace_afs_rotate(op, afs_rotate_trace_probe_fileserver, 0); in afs_select_fileserver()
644 afs_probe_fileserver(op->net, op->server); in afs_select_fileserver()
645 if (op->flags & AFS_OPERATION_RETRY_SERVER) { in afs_select_fileserver()
646 error = afs_wait_for_one_fs_probe(op->server, op->estate, op->addr_tried, in afs_select_fileserver()
647 !(op->flags & AFS_OPERATION_UNINTR)); in afs_select_fileserver()
650 op->flags &= ~AFS_OPERATION_RETRY_SERVER; in afs_select_fileserver()
651 trace_afs_rotate(op, afs_rotate_trace_retry_server, 1); in afs_select_fileserver()
654 trace_afs_rotate(op, afs_rotate_trace_retry_server, 0); in afs_select_fileserver()
657 afs_op_set_error(op, error); in afs_select_fileserver()
666 trace_afs_rotate(op, afs_rotate_trace_next_server, 0); in afs_select_fileserver()
668 op->estate = NULL; in afs_select_fileserver()
675 trace_afs_rotate(op, afs_rotate_trace_no_more_servers, 0); in afs_select_fileserver()
676 if (op->flags & AFS_OPERATION_VBUSY) { in afs_select_fileserver()
677 afs_sleep_and_retry(op); in afs_select_fileserver()
678 op->flags &= ~AFS_OPERATION_VBUSY; in afs_select_fileserver()
683 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_select_fileserver()
686 estate = op->server_states[i].endpoint_state; in afs_select_fileserver()
689 afs_op_accumulate_error(op, error, estate->abort_code); in afs_select_fileserver()
694 trace_afs_rotate(op, afs_rotate_trace_failed, 0); in afs_select_fileserver()
695 op->flags |= AFS_OPERATION_STOP; in afs_select_fileserver()
696 op->estate = NULL; in afs_select_fileserver()
697 _leave(" = f [failed %d]", afs_op_error(op)); in afs_select_fileserver()
704 void afs_dump_edestaddrreq(const struct afs_operation *op) in afs_dump_edestaddrreq() argument
717 op->file[0].cb_break_before, in afs_dump_edestaddrreq()
718 op->file[1].cb_break_before, op->flags, op->cumul_error.error); in afs_dump_edestaddrreq()
720 op->untried_servers, op->server_index, op->nr_iterations); in afs_dump_edestaddrreq()
722 op->call_error, op->call_abort_code, op->call_responded); in afs_dump_edestaddrreq()
724 if (op->server_list) { in afs_dump_edestaddrreq()
725 const struct afs_server_list *sl = op->server_list; in afs_dump_edestaddrreq()
750 pr_notice("AC: t=%lx ax=%d\n", op->addr_tried, op->addr_index); in afs_dump_edestaddrreq()