Skip to content

Commit

Permalink
afs: Rearrange afs_select_fileserver() a little
Browse files Browse the repository at this point in the history
Rearrange afs_select_fileserver() a little to put the use_server chunk
before the next_server chunk so that with the removal of a couple of gotos
the main path through the function is all one sequence.

Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Feb 6, 2018
1 parent 63dc4e4 commit 16280a1
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions fs/afs/rotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,27 +330,6 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc)

if (!afs_start_fs_iteration(fc, vnode))
goto failed;
goto use_server;

next_server:
_debug("next");
afs_end_cursor(&fc->ac);
afs_put_cb_interest(afs_v2net(vnode), fc->cbi);
fc->cbi = NULL;
fc->index++;
if (fc->index >= fc->server_list->nr_servers)
fc->index = 0;
if (fc->index != fc->start)
goto use_server;

/* That's all the servers poked to no good effect. Try again if some
* of them were busy.
*/
if (fc->flags & AFS_FS_CURSOR_VBUSY)
goto restart_from_beginning;

fc->ac.error = -EDESTADDRREQ;
goto failed;

use_server:
_debug("use");
Expand Down Expand Up @@ -401,7 +380,6 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc)

fc->ac.start = READ_ONCE(alist->index);
fc->ac.index = fc->ac.start;
goto iterate_address;

iterate_address:
ASSERT(fc->ac.alist);
Expand All @@ -415,6 +393,26 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc)
_leave(" = t");
return true;

next_server:
_debug("next");
afs_end_cursor(&fc->ac);
afs_put_cb_interest(afs_v2net(vnode), fc->cbi);
fc->cbi = NULL;
fc->index++;
if (fc->index >= fc->server_list->nr_servers)
fc->index = 0;
if (fc->index != fc->start)
goto use_server;

/* That's all the servers poked to no good effect. Try again if some
* of them were busy.
*/
if (fc->flags & AFS_FS_CURSOR_VBUSY)
goto restart_from_beginning;

fc->ac.error = -EDESTADDRREQ;
goto failed;

failed:
fc->flags |= AFS_FS_CURSOR_STOP;
afs_end_cursor(&fc->ac);
Expand Down

0 comments on commit 16280a1

Please sign in to comment.