From patchwork Mon Sep 23 15:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13809703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 514B1CF9C6F for ; Mon, 23 Sep 2024 15:08:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D32906B0093; Mon, 23 Sep 2024 11:08:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE2986B0095; Mon, 23 Sep 2024 11:08:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAA416B0096; Mon, 23 Sep 2024 11:08:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9A75C6B0093 for ; Mon, 23 Sep 2024 11:08:48 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5C051A130E for ; Mon, 23 Sep 2024 15:08:48 +0000 (UTC) X-FDA: 82596335136.26.04325CA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 88CF48000F for ; Mon, 23 Sep 2024 15:08:46 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M6Pu8LUS; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727104008; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3lKiHWTaBx3zx8IjGF1i+IbwHetAMo/Hx9i4LC4nBI4=; b=UqOV56ZCqdZ1+PZqjswKc49nN0dZRBzGgh6zh3ilj60InsHtmCvWG6skyunNvtjT8yb80Z XcOYVnmsoaVNChlm5Mm/Ds+iUwGkxpwWHinuYvq7POLzX3PvkGR+d/kvXiOsDzXx5FRr0B 4dFWPJoIBFVE3AAo8RGjkjLTurcXjjs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727104008; a=rsa-sha256; cv=none; b=JF0zG7MAtoyqu1+sPhsTVbYVnMfQB8c2HRAoNy69tLsdMtLfOd7jce+eyJII9So6YQVOSM mO3woyavkA2fyD7DYvAn04vELw3LB30u1eDiKJsBuMEdp+WfosgCSsM1oyrsG0RRFz9Tjk vp9jQWVsMo+un6iIKEqzMbTYOuffkVo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M6Pu8LUS; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727104125; 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=3lKiHWTaBx3zx8IjGF1i+IbwHetAMo/Hx9i4LC4nBI4=; b=M6Pu8LUS4dpTizbo8NZhOHTAYwuGlZRWIQ5KyIFerAV17DD/Oc27sDcBPRXz4SkH4xhgcj zMU/20AnyHKHSFLeSUjtDZoWgI26mhZw4VQy91p2TMeJ83hi1bs7s5UgBh3iIbmjknzRoJ ZyZGMh3Q2KCtie38V2rXCx10RkzXLas= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-Odl9lH7FPeeRz2-0q0JfvA-1; Mon, 23 Sep 2024 11:08:42 -0400 X-MC-Unique: Odl9lH7FPeeRz2-0q0JfvA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.17]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 059CD18BC605; Mon, 23 Sep 2024 15:08:40 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.145]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 51FD51977026; Mon, 23 Sep 2024 15:08:31 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Marc Dionne Cc: David Howells , Paulo Alcantara , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Markus Suvanto Subject: [PATCH 5/8] afs: Fix possible infinite loop with unresponsive servers Date: Mon, 23 Sep 2024 16:07:49 +0100 Message-ID: <20240923150756.902363-6-dhowells@redhat.com> In-Reply-To: <20240923150756.902363-1-dhowells@redhat.com> References: <20240923150756.902363-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDef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dl+oqd2J/b6i3lB29sa6dAq2653uvS1tR0VgN0/tS+Fw eTyjGlGc t4hxq45LPOJHvtLUHiZy8MwoVEWjcJgMRmel9CzQqApB4TjlisXArnAHHOqCUGJkVI6ocHr1ngGGycrPhSHNZ+g6DvtGP9vKjM1do5OfsKuI4Sl9LwrvOjkIZTo9UKuIbSODfm3J+o3l1n0YutIYgSjlEo1BSRVNj2+sgj+m+rGjl9k4Jt4Ch88jFXsR2fBCVigb69Lb6qnkfKNp+BNt8GrFvedVNGre3xTBhixzuYkGdFNA952g9JbUjpfsXgQTjFVfoYvUnm1HB9Sl77CPCGFBvwCMW9ci7flyf4FH7kRLC6+mNND9wb897OulyzExl+HUDqu1Fvb5tfu3wKWCwnq9K4QcYKBce6AHCZfQW5xLkmkvYvHoqOR9aCTce10ubhzwuszku7ZNw3LZ1mLwKBpJgDIqhkkm0Tr95YfQLxbJEKjUY85Igcn7ZZ3DVvAeFc5Tap+JrfDyNWy1CbPsA5xQKVKqpK5MmUAY/TLL57UZXHzTq7QwosBpWDZNnG1pt+W7dM82ttxDPWLUfQHHQfZfUSiKX+RxzQ1oac1dyAohiIe1YUL8l2Ob9XQ+4bj3+q4dl1/xoh71iekM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Marc Dionne A return code of 0 from afs_wait_for_one_fs_probe is an indication that the endpoint state attached to the operation is stale and has been superseded. In that case the iteration needs to be restarted so that the newer probe result state gets used. Failure to do so can result in an tight infinite loop around the iterate_address label, where all addresses are thought to be responsive and have been tried, with nothing to refresh the endpoint state. Fixes: 495f2ae9e355 ("afs: Fix fileserver rotation") Reported-by: Markus Suvanto Link: https://lists.infradead.org/pipermail/linux-afs/2024-July/008628.html cc: linux-afs@lists.infradead.org Signed-off-by: Marc Dionne Signed-off-by: David Howells Link: https://lore.kernel.org/r/20240906134019.131553-1-marc.dionne@auristor.com/ --- fs/afs/fs_probe.c | 4 ++-- fs/afs/rotate.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/afs/fs_probe.c b/fs/afs/fs_probe.c index 580de4adaaf6..b516d05b0fef 100644 --- a/fs/afs/fs_probe.c +++ b/fs/afs/fs_probe.c @@ -506,10 +506,10 @@ int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_sta finish_wait(&server->probe_wq, &wait); dont_wait: - if (estate->responsive_set & ~exclude) - return 1; if (test_bit(AFS_ESTATE_SUPERSEDED, &estate->flags)) return 0; + if (estate->responsive_set & ~exclude) + return 1; if (is_intr && signal_pending(current)) return -ERESTARTSYS; if (timo == 0) diff --git a/fs/afs/rotate.c b/fs/afs/rotate.c index ed09d4d4c211..d612983d6f38 100644 --- a/fs/afs/rotate.c +++ b/fs/afs/rotate.c @@ -632,8 +632,10 @@ bool afs_select_fileserver(struct afs_operation *op) wait_for_more_probe_results: error = afs_wait_for_one_fs_probe(op->server, op->estate, op->addr_tried, !(op->flags & AFS_OPERATION_UNINTR)); - if (!error) + if (error == 1) goto iterate_address; + if (!error) + goto restart_from_beginning; /* We've now had a failure to respond on all of a server's addresses - * immediately probe them again and consider retrying the server. @@ -644,10 +646,13 @@ bool afs_select_fileserver(struct afs_operation *op) error = afs_wait_for_one_fs_probe(op->server, op->estate, op->addr_tried, !(op->flags & AFS_OPERATION_UNINTR)); switch (error) { - case 0: + case 1: op->flags &= ~AFS_OPERATION_RETRY_SERVER; - trace_afs_rotate(op, afs_rotate_trace_retry_server, 0); + trace_afs_rotate(op, afs_rotate_trace_retry_server, 1); goto retry_server; + case 0: + trace_afs_rotate(op, afs_rotate_trace_retry_server, 0); + goto restart_from_beginning; case -ERESTARTSYS: afs_op_set_error(op, error); goto failed;