diff options
| author | Andrew Morton <akpm@digeo.com> | 2003-05-18 20:28:32 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-05-18 20:28:32 -0700 |
| commit | 98063ca722718f8d6861202aa9e5bee2c7010b0d (patch) | |
| tree | 9f60785bad661cc759071734da82c236babc4427 | |
| parent | e432a56214e3a5b61c5b3b13fff3107af70207cb (diff) | |
[PATCH] Fix for latent bug in vmtruncate()
From: "Paul E. McKenney" <paulmck@us.ibm.com>
The vmtruncate() function shifts down by PAGE_CACHE_SHIFT, then calls
vmtruncate_list(), which deals in terms of PAGE_SHIFT instead. Currently,
no harm done, since PAGE_CACHE_SHIFT and PAGE_SHIFT are identical. Some
day they might not be, hence this patch.
I also took the liberty of modifying a hand-coded "if" that seems to
optimize for files that are not mapped to instead use unlikely().
| -rw-r--r-- | mm/memory.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/mm/memory.c b/mm/memory.c index 8397ea054459..e0dee2c62f5d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1108,17 +1108,12 @@ int vmtruncate(struct inode * inode, loff_t offset) if (inode->i_size < offset) goto do_expand; inode->i_size = offset; + pgoff = (offset + PAGE_SIZE - 1) >> PAGE_SHIFT; down(&mapping->i_shared_sem); - if (list_empty(&mapping->i_mmap) && list_empty(&mapping->i_mmap_shared)) - goto out_unlock; - - pgoff = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (!list_empty(&mapping->i_mmap)) + if (unlikely(!list_empty(&mapping->i_mmap))) vmtruncate_list(&mapping->i_mmap, pgoff); - if (!list_empty(&mapping->i_mmap_shared)) + if (unlikely(!list_empty(&mapping->i_mmap_shared))) vmtruncate_list(&mapping->i_mmap_shared, pgoff); - -out_unlock: up(&mapping->i_shared_sem); truncate_inode_pages(mapping, offset); goto out_truncate; |
