Commit 83505bde authored by David Howells's avatar David Howells Committed by Christian Brauner

afs: Don't cache preferred address

In the AFS fileserver rotation algorithm, don't cache the preferred address
for the server as that will override the explicit preference if a
non-preferred address responds first.

Fixes: 495f2ae9 ("afs: Fix fileserver rotation")
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20240313081505.3060173-2-dhowells@redhat.comReviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 0aec3847
...@@ -602,6 +602,8 @@ bool afs_select_fileserver(struct afs_operation *op) ...@@ -602,6 +602,8 @@ bool afs_select_fileserver(struct afs_operation *op)
goto wait_for_more_probe_results; goto wait_for_more_probe_results;
alist = op->estate->addresses; alist = op->estate->addresses;
best_prio = -1;
addr_index = 0;
for (i = 0; i < alist->nr_addrs; i++) { for (i = 0; i < alist->nr_addrs; i++) {
if (alist->addrs[i].prio > best_prio) { if (alist->addrs[i].prio > best_prio) {
addr_index = i; addr_index = i;
...@@ -609,9 +611,7 @@ bool afs_select_fileserver(struct afs_operation *op) ...@@ -609,9 +611,7 @@ bool afs_select_fileserver(struct afs_operation *op)
} }
} }
addr_index = READ_ONCE(alist->preferred); alist->preferred = addr_index;
if (!test_bit(addr_index, &set))
addr_index = __ffs(set);
op->addr_index = addr_index; op->addr_index = addr_index;
set_bit(addr_index, &op->addr_tried); set_bit(addr_index, &op->addr_tried);
...@@ -656,12 +656,6 @@ bool afs_select_fileserver(struct afs_operation *op) ...@@ -656,12 +656,6 @@ bool afs_select_fileserver(struct afs_operation *op)
next_server: next_server:
trace_afs_rotate(op, afs_rotate_trace_next_server, 0); trace_afs_rotate(op, afs_rotate_trace_next_server, 0);
_debug("next"); _debug("next");
ASSERT(op->estate);
alist = op->estate->addresses;
if (op->call_responded &&
op->addr_index != READ_ONCE(alist->preferred) &&
test_bit(alist->preferred, &op->addr_tried))
WRITE_ONCE(alist->preferred, op->addr_index);
op->estate = NULL; op->estate = NULL;
goto pick_server; goto pick_server;
...@@ -690,14 +684,7 @@ bool afs_select_fileserver(struct afs_operation *op) ...@@ -690,14 +684,7 @@ bool afs_select_fileserver(struct afs_operation *op)
failed: failed:
trace_afs_rotate(op, afs_rotate_trace_failed, 0); trace_afs_rotate(op, afs_rotate_trace_failed, 0);
op->flags |= AFS_OPERATION_STOP; op->flags |= AFS_OPERATION_STOP;
if (op->estate) { op->estate = NULL;
alist = op->estate->addresses;
if (op->call_responded &&
op->addr_index != READ_ONCE(alist->preferred) &&
test_bit(alist->preferred, &op->addr_tried))
WRITE_ONCE(alist->preferred, op->addr_index);
op->estate = NULL;
}
_leave(" = f [failed %d]", afs_op_error(op)); _leave(" = f [failed %d]", afs_op_error(op));
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment