[PATCH] install_page vs. vmtruncate
authorHugh Dickins <hugh@veritas.com>
Wed, 28 Jul 2004 15:58:01 +0000 (08:58 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 28 Jul 2004 15:58:01 +0000 (08:58 -0700)
commit5136181d5b8bbb2c94d163a6d3362bfea9fdd99d
tree76cb2ce062ca4010a369e06e0c4260b4eed1d72c
parentddd443e4d88c6e39bc3a6d249a980ccc438544cb
[PATCH] install_page vs. vmtruncate

BK is still missing one piece for Oleg's install_page/vmtruncate races.
Oleg didn't explicitly ACK this, but I think he did implicitly: Oleg?

The previous patch to install_page, returning an error if !page_mapping
once page_table_lock is held, is not enough to guard against vmtruncate.

When unmap_mapping_range already did this vma, but truncate_inode_pages has
not yet done this page, page->mapping will still be set, but we must now
refrain from inserting the page into the page table.

Could check truncate_count, but that would need caller to read and pass it
down.  Instead, recheck page->index against i_size, which is updated before
unmap_mapping_range.  Better check page->mapping too: not really necessary,
but it's accidental that index is left when mapping is reset.

Also, callers are expecting -EINVAL for beyond end of file, not -EAGAIN.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/fremap.c