Skip to content

Commit 3ef0f72

Browse files
Miklos Szereditorvalds
authored andcommitted
mm: fix infinite loop in filemap_fault
filemap_fault will go into an infinite loop if ->readpage() fails asynchronously. AFAICS the bug was introduced by this commit, which removed the wait after the final readpage: commit d00806b Author: Nick Piggin <npiggin@suse.de> Date: Thu Jul 19 01:46:57 2007 -0700 mm: fix fault vs invalidate race for linear mappings Fix by reintroducing the wait_on_page_locked() after ->readpage() to make sure the page is up-to-date before jumping back to the beginning of the function. I've noticed this while testing nfs exporting on fuse. The patch fixes it. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3b73a22 commit 3ef0f72

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mm/filemap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,11 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
14611461
*/
14621462
ClearPageError(page);
14631463
error = mapping->a_ops->readpage(file, page);
1464+
if (!error) {
1465+
wait_on_page_locked(page);
1466+
if (!PageUptodate(page))
1467+
error = -EIO;
1468+
}
14641469
page_cache_release(page);
14651470

14661471
if (!error || error == AOP_TRUNCATED_PAGE)

0 commit comments

Comments
 (0)