[PATCH] 2.3.1[34]: filemap_nopage faults on ->readpage() failure

Steve Dodd (dirk@loth.demon.co.uk)
Thu, 19 Aug 1999 08:53:12 +0100


Hi,

The current code in filemap_nopage() seems to expect the page to still be
locked after an error, but as we've normally just waited on it, it won't be:

...
page_not_uptodate:
lock_page(page);
if (Page_Uptodate(page)) {
UnlockPage(page);
goto success;
}

error = inode->i_op->readpage(file, page);

if (!error) {
wait_on_page(page);
if (Page_Uptodate(page))
goto success;
}

/*
* Umm, take care of errors if the page isn't up-to-date.
* Try to re-read it _once_. We do this synchronously,
* because there really aren't any performance issues here
* and we need to check for errors.
*/
if (!PageLocked(page))
PAGE_BUG(page);
ClearPageError(page);
...

block_read_full_page() never fails, but I don't know what other
implementations of ->readpage() might be expected to do in an error situation.

The 'obvious' fix seems to be:

--- mm/filemap.c.orig Thu Aug 19 08:37:26 1999
+++ mm/filemap.c Thu Aug 19 08:43:22 1999
@@ -1386,8 +1386,12 @@
* because there really aren't any performance issues here
* and we need to check for errors.
*/
- if (!PageLocked(page))
- PAGE_BUG(page);
+ lock_page(page);
+ if (Page_Uptodate(page)) {
+ UnlockPage(page);
+ goto success;
+ }
+
ClearPageError(page);
error = inode->i_op->readpage(file, page);
if (error)

Thoughts?

-- 
Fortune: You will be attacked next Wednesday at 3:15 p.m. by six samuri
sword wielding purple fish glued to Harley-Davidson motorcycles.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/