Lines Matching refs:op
21 static bool afs_start_fs_iteration(struct afs_operation *op, in afs_start_fs_iteration() argument
28 read_lock(&op->volume->servers_lock); in afs_start_fs_iteration()
29 op->server_list = afs_get_serverlist( in afs_start_fs_iteration()
30 rcu_dereference_protected(op->volume->servers, in afs_start_fs_iteration()
31 lockdep_is_held(&op->volume->servers_lock))); in afs_start_fs_iteration()
32 read_unlock(&op->volume->servers_lock); in afs_start_fs_iteration()
34 op->untried = (1UL << op->server_list->nr_servers) - 1; in afs_start_fs_iteration()
35 op->index = READ_ONCE(op->server_list->preferred); in afs_start_fs_iteration()
40 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_start_fs_iteration()
41 server = op->server_list->servers[i].server; in afs_start_fs_iteration()
43 op->index = i; in afs_start_fs_iteration()
52 if (op->flags & AFS_OPERATION_CUR_ONLY) { in afs_start_fs_iteration()
53 op->error = -ESTALE; in afs_start_fs_iteration()
90 static bool afs_sleep_and_retry(struct afs_operation *op) in afs_sleep_and_retry() argument
92 if (!(op->flags & AFS_OPERATION_UNINTR)) { in afs_sleep_and_retry()
95 op->error = -ERESTARTSYS; in afs_sleep_and_retry()
109 bool afs_select_fileserver(struct afs_operation *op) in afs_select_fileserver() argument
113 struct afs_vnode *vnode = op->file[0].vnode; in afs_select_fileserver()
116 int error = op->ac.error, i; in afs_select_fileserver()
119 op->untried, op->index, in afs_select_fileserver()
120 op->ac.tried, op->ac.index, in afs_select_fileserver()
121 error, op->ac.abort_code); in afs_select_fileserver()
123 if (op->flags & AFS_OPERATION_STOP) { in afs_select_fileserver()
128 op->nr_iterations++; in afs_select_fileserver()
138 op->error = error; in afs_select_fileserver()
139 op->flags |= AFS_OPERATION_STOP; in afs_select_fileserver()
147 switch (op->ac.abort_code) { in afs_select_fileserver()
154 if (op->flags & AFS_OPERATION_VNOVOL) { in afs_select_fileserver()
155 op->error = -EREMOTEIO; in afs_select_fileserver()
159 write_lock(&op->volume->servers_lock); in afs_select_fileserver()
160 op->server_list->vnovol_mask |= 1 << op->index; in afs_select_fileserver()
161 write_unlock(&op->volume->servers_lock); in afs_select_fileserver()
163 set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags); in afs_select_fileserver()
164 error = afs_check_volume_status(op->volume, op); in afs_select_fileserver()
168 if (test_bit(AFS_VOLUME_DELETED, &op->volume->flags)) { in afs_select_fileserver()
169 op->error = -ENOMEDIUM; in afs_select_fileserver()
176 if (rcu_access_pointer(op->volume->servers) == op->server_list) { in afs_select_fileserver()
177 op->error = -EREMOTEIO; in afs_select_fileserver()
182 op->flags |= AFS_OPERATION_VNOVOL; in afs_select_fileserver()
192 op->error = afs_abort_to_error(op->ac.abort_code); in afs_select_fileserver()
196 if (!test_and_set_bit(AFS_VOLUME_OFFLINE, &op->volume->flags)) { in afs_select_fileserver()
197 afs_busy(op->volume, op->ac.abort_code); in afs_select_fileserver()
198 clear_bit(AFS_VOLUME_BUSY, &op->volume->flags); in afs_select_fileserver()
200 if (op->flags & AFS_OPERATION_NO_VSLEEP) { in afs_select_fileserver()
201 op->error = -EADV; in afs_select_fileserver()
204 if (op->flags & AFS_OPERATION_CUR_ONLY) { in afs_select_fileserver()
205 op->error = -ESTALE; in afs_select_fileserver()
216 if (op->flags & AFS_OPERATION_NO_VSLEEP) { in afs_select_fileserver()
217 op->error = -EBUSY; in afs_select_fileserver()
220 if (!test_and_set_bit(AFS_VOLUME_BUSY, &op->volume->flags)) { in afs_select_fileserver()
221 afs_busy(op->volume, op->ac.abort_code); in afs_select_fileserver()
222 clear_bit(AFS_VOLUME_OFFLINE, &op->volume->flags); in afs_select_fileserver()
225 if (op->flags & AFS_OPERATION_CUR_ONLY) { in afs_select_fileserver()
226 if (!afs_sleep_and_retry(op)) in afs_select_fileserver()
234 op->flags |= AFS_OPERATION_VBUSY; in afs_select_fileserver()
245 if (op->flags & AFS_OPERATION_VMOVED) { in afs_select_fileserver()
246 op->error = -EREMOTEIO; in afs_select_fileserver()
249 op->flags |= AFS_OPERATION_VMOVED; in afs_select_fileserver()
251 set_bit(AFS_VOLUME_WAIT, &op->volume->flags); in afs_select_fileserver()
252 set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags); in afs_select_fileserver()
253 error = afs_check_volume_status(op->volume, op); in afs_select_fileserver()
266 if (rcu_access_pointer(op->volume->servers) == op->server_list) { in afs_select_fileserver()
267 op->error = -ENOMEDIUM; in afs_select_fileserver()
274 clear_bit(AFS_VOLUME_OFFLINE, &op->volume->flags); in afs_select_fileserver()
275 clear_bit(AFS_VOLUME_BUSY, &op->volume->flags); in afs_select_fileserver()
276 op->error = afs_abort_to_error(op->ac.abort_code); in afs_select_fileserver()
282 if (op->error != -EDESTADDRREQ) in afs_select_fileserver()
292 op->error = error; in afs_select_fileserver()
297 op->type ? op->type->name : "???", op->debug_id); in afs_select_fileserver()
301 op->error = error; in afs_select_fileserver()
307 afs_end_cursor(&op->ac); in afs_select_fileserver()
308 op->server = NULL; in afs_select_fileserver()
309 afs_put_serverlist(op->net, op->server_list); in afs_select_fileserver()
310 op->server_list = NULL; in afs_select_fileserver()
316 error = afs_check_volume_status(op->volume, op); in afs_select_fileserver()
320 if (!afs_start_fs_iteration(op, vnode)) in afs_select_fileserver()
323 _debug("__ VOL %llx __", op->volume->vid); in afs_select_fileserver()
326 _debug("pick [%lx]", op->untried); in afs_select_fileserver()
328 error = afs_wait_for_fs_probes(op->server_list, op->untried); in afs_select_fileserver()
335 if (op->server) { in afs_select_fileserver()
336 _debug("server %u", op->index); in afs_select_fileserver()
337 if (test_bit(op->index, &op->untried)) in afs_select_fileserver()
339 op->server = NULL; in afs_select_fileserver()
343 op->index = -1; in afs_select_fileserver()
345 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_select_fileserver()
346 struct afs_server *s = op->server_list->servers[i].server; in afs_select_fileserver()
348 if (!test_bit(i, &op->untried) || in afs_select_fileserver()
352 op->index = i; in afs_select_fileserver()
357 if (op->index == -1) in afs_select_fileserver()
361 _debug("use %d", op->index); in afs_select_fileserver()
362 __clear_bit(op->index, &op->untried); in afs_select_fileserver()
368 ASSERTCMP(op->ac.alist, ==, NULL); in afs_select_fileserver()
369 server = op->server_list->servers[op->index].server; in afs_select_fileserver()
371 if (!afs_check_server_record(op, server)) in afs_select_fileserver()
376 op->flags |= AFS_OPERATION_RETRY_SERVER; in afs_select_fileserver()
377 op->server = server; in afs_select_fileserver()
393 memset(&op->ac, 0, sizeof(op->ac)); in afs_select_fileserver()
395 if (!op->ac.alist) in afs_select_fileserver()
396 op->ac.alist = alist; in afs_select_fileserver()
400 op->ac.index = -1; in afs_select_fileserver()
403 ASSERT(op->ac.alist); in afs_select_fileserver()
407 if (!afs_iterate_addresses(&op->ac)) in afs_select_fileserver()
411 op->index, op->ac.index, op->ac.alist->nr_addrs, in afs_select_fileserver()
412 &op->ac.alist->addrs[op->ac.index].transport); in afs_select_fileserver()
421 afs_probe_fileserver(op->net, op->server); in afs_select_fileserver()
422 if (op->flags & AFS_OPERATION_RETRY_SERVER) { in afs_select_fileserver()
423 alist = op->ac.alist; in afs_select_fileserver()
425 op->server, !(op->flags & AFS_OPERATION_UNINTR)); in afs_select_fileserver()
428 op->flags &= ~AFS_OPERATION_RETRY_SERVER; in afs_select_fileserver()
440 afs_end_cursor(&op->ac); in afs_select_fileserver()
447 if (op->flags & AFS_OPERATION_VBUSY) in afs_select_fileserver()
452 for (i = 0; i < op->server_list->nr_servers; i++) { in afs_select_fileserver()
453 struct afs_server *s = op->server_list->servers[i].server; in afs_select_fileserver()
462 op->error = error; in afs_select_fileserver()
464 op->flags |= AFS_OPERATION_STOP; in afs_select_fileserver()
465 afs_end_cursor(&op->ac); in afs_select_fileserver()
466 _leave(" = f [failed %d]", op->error); in afs_select_fileserver()
473 void afs_dump_edestaddrreq(const struct afs_operation *op) in afs_dump_edestaddrreq() argument
486 op->file[0].cb_break_before, in afs_dump_edestaddrreq()
487 op->file[1].cb_break_before, op->flags, op->error); in afs_dump_edestaddrreq()
489 op->untried, op->index, op->nr_iterations); in afs_dump_edestaddrreq()
491 if (op->server_list) { in afs_dump_edestaddrreq()
492 const struct afs_server_list *sl = op->server_list; in afs_dump_edestaddrreq()
508 if (a == op->ac.alist) in afs_dump_edestaddrreq()
515 op->ac.tried, op->ac.index, op->ac.abort_code, op->ac.error, in afs_dump_edestaddrreq()
516 op->ac.responded, op->ac.nr_iterations); in afs_dump_edestaddrreq()