Skip to contentSkip to conversation

filemap_getpage can block when MAP_NONBLOCK specified

PATCH New Jeff Moyer 1 participant 1 message Mar 30, 2005

Subsystems (2)
lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 filemap_getpage can block when MAP_NONBLOCK specified

Hello,

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;

Patch attached.

Thanks,

Jeff

mm/filemap.c renamed from mm/filemap.c.orig +6 -1
@@ -1379,8 +1379,13 @@ retry_find:
 	 * 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:
 	/*