summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorBadari Pulavarty <pbadari@us.ibm.com>2006-12-22 01:06:23 -0800
committerChris Wright <chrisw@sous-sol.org>2007-01-10 11:05:19 -0800
commitcb57fcaf9b8c1946aa1e436821a7a4901dc926d0 (patch)
treeb3d350e5024ca025f6abecc55d8827536fe555eb /mm
parent9ba9b18addcee8b7be8877727738f59a9fd37b29 (diff)
[PATCH] Fix for shmem_truncate_range() BUG_ON()
Ran into BUG() while doing madvise(REMOVE) testing. If we are punching a hole into shared memory segment using madvise(REMOVE) and the entire hole is below the indirect blocks, we hit following assert. BUG_ON(limit <= SHMEM_NR_DIRECT); Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com> Cc: Hugh Dickins <hugh@veritas.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/shmem.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 4959535fc14c..697ecd7fdbe6 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -515,7 +515,12 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
size = SHMEM_NR_DIRECT;
nr_swaps_freed = shmem_free_swp(ptr+idx, ptr+size);
}
- if (!topdir)
+
+ /*
+ * If there are no indirect blocks or we are punching a hole
+ * below indirect blocks, nothing to be done.
+ */
+ if (!topdir || (punch_hole && (limit <= SHMEM_NR_DIRECT)))
goto done2;
BUG_ON(limit <= SHMEM_NR_DIRECT);