Re: [PATCH] [12/16] Refactor truncate to allow direct truncating of page

Wu Fengguang
2009-06-04T04:32:24Z

On Thu, Jun 04, 2009 at 02:46:46AM +0800, Andi Kleen wrote:
>
> From: Nick Piggin <npiggin@suse.de>
>
> Extract out truncate_inode_page() out of the truncate path so that
> it can be used by memory-failure.c
>
> [AK: description, headers, fix typos]
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> ---
> include/linux/mm.h | 2 ++
> mm/truncate.c | 24 ++++++++++++------------
> 2 files changed, 14 insertions(+), 12 deletions(-)
>
> Index: linux/mm/truncate.c
> ===================================================================
> --- linux.orig/mm/truncate.c 2009-06-03 19:37:38.000000000 +0200
> +++ linux/mm/truncate.c 2009-06-03 20:13:43.000000000 +0200
> @@ -135,6 +135,16 @@
> return ret;
> }
>
> +void truncate_inode_page(struct address_space *mapping, struct page *page)
> +{
> + if (page_mapped(page)) {
> + unmap_mapping_range(mapping,
> + (loff_t)page->index<<PAGE_CACHE_SHIFT,
> + PAGE_CACHE_SIZE, 0);
> + }
> + truncate_complete_page(mapping, page);
> +}
> +

Small style cleanup:

---
mm/truncate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- sound-2.6.orig/mm/truncate.c
+++ sound-2.6/mm/truncate.c
@@ -139,8 +139,8 @@ void truncate_inode_page(struct address_
{
if (page_mapped(page)) {
unmap_mapping_range(mapping,
- (loff_t)page->index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ (loff_t)page->index << PAGE_CACHE_SHIFT,
+ PAGE_CACHE_SIZE, 0);
}
truncate_complete_page(mapping, page);
}