Skip to content

Commit

Permalink
mm: fix infinite loop in filemap_fault
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed May 15, 2008
1 parent 3b73a22 commit 3ef0f72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,11 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
*/
ClearPageError(page);
error = mapping->a_ops->readpage(file, page);
if (!error) {
wait_on_page_locked(page);
if (!PageUptodate(page))
error = -EIO;
}
page_cache_release(page);

if (!error || error == AOP_TRUNCATED_PAGE)
Expand Down

0 comments on commit 3ef0f72

Please sign in to comment.