afs: Avoid endless loop if file is larger than expected
authorMarc Dionne <marc.dionne@auristor.com>
Fri, 2 Dec 2022 14:19:42 +0000 (10:19 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:38 +0000 (23:03 +0900)
commit274c0b0c2f49c1b068d6fc59c4ee33ccae74c6e3
treeb7920d85d13be4717774f8567266d3aa3fe85770
parent7b6ccf752a115399576e42a88494d27389af595f
afs: Avoid endless loop if file is larger than expected

[ Upstream commit 9ea4eff4b6f4f36546d537a74da44fd3f30903ab ]

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 <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/afs/dir.c