Skip to content

Commit

Permalink
[PATCH] filemap_getpage can block when MAP_NONBLOCK specified
Browse files Browse the repository at this point in the history
We will return NULL from filemap_getpage when a page does not exist in the
page cache and MAP_NONBLOCK is specified, here:

	page = find_get_page(mapping, pgoff);
	if (!page) {
		if (nonblock)
			return NULL;
		goto no_cached_page;
	}

But we forget to do so when the page in the cache is not uptodate.  The
following could result in a blocking call:

	/*
	 * Ok, found a page in the page cache, now we need to check
	 * that it's up-to-date.
	 */
	if (!PageUptodate(page))
		goto page_not_uptodate;



Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JeffMoyer authored and Linus Torvalds committed Apr 16, 2005
1 parent 41aac24 commit d345734
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,13 @@ static struct page * filemap_getpage(struct file *file, unsigned long pgoff,
* Ok, found a page in the page cache, now we need to check
* that it's up-to-date.
*/
if (!PageUptodate(page))
if (!PageUptodate(page)) {
if (nonblock) {
page_cache_release(page);
return NULL;
}
goto page_not_uptodate;
}

success:
/*
Expand Down

0 comments on commit d345734

Please sign in to comment.