From: clameter@sgi.com
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Christoph Hellwig <hch@infradead.org>
Subject: [patch 05/14] Use page_cache_xxx in mm/truncate.c
Date: Thu, 14 Jun 2007 12:38:44 -0700 [thread overview]
Message-ID: <20070614194053.603193326@sgi.com> (raw)
In-Reply-To: 20070614193839.878721298@sgi.com
[-- Attachment #1: vps_mm_truncate --]
[-- Type: text/plain, Size: 3797 bytes --]
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/truncate.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
Index: vps/mm/truncate.c
===================================================================
--- vps.orig/mm/truncate.c 2007-06-09 20:35:19.000000000 -0700
+++ vps/mm/truncate.c 2007-06-09 21:39:47.000000000 -0700
@@ -45,9 +45,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);
}
@@ -95,7 +96,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);
@@ -157,9 +158,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;
@@ -167,8 +168,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;
@@ -194,8 +196,8 @@ void truncate_inode_pages_range(struct a
}
if (page_mapped(page)) {
unmap_mapping_range(mapping,
- (loff_t)page_index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ page_cache_pos(mapping, page_index, 0),
+ page_cache_size(mapping), 0);
}
truncate_complete_page(mapping, page);
unlock_page(page);
@@ -208,7 +210,7 @@ void truncate_inode_pages_range(struct a
struct page *page = find_lock_page(mapping, start - 1);
if (page) {
wait_on_page_writeback(page);
- truncate_partial_page(page, partial);
+ truncate_partial_page(mapping, page, partial);
unlock_page(page);
page_cache_release(page);
}
@@ -236,8 +238,8 @@ void truncate_inode_pages_range(struct a
wait_on_page_writeback(page);
if (page_mapped(page)) {
unmap_mapping_range(mapping,
- (loff_t)page->index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ page_cache_pos(mapping, page->index, 0),
+ page_cache_size(mapping), 0);
}
if (page->index > next)
next = page->index;
@@ -421,9 +423,8 @@ int invalidate_inode_pages2_range(struct
* Zap the rest of the file in one hit.
*/
unmap_mapping_range(mapping,
- (loff_t)page_index<<PAGE_CACHE_SHIFT,
- (loff_t)(end - page_index + 1)
- << PAGE_CACHE_SHIFT,
+ page_cache_pos(mapping, page_index, 0),
+ page_cache_pos(mapping, end - page_index + 1, 0),
0);
did_range_unmap = 1;
} else {
@@ -431,8 +432,8 @@ int invalidate_inode_pages2_range(struct
* Just zap this page
*/
unmap_mapping_range(mapping,
- (loff_t)page_index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ page_cache_pos(mapping, page_index, 0),
+ page_cache_size(mapping), 0);
}
}
BUG_ON(page_mapped(page));
--
next prev parent reply other threads:[~2007-06-14 19:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-14 19:38 [patch 00/14] Page cache cleanup in anticipation of Large Blocksize support clameter
2007-06-14 19:38 ` [patch 01/14] Define functions for page cache handling clameter
2007-06-14 19:56 ` Sam Ravnborg
2007-06-14 19:58 ` Christoph Lameter
2007-06-14 20:07 ` Sam Ravnborg
2007-06-14 19:38 ` [patch 02/14] Pagecache zeroing: zero_user_segment, zero_user_segments and zero_user clameter
2007-06-14 19:38 ` [patch 03/14] Use page_cache_xx function in mm/filemap.c clameter
2007-06-14 19:38 ` [patch 04/14] Use page_cache_xxx in mm/page-writeback.c clameter
2007-06-14 19:38 ` clameter [this message]
2007-06-14 19:38 ` [patch 06/14] Use page_cache_xxx in mm/rmap.c clameter
2007-06-14 19:38 ` [patch 07/14] Use page_cache_xx in mm/filemap_xip.c clameter
2007-06-14 19:38 ` [patch 08/14] Use page_cache_xx in mm/migrate.c clameter
2007-06-14 19:38 ` [patch 09/14] Use page_cache_xx in fs/libfs.c clameter
2007-06-14 19:38 ` [patch 10/14] Use page_cache_xx in fs/sync clameter
2007-06-14 19:38 ` [patch 11/14] Use page_cache_xx in fs/buffer.c clameter
2007-06-14 19:38 ` [patch 12/14] Use page_cache_xxx in mm/mpage.c clameter
2007-06-14 19:38 ` [patch 13/14] Use page_cache_xxx in mm/fadvise.c clameter
2007-06-14 19:38 ` [patch 14/14] Use page_cache_xx in fs/splice.c clameter
2007-06-14 20:06 ` [patch 00/14] Page cache cleanup in anticipation of Large Blocksize support Andrew Morton
2007-06-14 21:07 ` Christoph Hellwig
2007-06-14 21:25 ` Dave McCracken
2007-06-14 21:20 ` Christoph Lameter
2007-06-14 21:32 ` Andrew Morton
2007-06-14 21:37 ` Christoph Lameter
2007-06-14 22:04 ` Andrew Morton
2007-06-14 22:22 ` Christoph Lameter
2007-06-14 22:49 ` Andrew Morton
2007-06-15 0:45 ` Christoph Lameter
2007-06-15 1:40 ` Andrew Morton
2007-06-15 2:04 ` Christoph Lameter
2007-06-15 2:23 ` Andrew Morton
2007-06-15 2:37 ` Christoph Lameter
2007-06-15 9:03 ` David Chinner
2007-06-14 23:30 ` David Chinner
2007-06-14 23:41 ` Andrew Morton
2007-06-15 0:29 ` David Chinner
2007-06-15 15:05 ` Dave Kleikamp
2007-06-17 1:25 ` Arjan van de Ven
2007-06-17 5:02 ` Matt Mackall
2007-06-18 2:08 ` Christoph Lameter
2007-06-18 3:00 ` Arjan van de Ven
2007-06-18 4:50 ` William Lee Irwin III
2007-06-14 23:54 ` David Chinner
2007-07-02 18:16 ` Badari Pulavarty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070614194053.603193326@sgi.com \
--to=clameter@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox