]> git.hungrycats.org Git - linux/commit
[PATCH] readpage-vs-invalidate fix
authorAndrew Morton <akpm@osdl.org>
Sat, 8 Jan 2005 06:03:01 +0000 (22:03 -0800)
committerLinus Torvalds <torvalds@evo.osdl.org>
Sat, 8 Jan 2005 06:03:01 +0000 (22:03 -0800)
commitba1f08f14b523e1722ee423eb729663e3fa5b192
treeccde6616758523560c19774e8db89b1fd9b7be89
parent7d2b870243bef6003b4fd57bba8f9fc80894072f
[PATCH] readpage-vs-invalidate fix

A while ago we merged a patch which tried to solve a problem wherein a
concurrent read() and invalidate_inode_pages() would cause the read() to
return -EIO because invalidate cleared PageUptodate() at the wrong time.

That patch tests for (page_count(page) != 2) in invalidate_complete_page() and
bales out if false.

Problem is, the page may be in the per-cpu LRU front-ends over in
lru_cache_add.  This elevates the refcount pending spillage of the page onto
the LRU for real.  That causes a false positive in invalidate_complete_page(),
causing the page to not get invalidated.  This screws up the logic in my new
O_DIRECT-vs-buffered coherency fix.

So let's solve the invalidate-vs-read in a different manner.  Over on the
read() side, add an explicit check to see if the page was invalidated.  If so,
just drop it on the floor and redo the read from scratch.

Note that only do_generic_mapping_read() needs treatment.  filemap_nopage(),
filemap_getpage() and read_cache_page() are already doing the
oh-it-was-invalidated-so-try-again thing.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/filemap.c
mm/truncate.c