From nobody Mon Feb 9 01:18:21 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BBE0C77B73 for ; Tue, 2 May 2023 16:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234296AbjEBQhq (ORCPT ); Tue, 2 May 2023 12:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234364AbjEBQhS (ORCPT ); Tue, 2 May 2023 12:37:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C20484222 for ; Tue, 2 May 2023 09:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683045343; 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=CZoekTna0zWXws8EaTSEoCtu55gwMy5uNJXIGmQIy0w=; b=dAAh1kWhrDuanGZJQvwD1dIbOP18YmGjEU54b//kMloX73Rx65z0iQxdtFyXAXrotmo5yO GdcxHXO6E0llMjie/GyfHlgsFR01uAqlz+/rLy8SiJ40arOtcsnY6C4JLEirDe/ZXGxnBB kwKs40k3ptn65XRdNiFDb959NEZZFeY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-NezWOwQXMZa1ygaArBVR1g-1; Tue, 02 May 2023 12:35:41 -0400 X-MC-Unique: NezWOwQXMZa1ygaArBVR1g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 429371C0432C; Tue, 2 May 2023 16:35:41 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 346DA2166B26; Tue, 2 May 2023 16:35:40 +0000 (UTC) From: David Howells To: Linus Torvalds Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] afs: Avoid endless loop if file is larger than expected Date: Tue, 2 May 2023 17:35:28 +0100 Message-Id: <20230502163528.1564398-4-dhowells@redhat.com> In-Reply-To: <20230502163528.1564398-1-dhowells@redhat.com> References: <20230502163528.1564398-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marc Dionne afs_read_dir fetches an amount of data that's based on what the inode size is thought to be. If the file on the server is larger than what was fetched, the code rechecks i_size and retries. If the local i_size was not properly updated, this can lead to an endless loop of fetching i_size from the server and noticing each time that the size is larger on the server. If it is known that the remote size is larger than i_size, bump up the fetch size to that size. Fixes: f3ddee8dc4e2 ("afs: Fix directory handling") Signed-off-by: Marc Dionne Signed-off-by: David Howells cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index f92b9e62d567..4dd97afa536c 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -275,6 +275,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *= dvnode, struct key *key) loff_t i_size; int nr_pages, i; int ret; + loff_t remote_size =3D 0; =20 _enter(""); =20 @@ -289,6 +290,8 @@ static struct afs_read *afs_read_dir(struct afs_vnode *= dvnode, struct key *key) =20 expand: i_size =3D i_size_read(&dvnode->netfs.inode); + if (i_size < remote_size) + i_size =3D remote_size; if (i_size < 2048) { ret =3D afs_bad(dvnode, afs_file_error_dir_small); goto error; @@ -364,6 +367,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *= dvnode, struct key *key) * buffer. */ up_write(&dvnode->validate_lock); + remote_size =3D req->file_size; goto expand; }