Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1817352lqm; Fri, 3 May 2024 07:25:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBhHZyiZOTM9QlYLtcWHvJGsrp6bqKvD+rzpNv61WWtKBiR0C++WNYmqgf/rX/gX/coL5tVMU5UM/sVEym5v3tf0zW3209u82seh1MVA== X-Google-Smtp-Source: AGHT+IGysI4SXBzY/YNgAjg6I1Wx3h/91AdF1nD4UcWCqMHEkV+tu6deK+rYR603Koam88msn0Sg X-Received: by 2002:a05:6a00:2d97:b0:6f3:c10a:7bdd with SMTP id fb23-20020a056a002d9700b006f3c10a7bddmr2738754pfb.18.1714746302518; Fri, 03 May 2024 07:25:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714746302; cv=pass; d=google.com; s=arc-20160816; b=mI5RQSczIBd+lQetA+wkcmal/mPYc02aEZDRhEMY5uPmv9DoqA80O/RpmsEW3suubS TNGPI05bLGJZpKD2MYS4qsQZQV5C4JPT+bw9djl1ik2ePRfw/BMH5pumpHffBkWaT3IM /nWN3fb6/HlionGdGeUiFZQkucKnpCfBP2XxOqSC0gw0qP7wWnLboGk19UtqcauzBrDn gbh3w2vnrMj2idxBK9Upg1YrCoodqAHjEJ3l8ddizNPjr0PTOBcbwQJYH1v5M4txZeG9 a7BD+mHerb6lM2x/7ZQj5XhugwGbi5h4aQEhUm9VbRhKGbn2Is2ZJymIax23+15KuOiZ zvBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :from:organization:dkim-signature; bh=fdzGfOXdyJ77aM6wV3QFOsIhYI1kALNNR677cthOE1w=; fh=ceS1dE/ZrKeeuGxwGoRgEfw5mFXSLQZE1ipjUfjWmPw=; b=pZNM/rAhn71WH2uv0F9NgH4CjP14AkVICdOjXVtIelvJB2LQKTPi8WvtYN23x4tJF0 ScnDGEpQrZydDcN/m1cE0+TZBzRMJqTosiZ0ERY++3NBG+ymLpVBb7td0q37AObe6CX4 bZ+ivfSZKOYjd09sAlBPIiX1G8KVF+EB3xCp+2J/UND5kY+bzU+oWKpXqqMNaxCn/R2K RudurBZxCjcOiittINDuLdNuX80hFZ1sCtFfACSycTCixkHutSNerFx8/agXnIk+omuI BG3J4sPDJd7g11LVQxjFU6OomA7jNQJAg2LkvwgYFrr3lwFdfj+wjx66fmgU/UhOLwGW JOHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ezGhBUYp; 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-167769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167769-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 d18-20020a056a00199200b006e6cf11a823si2521089pfl.255.2024.05.03.07.25.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 07:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167769-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=ezGhBUYp; 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-167769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167769-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 274A92842FD for ; Fri, 3 May 2024 14:25:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0338E155394; Fri, 3 May 2024 14:22:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ezGhBUYp" 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 A8E54155344 for ; Fri, 3 May 2024 14:22:39 +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=1714746161; cv=none; b=CyPpohPPitgwA605P1k7AmPTSM4oYUC2AlAGvZw8w+LnZa1RqxxB/gRxloXqSAfn/s2sGscoMkyJETcxffTMUenwsSNY1oVguBsNcZitZDZNHJFLkpNrM0E/xUQ24MiyUfOHCI6uPQSkYzFtP1yDWg/Ifj1wTuq/i3WWJqu00NQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714746161; c=relaxed/simple; bh=CQuCKx1f52rBmguZ6r3kKXQ8Q8tgOq7dYH9ndvPdeg8=; h=From:To:cc:Subject:MIME-Version:Content-Type:Date:Message-ID; b=Ay0FEQU1MWECdWFCLV1sHnoiN1iG9BqvG0PsAkxGSAdXhU2XIiFnAXUqTMMigfaFoY9/dIz+IqS9gMgWHHAFZAu/EVtSXDKVoRtWd3A9UNXQSnTXvidQgu49c6Pp49WuFG8K5VUawvf+xDt98MCnxednVS8rqg884f/1XaLLkxQ= 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=ezGhBUYp; 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=1714746158; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fdzGfOXdyJ77aM6wV3QFOsIhYI1kALNNR677cthOE1w=; b=ezGhBUYpaDBGHutTpPMw6OrDeZaoPsrrusA/f57vjwpmtVsRmfwrhdXwqCHN/9WCHKcmh2 EXszFoAv3imytjIEIzILgwQMBfzKvIUWhwDB2Tv4keuKWR1v6C4Jmu8wU7LsmQUH7iouaI dq40NFAej1eByy4cQ6YbIETI7Oe/GsE= 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-251--q8-pTE7PZah1LJSYg3Xsg-1; Fri, 03 May 2024 10:22:34 -0400 X-MC-Unique: -q8-pTE7PZah1LJSYg3Xsg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 204AF28EC11E; Fri, 3 May 2024 14:22:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5558840F5F8; Fri, 3 May 2024 14:22:33 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Christian Brauner cc: dhowells@redhat.com, Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] afs: Fix fileserver rotation getting stuck Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <998835.1714746152.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 03 May 2024 15:22:32 +0100 Message-ID: <998836.1714746152@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Hi Christian, Could you pick this up, please? David --- afs: Fix fileserver rotation getting stuck Fix the fileserver rotation code in a couple of ways: (1) op->server_states is an array, not a pointer to a single record, so fix the places that access it to index it. (2) In the places that go through an address list to work out which one has the best priority, fix the loops to skip known failed addresses. Without this, the rotation algorithm may get stuck on addresses that are inaccessible or don't respond. This can be triggered manually by finding a server that advertises a non-routable address and giving it a higher priority, eg.: echo "add udp 192.168.0.0/16 3000" >/proc/fs/afs/addr_prefs if the server, say, includes the address 192.168.7.7 in its address list, and then attempting to access a volume on that server. Fixes: 495f2ae9e355 ("afs: Fix fileserver rotation") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/4005300.1712309731@warthog.procyon.org.uk/= # v1 --- Changes =3D=3D=3D=3D=3D=3D=3D ver #2) - Use the untried address set precomputed in the 'set' variable. fs/afs/rotate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/afs/rotate.c b/fs/afs/rotate.c index ed04bd1eeae8..ed09d4d4c211 100644 --- a/fs/afs/rotate.c +++ b/fs/afs/rotate.c @@ -541,11 +541,13 @@ bool afs_select_fileserver(struct afs_operation *op) test_bit(AFS_SE_EXCLUDED, &se->flags) || !test_bit(AFS_SERVER_FL_RESPONDING, &s->flags)) continue; - es =3D op->server_states->endpoint_state; + es =3D op->server_states[i].endpoint_state; sal =3D es->addresses; = afs_get_address_preferences_rcu(op->net, sal); for (j =3D 0; j < sal->nr_addrs; j++) { + if (es->failed_set & (1 << j)) + continue; if (!sal->addrs[j].peer) continue; if (sal->addrs[j].prio > best_prio) { @@ -605,6 +607,8 @@ bool afs_select_fileserver(struct afs_operation *op) best_prio =3D -1; addr_index =3D 0; for (i =3D 0; i < alist->nr_addrs; i++) { + if (!(set & (1 << i))) + continue; if (alist->addrs[i].prio > best_prio) { addr_index =3D i; best_prio =3D alist->addrs[i].prio; @@ -674,7 +678,7 @@ bool afs_select_fileserver(struct afs_operation *op) for (i =3D 0; i < op->server_list->nr_servers; i++) { struct afs_endpoint_state *estate; = - estate =3D op->server_states->endpoint_state; + estate =3D op->server_states[i].endpoint_state; error =3D READ_ONCE(estate->error); if (error < 0) afs_op_accumulate_error(op, error, estate->abort_code);