Skip to content

Commit 9ea4eff

Browse files
Marc Dionnedhowells
authored andcommitted
afs: Avoid endless loop if file is larger than expected
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: f3ddee8 ("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
1 parent 45f66fa commit 9ea4eff

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fs/afs/dir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
275275
loff_t i_size;
276276
int nr_pages, i;
277277
int ret;
278+
loff_t remote_size = 0;
278279

279280
_enter("");
280281

@@ -289,6 +290,8 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
289290

290291
expand:
291292
i_size = i_size_read(&dvnode->netfs.inode);
293+
if (i_size < remote_size)
294+
i_size = remote_size;
292295
if (i_size < 2048) {
293296
ret = afs_bad(dvnode, afs_file_error_dir_small);
294297
goto error;
@@ -364,6 +367,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
364367
* buffer.
365368
*/
366369
up_write(&dvnode->validate_lock);
370+
remote_size = req->file_size;
367371
goto expand;
368372
}
369373

0 commit comments

Comments
 (0)