]> git.ipfire.org Git - people/ms/linux.git/commitdiff
Fix for shmem_truncate_range() BUG_ON()
authorBadari Pulavarty <pbadari@us.ibm.com>
Sat, 6 Jan 2007 23:58:15 +0000 (00:58 +0100)
committerAdrian Bunk <bunk@stusta.de>
Tue, 9 Jan 2007 02:23:34 +0000 (03:23 +0100)
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>
mm/shmem.c

index 1bc2285f74693d821e5d63e3cfed5856a9df2a2e..e25bceda7dd0a4d3d54ff07b4a08f1d93c3bd884 100644 (file)
@@ -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);