]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
holepunch: fix disconnected pages after second truncate
authorHugh Dickins <hugh@veritas.com>
Thu, 3 May 2007 22:53:54 +0000 (00:53 +0200)
committerAdrian Bunk <bunk@stusta.de>
Thu, 3 May 2007 22:53:54 +0000 (00:53 +0200)
commit7943951f236f91699a634097a70abc35927efeb9
tree585ec55ceccc1df04677b88798f453b0605bc6de
parentffd0472d4ece96766eec98ebb0ad649dc76248b8
holepunch: fix disconnected pages after second truncate

shmem_truncate_range has its own truncate_inode_pages_range, to free any
pages racily instantiated while it was in progress: a SHMEM_PAGEIN flag
is set when this might have happened.  But holepunching gets no chance
to clear that flag at the start of vmtruncate_range, so it's always set
(unless a truncate came just before), so holepunch almost always does
this second truncate_inode_pages_range.

shmem holepunch has unlikely swap<->file races hereabouts whatever we do
(without a fuller rework than is fit for this release): I was going to
skip the second truncate in the punch_hole case, but Miklos points out
that would make holepunch correctness more vulnerable to swapoff.  So
keep the second truncate, but follow it by an unmap_mapping_range to
eliminate the disconnected pages (freed from pagecache while still
mapped in userspace) that it might have left behind.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
mm/shmem.c