aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBadari Pulavarty <pbadari@us.ibm.com>2007-01-07 00:58:15 +0100
committerAdrian Bunk <bunk@stusta.de>2007-01-09 03:23:34 +0100
commitac7663f17a4b5dc08776eb71f870bde40a0e5a37 (patch)
tree1d5b98f16bb3a0119872cfc347cd6447990c7901
parent45c97a2582a6dc2a41fbb71b14fd4c61402ad926 (diff)
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> Forwarded-by: Jordan Neumeyer Signed-off-by: Adrian Bunk <bunk@stusta.de>
-rw-r--r--mm/shmem.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 1bc2285f746..e25bceda7dd 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -510,7 +510,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);