From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Lameter Subject: [patch 04/19] Use page_cache_xxx in mm/truncate.c Date: Fri, 30 Nov 2007 09:34:52 -0800 Message-ID: <20071130173507.058970174@sgi.com> References: <20071130173448.951783014@sgi.com> Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org To: akpm@linux-foundation.org Return-path: Received: from netops-testserver-3-out.sgi.com ([192.48.171.28]:58288 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757641AbXK3RfL (ORCPT ); Fri, 30 Nov 2007 12:35:11 -0500 Cc: Christoph Hellwig , Mel Gorman Cc: William Lee Irwin III , David Chinner Cc: Jens Axboe , Badari Pulavarty Cc: Maxim Levitsky , Fengguang Wu Cc: swin wang , totty.lu@gmail.com, hugh@veritas.com Cc: joern@lazybastard.org Content-Disposition: inline; filename=0005-Use-page_cache_xxx-in-mm-truncate.c.patch Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Use page_cache_xxx in mm/truncate.c Reviewed-by: Dave Chinner Signed-off-by: Christoph Lameter --- mm/truncate.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) Index: mm/mm/truncate.c =================================================================== --- mm.orig/mm/truncate.c 2007-11-28 12:27:32.480099915 -0800 +++ mm/mm/truncate.c 2007-11-28 14:10:39.013977394 -0800 @@ -46,9 +46,10 @@ void do_invalidatepage(struct page *page (*invalidatepage)(page, offset); } -static inline void truncate_partial_page(struct page *page, unsigned partial) +static inline void truncate_partial_page(struct address_space *mapping, + struct page *page, unsigned partial) { - zero_user_segment(page, partial, PAGE_CACHE_SIZE); + zero_user_segment(page, partial, page_cache_size(mapping)); if (PagePrivate(page)) do_invalidatepage(page, partial); } @@ -98,7 +99,7 @@ truncate_complete_page(struct address_sp if (page->mapping != mapping) return; - cancel_dirty_page(page, PAGE_CACHE_SIZE); + cancel_dirty_page(page, page_cache_size(mapping)); if (PagePrivate(page)) do_invalidatepage(page, 0); @@ -160,9 +161,9 @@ invalidate_complete_page(struct address_ void truncate_inode_pages_range(struct address_space *mapping, loff_t lstart, loff_t lend) { - const pgoff_t start = (lstart + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; + const pgoff_t start = page_cache_next(mapping, lstart); pgoff_t end; - const unsigned partial = lstart & (PAGE_CACHE_SIZE - 1); + const unsigned partial = page_cache_offset(mapping, lstart); struct pagevec pvec; pgoff_t next; int i; @@ -170,8 +171,9 @@ void truncate_inode_pages_range(struct a if (mapping->nrpages == 0) return; - BUG_ON((lend & (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1)); - end = (lend >> PAGE_CACHE_SHIFT); + BUG_ON(page_cache_offset(mapping, lend) != + page_cache_size(mapping) - 1); + end = page_cache_index(mapping, lend); pagevec_init(&pvec, 0); next = start; @@ -197,8 +199,8 @@ void truncate_inode_pages_range(struct a } if (page_mapped(page)) { unmap_mapping_range(mapping, - (loff_t)page_index<index<index, 0), + page_cache_size(mapping), 0); } if (page->index > next) next = page->index; @@ -424,9 +426,8 @@ int invalidate_inode_pages2_range(struct * Zap the rest of the file in one hit. */ unmap_mapping_range(mapping, - (loff_t)page_index<