Commit ac7663f1 authored by Badari Pulavarty's avatar Badari Pulavarty Committed by Adrian Bunk

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: default avatarBadari Pulavarty <pbadari@us.ibm.com>
Forwarded-by: Jordan Neumeyer
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent 45c97a25
...@@ -510,7 +510,12 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) ...@@ -510,7 +510,12 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
size = SHMEM_NR_DIRECT; size = SHMEM_NR_DIRECT;
nr_swaps_freed = shmem_free_swp(ptr+idx, ptr+size); 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; goto done2;
BUG_ON(limit <= SHMEM_NR_DIRECT); BUG_ON(limit <= SHMEM_NR_DIRECT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment