Skip to content

Commit 83505bd

Browse files
dhowellsbrauner
authored andcommitted
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: 495f2ae ("afs: Fix fileserver rotation") Signed-off-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/r/20240313081505.3060173-2-dhowells@redhat.com Reviewed-by: Marc Dionne <marc.dionne@auristor.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 0aec384 commit 83505bd

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

fs/afs/rotate.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,16 @@ bool afs_select_fileserver(struct afs_operation *op)
602602
goto wait_for_more_probe_results;
603603

604604
alist = op->estate->addresses;
605+
best_prio = -1;
606+
addr_index = 0;
605607
for (i = 0; i < alist->nr_addrs; i++) {
606608
if (alist->addrs[i].prio > best_prio) {
607609
addr_index = i;
608610
best_prio = alist->addrs[i].prio;
609611
}
610612
}
611613

612-
addr_index = READ_ONCE(alist->preferred);
613-
if (!test_bit(addr_index, &set))
614-
addr_index = __ffs(set);
614+
alist->preferred = addr_index;
615615

616616
op->addr_index = addr_index;
617617
set_bit(addr_index, &op->addr_tried);
@@ -656,12 +656,6 @@ bool afs_select_fileserver(struct afs_operation *op)
656656
next_server:
657657
trace_afs_rotate(op, afs_rotate_trace_next_server, 0);
658658
_debug("next");
659-
ASSERT(op->estate);
660-
alist = op->estate->addresses;
661-
if (op->call_responded &&
662-
op->addr_index != READ_ONCE(alist->preferred) &&
663-
test_bit(alist->preferred, &op->addr_tried))
664-
WRITE_ONCE(alist->preferred, op->addr_index);
665659
op->estate = NULL;
666660
goto pick_server;
667661

@@ -690,14 +684,7 @@ bool afs_select_fileserver(struct afs_operation *op)
690684
failed:
691685
trace_afs_rotate(op, afs_rotate_trace_failed, 0);
692686
op->flags |= AFS_OPERATION_STOP;
693-
if (op->estate) {
694-
alist = op->estate->addresses;
695-
if (op->call_responded &&
696-
op->addr_index != READ_ONCE(alist->preferred) &&
697-
test_bit(alist->preferred, &op->addr_tried))
698-
WRITE_ONCE(alist->preferred, op->addr_index);
699-
op->estate = NULL;
700-
}
687+
op->estate = NULL;
701688
_leave(" = f [failed %d]", afs_op_error(op));
702689
return false;
703690
}

0 commit comments

Comments
 (0)