Skip to content

Commit

Permalink
ext4: hole-punch use truncate_pagecache_range
Browse files Browse the repository at this point in the history
When truncating a file, we unmap pages from userspace first, as that's
usually more efficient than relying, page by page, on the fallback in
truncate_inode_page() - particularly if the file is mapped many times.

Do the same when punching a hole: 3.4 added truncate_pagecache_range()
to do the unmap and trunc, so use it in ext4_ext_punch_hole(), instead
of calling truncate_inode_pages_range() directly.

Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Hugh Dickins authored and tytso committed Jun 1, 2012
1 parent b2f4edb commit 5e44f8c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -4789,8 +4789,8 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)

/* Now release the pages */
if (last_page_offset > first_page_offset) {
truncate_inode_pages_range(mapping, first_page_offset,
last_page_offset-1);
truncate_pagecache_range(inode, first_page_offset,
last_page_offset - 1);
}

/* finish any pending end_io work */
Expand Down

0 comments on commit 5e44f8c

Please sign in to comment.