]> git.hungrycats.org Git - linux/commit
[PATCH] tmpfs 4/7 getpage/truncate race fix
authorAndrew Morton <akpm@osdl.org>
Wed, 22 Oct 2003 01:20:16 +0000 (18:20 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 22 Oct 2003 01:20:16 +0000 (18:20 -0700)
commit686e9e7248fedeaf5874c9d1ee1690458cb3e9ac
tree0a6bc9943970816a7b3913305c72875138218450
parenteaec8c0c5ff784c71230d080e055ebb63b344dc1
[PATCH] tmpfs 4/7 getpage/truncate race fix

From: Hugh Dickins <hugh@veritas.com>

Extend use of that SHMEM_PAGEIN flag to where shmem_getpage adds a page
to the cache.  It couldn't have caused a BUG_ON(inode->i_blocks), but if
i_size is reduced (from another cpu) the instant after shmem_swp_alloc
checks it, shmem_getpage could insert a page into the cache just after
truncate_inode_pages has passed through cleaning it, leaving stale data
(which may mysteriously reappear if the file is later extended).

Easily fixed for tmpfs, using the mechanism just added for swapoff; and
probably more important there, since its read from swap can insert non-0
data.  But is there not a similar issue, a tiny window, in filemap.c?
if truncate_inode_pages comes in between checking i_size and adding new
page to cache.  Not worth getting excited, but something to beware of.
mm/shmem.c