]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
holepunch: fix shmem_truncate_range punching too far
authorHugh Dickins <hugh@veritas.com>
Thu, 3 May 2007 22:52:18 +0000 (00:52 +0200)
committerAdrian Bunk <bunk@stusta.de>
Thu, 3 May 2007 22:52:18 +0000 (00:52 +0200)
commit0e846d67dd67e4b22a4889768f7982363e44ed26
tree5d7d2e57d5ad944e4c491c96e44fe9264c011b5d
parente76e407ef9ac8b94f011b42375b9105923b41dd9
holepunch: fix shmem_truncate_range punching too far

Miklos Szeredi observes BUG_ON(!entry) in shmem_writepage() triggered
in rare circumstances, because shmem_truncate_range() erroneously
removes partially truncated directory pages at the end of the range:
later reclaim on pages pointing to these removed directories triggers
the BUG.  Indeed, and it can also cause data loss beyond the hole.

Fix this as in the patch proposed by Miklos, but distinguish between
"limit" (how far we need to search: ignore truncation's next_index
optimization in the holepunch case - if there are races it's more
consistent to act on the whole range specified) and "upper_limit"
(how far we can free directory pages: generally we must be careful
to keep partially punched pages, but can relax at end of file -
i_size being held stable by i_mutex).

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