Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1561711lql; Wed, 13 Mar 2024 01:16:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlncKaW67rnOXYDgEbAzE/7wDQ6I5h432dMjN31crUVLhp1zsZjNHg3aJQDnbzUzLX3DbJk3lkCBbDBMFH3Y44/nT2/wnz3m9DkqvADw== X-Google-Smtp-Source: AGHT+IFVWF2VRkpHSvnG5SzmD1op+70kQm0aHm2KYBV705uNfWM8BjchV+DjOMms37X/IftVWzk4 X-Received: by 2002:a05:6a20:9386:b0:1a3:3399:dd2a with SMTP id x6-20020a056a20938600b001a33399dd2amr894705pzh.18.1710317762007; Wed, 13 Mar 2024 01:16:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710317761; cv=pass; d=google.com; s=arc-20160816; b=jzU399yV6m0yJbTQAl73oy3hdj+gfJWUs2sH8IEb3l4fUYq/UtJfgtcJwf9DPluzdg 14f38mtgoscXHSx75Pr0DJpbG6BmsCXuJXrQsMjjjQtv8M0lOAxMpnVoCwP4f+RrIR12 VQ+w3UsxMcD4wRmh+xtw2/+FwPoR4ths4eQsXCO2i3H5hDwJmnPbhJtV5e8/ygZXhSDb l92fc+zy7wBNWOcFw0K3Fzbzz/1Qiz+71I9sBDD10ZPmOzvrLyOsYGozqKjt6mY+asXi 3XxbTRyWtpSzUE8nL9gbJYczvcsfoGgW8SEll5m6gkt2PjZh7jU+mdqfCK8gcqIb9epG kQ4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WGiwFYhlQwAkAcK9KSYTrO5XDHNnn5GT+CKnu+I/Sm8=; fh=q5b0b12/c9B3HD3t3caNNmAFy1LNWNeL+ritg8twD4Y=; b=B9BLuX9XPaNdWJ9QT0VkxteiIFKoYJJX1mEyLPU/uDAKYAeGzlaLu8pzj8gtnHAYoF gsQ5A+2ofmTHbuD39CqCKB3ye0ieN4jnTWtpWBzjFJGJRybbnzixoqow1flLMwux1Czw WQVGDu1m++EJGchfPgWkWeVyLG8s/9RGhL+HD/5Ot5EgE/NiMYFwpoN4HPXjK9LzLkdb H84CeDahxFZSMZh7m8LOgm7l9C1U0qM+ZWsEBjID5dWRCiGSfl5mnLxqrZuEOMJJBDna L8zCkfdfXpticgq1Yh30E3PSIa58DXfNg/fvrtERgEktlQZmZaT0EYfW5CA3g2uRhQZL UsgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CtjPHJex; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-101206-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u14-20020a63454e000000b005dc36761ae8si8343666pgk.351.2024.03.13.01.16.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 01:16:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101206-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CtjPHJex; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-101206-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AA919282D0D for ; Wed, 13 Mar 2024 08:16:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 125A822071; Wed, 13 Mar 2024 08:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CtjPHJex" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7CDF1CA80 for ; Wed, 13 Mar 2024 08:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710317718; cv=none; b=OYvsvUaqiiDEpfW1/A0/tOoUfgQM1HyWRGFZ0EdR5zKzwJ0nIbsXcF1h92xN/ZYCthS+efyZ8Aol1xc05X/oRrCf+Q7CfpAXq0jRGGfHX3gOcDsBVWtGRhoAjmMyn0tuAiPnPzL83qBvOp8a4ehvfOFkpVVDXqXsqBPSi2flXQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710317718; c=relaxed/simple; bh=nEffeaEkUXeL9ZZoT5q8k9bvL4SIKdrRskLsclcByxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G4qA08MhD3R0tIdWuzr3GyHGeFMSoPhpXlPoTyFXpKv9qwkUD8iEfU4g/RgVM0u5BOxWuPf5zYtWTQTydzY/t48So0BBBJEhbJJiefpJ+edohQWKirlEgbB+HlSP29zXqTDUUbPO9o2XSEzBlrbdNDLkjnRFY2qt+V4Ohaw4Yo8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CtjPHJex; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710317715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WGiwFYhlQwAkAcK9KSYTrO5XDHNnn5GT+CKnu+I/Sm8=; b=CtjPHJexmYAGl4DLY6uhsXmWYBcT8sqS3SUAP7/F1RYeY6+2C4eRjcn+Ld6Pq2638jS6Sr zB2rEcYCeVJITRDlzYMLOldYE1ncKA7nLwLR580e60yUP+0ep2S+VYUWmpUjoFHvMrZRy3 07+c57KGyh4WwiOinUKIRVsKgMVEIb0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-iPBGcg6VMCGu5FCxtsf5cQ-1; Wed, 13 Mar 2024 04:15:10 -0400 X-MC-Unique: iPBGcg6VMCGu5FCxtsf5cQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06070380390D; Wed, 13 Mar 2024 08:15:10 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 310F53C23; Wed, 13 Mar 2024 08:15:09 +0000 (UTC) From: David Howells To: Marc Dionne Cc: David Howells , Christian Brauner , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] afs: Don't cache preferred address Date: Wed, 13 Mar 2024 08:15:02 +0000 Message-ID: <20240313081505.3060173-2-dhowells@redhat.com> In-Reply-To: <20240313081505.3060173-1-dhowells@redhat.com> References: <20240313081505.3060173-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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: 495f2ae9e355 ("afs: Fix fileserver rotation") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/rotate.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/fs/afs/rotate.c b/fs/afs/rotate.c index 700a27bc8c25..ed04bd1eeae8 100644 --- a/fs/afs/rotate.c +++ b/fs/afs/rotate.c @@ -602,6 +602,8 @@ bool afs_select_fileserver(struct afs_operation *op) goto wait_for_more_probe_results; alist = op->estate->addresses; + best_prio = -1; + addr_index = 0; for (i = 0; i < alist->nr_addrs; i++) { if (alist->addrs[i].prio > best_prio) { addr_index = i; @@ -609,9 +611,7 @@ bool afs_select_fileserver(struct afs_operation *op) } } - addr_index = READ_ONCE(alist->preferred); - if (!test_bit(addr_index, &set)) - addr_index = __ffs(set); + alist->preferred = addr_index; op->addr_index = addr_index; set_bit(addr_index, &op->addr_tried); @@ -656,12 +656,6 @@ bool afs_select_fileserver(struct afs_operation *op) next_server: trace_afs_rotate(op, afs_rotate_trace_next_server, 0); _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; goto pick_server; @@ -690,14 +684,7 @@ bool afs_select_fileserver(struct afs_operation *op) failed: trace_afs_rotate(op, afs_rotate_trace_failed, 0); op->flags |= AFS_OPERATION_STOP; - if (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; _leave(" = f [failed %d]", afs_op_error(op)); return false; }