diff options
author | Hugh Dickins <hughd@google.com> | 2012-05-29 18:06:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:22 -0400 |
commit | 3f31d07571eeea18a7d34db9af21d2285b807a17 (patch) | |
tree | 04350a376ef0cbe32cf2ff11067d4a0a920fd093 /drivers/staging | |
parent | 83e4fa9c16e4af7122e31be3eca5d57881d236fe (diff) |
mm/fs: route MADV_REMOVE to FALLOC_FL_PUNCH_HOLE
Now tmpfs supports hole-punching via fallocate(), switch madvise_remove()
to use do_fallocate() instead of vmtruncate_range(): which extends
madvise(,,MADV_REMOVE) support from tmpfs to ext4, ocfs2 and xfs.
There is one more user of vmtruncate_range() in our tree,
staging/android's ashmem_shrink(): convert it to use do_fallocate() too
(but if its unpinned areas are already unmapped - I don't know - then it
would do better to use shmem_truncate_range() directly).
Based-on-patch-by: Cong Wang <amwang@redhat.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Colin Cross <ccross@android.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger@dilger.ca>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Ben Myers <bpm@sgi.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/android/ashmem.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 4511420849bc..e84dbecd0991 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/file.h> | 20 | #include <linux/file.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/falloc.h> | ||
22 | #include <linux/miscdevice.h> | 23 | #include <linux/miscdevice.h> |
23 | #include <linux/security.h> | 24 | #include <linux/security.h> |
24 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
@@ -363,11 +364,12 @@ static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc) | |||
363 | 364 | ||
364 | mutex_lock(&ashmem_mutex); | 365 | mutex_lock(&ashmem_mutex); |
365 | list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) { | 366 | list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) { |
366 | struct inode *inode = range->asma->file->f_dentry->d_inode; | ||
367 | loff_t start = range->pgstart * PAGE_SIZE; | 367 | loff_t start = range->pgstart * PAGE_SIZE; |
368 | loff_t end = (range->pgend + 1) * PAGE_SIZE - 1; | 368 | loff_t end = (range->pgend + 1) * PAGE_SIZE; |
369 | 369 | ||
370 | vmtruncate_range(inode, start, end); | 370 | do_fallocate(range->asma->file, |
371 | FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, | ||
372 | start, end - start); | ||
371 | range->purged = ASHMEM_WAS_PURGED; | 373 | range->purged = ASHMEM_WAS_PURGED; |
372 | lru_del(range); | 374 | lru_del(range); |
373 | 375 | ||