From: Christoph Lameter <clameter@sgi.com>
To: akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Cc: Christoph Hellwig <hch@lst.de>, Mel Gorman <mel@skynet.ie>
Cc: William Lee Irwin III <wli@holomorphy.com>, David Chinner <dgc@sgi.com>
Cc: Jens Axboe <jens.axboe@oracle.com>, Badari Pulavarty <pbadari@gmail.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>,
Fengguang Wu <fengguang.wu@gmail.com>
Cc: swin wang <wangswin@gmail.com>, totty.lu@gmail.com, hugh@veritas.com
Cc: joern@lazybastard.org
Subject: [patch 14/19] Use page_cache_xxx in ext2
Date: Wed, 28 Nov 2007 17:11:06 -0800 [thread overview]
Message-ID: <20071129011147.567317218@sgi.com> (raw)
In-Reply-To: 20071129011052.866354847@sgi.com
[-- Attachment #1: 0015-Use-page_cache_xxx-functions-in-fs-ext2.patch --]
[-- Type: text/plain, Size: 5666 bytes --]
Use page_cache_xxx functions in fs/ext2/*
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/ext2/dir.c | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
Index: linux-2.6/fs/ext2/dir.c
===================================================================
--- linux-2.6.orig/fs/ext2/dir.c 2007-11-26 17:45:29.155116723 -0800
+++ linux-2.6/fs/ext2/dir.c 2007-11-26 18:15:08.660772219 -0800
@@ -63,7 +63,8 @@ static inline void ext2_put_page(struct
static inline unsigned long dir_pages(struct inode *inode)
{
- return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
+ return (inode->i_size+page_cache_size(inode->i_mapping)-1)>>
+ page_cache_shift(inode->i_mapping);
}
/*
@@ -74,10 +75,11 @@ static unsigned
ext2_last_byte(struct inode *inode, unsigned long page_nr)
{
unsigned last_byte = inode->i_size;
+ struct address_space *mapping = inode->i_mapping;
- last_byte -= page_nr << PAGE_CACHE_SHIFT;
- if (last_byte > PAGE_CACHE_SIZE)
- last_byte = PAGE_CACHE_SIZE;
+ last_byte -= page_nr << page_cache_shift(mapping);
+ if (last_byte > page_cache_size(mapping))
+ last_byte = page_cache_size(mapping);
return last_byte;
}
@@ -105,18 +107,19 @@ static int ext2_commit_chunk(struct page
static void ext2_check_page(struct page *page)
{
- struct inode *dir = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode *dir = mapping->host;
struct super_block *sb = dir->i_sb;
unsigned chunk_size = ext2_chunk_size(dir);
char *kaddr = page_address(page);
u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count);
unsigned offs, rec_len;
- unsigned limit = PAGE_CACHE_SIZE;
+ unsigned limit = page_cache_size(mapping);
ext2_dirent *p;
char *error;
- if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
- limit = dir->i_size & ~PAGE_CACHE_MASK;
+ if (page_cache_index(mapping, dir->i_size) == page->index) {
+ limit = page_cache_offset(mapping, dir->i_size);
if (limit & (chunk_size - 1))
goto Ebadsize;
if (!limit)
@@ -168,7 +171,7 @@ Einumber:
bad_entry:
ext2_error (sb, "ext2_check_page", "bad entry in directory #%lu: %s - "
"offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
- dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs,
+ dir->i_ino, error, page_cache_pos(mapping, page->index, offs),
(unsigned long) le32_to_cpu(p->inode),
rec_len, p->name_len);
goto fail;
@@ -177,7 +180,7 @@ Eend:
ext2_error (sb, "ext2_check_page",
"entry in directory #%lu spans the page boundary"
"offset=%lu, inode=%lu",
- dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
+ dir->i_ino, page_cache_pos(mapping, page->index, offs),
(unsigned long) le32_to_cpu(p->inode));
fail:
SetPageChecked(page);
@@ -276,8 +279,9 @@ ext2_readdir (struct file * filp, void *
loff_t pos = filp->f_pos;
struct inode *inode = filp->f_path.dentry->d_inode;
struct super_block *sb = inode->i_sb;
- unsigned int offset = pos & ~PAGE_CACHE_MASK;
- unsigned long n = pos >> PAGE_CACHE_SHIFT;
+ struct address_space *mapping = inode->i_mapping;
+ unsigned int offset = page_cache_offset(mapping, pos);
+ unsigned long n = page_cache_index(mapping, pos);
unsigned long npages = dir_pages(inode);
unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
unsigned char *types = NULL;
@@ -298,14 +302,14 @@ ext2_readdir (struct file * filp, void *
ext2_error(sb, __FUNCTION__,
"bad page in #%lu",
inode->i_ino);
- filp->f_pos += PAGE_CACHE_SIZE - offset;
+ filp->f_pos += page_cache_size(mapping) - offset;
return -EIO;
}
kaddr = page_address(page);
if (unlikely(need_revalidate)) {
if (offset) {
offset = ext2_validate_entry(kaddr, offset, chunk_mask);
- filp->f_pos = (n<<PAGE_CACHE_SHIFT) + offset;
+ filp->f_pos = page_cache_pos(mapping, n, offset);
}
filp->f_version = inode->i_version;
need_revalidate = 0;
@@ -328,7 +332,7 @@ ext2_readdir (struct file * filp, void *
offset = (char *)de - kaddr;
over = filldir(dirent, de->name, de->name_len,
- (n<<PAGE_CACHE_SHIFT) | offset,
+ page_cache_pos(mapping, n, offset),
le32_to_cpu(de->inode), d_type);
if (over) {
ext2_put_page(page);
@@ -354,6 +358,7 @@ struct ext2_dir_entry_2 * ext2_find_entr
struct dentry *dentry, struct page ** res_page)
{
const char *name = dentry->d_name.name;
+ struct address_space *mapping = dir->i_mapping;
int namelen = dentry->d_name.len;
unsigned reclen = EXT2_DIR_REC_LEN(namelen);
unsigned long start, n;
@@ -395,7 +400,7 @@ struct ext2_dir_entry_2 * ext2_find_entr
if (++n >= npages)
n = 0;
/* next page is past the blocks we've got */
- if (unlikely(n > (dir->i_blocks >> (PAGE_CACHE_SHIFT - 9)))) {
+ if (unlikely(n > (dir->i_blocks >> (page_cache_shift(mapping) - 9)))) {
ext2_error(dir->i_sb, __FUNCTION__,
"dir %lu size %lld exceeds block count %llu",
dir->i_ino, dir->i_size,
@@ -466,6 +471,7 @@ void ext2_set_link(struct inode *dir, st
int ext2_add_link (struct dentry *dentry, struct inode *inode)
{
struct inode *dir = dentry->d_parent->d_inode;
+ struct address_space *mapping = inode->i_mapping;
const char *name = dentry->d_name.name;
int namelen = dentry->d_name.len;
unsigned chunk_size = ext2_chunk_size(dir);
@@ -495,7 +501,7 @@ int ext2_add_link (struct dentry *dentry
kaddr = page_address(page);
dir_end = kaddr + ext2_last_byte(dir, n);
de = (ext2_dirent *)kaddr;
- kaddr += PAGE_CACHE_SIZE - reclen;
+ kaddr += page_cache_size(mapping) - reclen;
while ((char *)de <= kaddr) {
if ((char *)de == dir_end) {
/* We hit i_size */
--
next prev parent reply other threads:[~2007-11-29 1:11 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 1:10 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions Christoph Lameter
2007-11-29 1:10 ` [patch 01/19] Define functions for page cache handling Christoph Lameter
2007-11-29 3:06 ` David Chinner
2007-11-29 3:21 ` Christoph Lameter
[not found] ` <E1Ixf0M-0004lI-0Z@localhost>
2007-11-29 8:44 ` Fengguang Wu
2007-11-29 19:23 ` Christoph Lameter
2007-11-29 1:10 ` [patch 02/19] Use page_cache_xxx functions in mm/filemap.c Christoph Lameter
2007-11-29 1:10 ` [patch 03/19] Use page_cache_xxx in mm/page-writeback.c Christoph Lameter
2007-11-29 1:10 ` [patch 04/19] Use page_cache_xxx in mm/truncate.c Christoph Lameter
2007-11-29 1:10 ` [patch 05/19] Use page_cache_xxx in mm/rmap.c Christoph Lameter
2007-11-29 3:19 ` David Chinner
2007-11-29 3:30 ` Christoph Lameter
2007-11-29 3:59 ` David Chinner
2007-11-29 4:09 ` Christoph Lameter
2007-11-29 4:11 ` David Chinner
2007-11-29 1:10 ` [patch 06/19] Use page_cache_xxx in mm/filemap_xip.c Christoph Lameter
[not found] ` <E1IxfXc-0005sC-9J@localhost>
2007-11-29 9:18 ` Fengguang Wu
2007-11-29 1:10 ` [patch 07/19] Use page_cache_xxx in mm/migrate.c Christoph Lameter
2007-11-29 1:11 ` [patch 08/19] Use page_cache_xxx in fs/libfs.c Christoph Lameter
2007-11-29 1:11 ` [patch 09/19] Use page_cache_xxx in fs/sync Christoph Lameter
2007-11-29 1:11 ` [patch 10/19] Use page_cache_xxx in fs/buffer.c Christoph Lameter
2007-11-29 3:34 ` David Chinner
2007-11-29 3:48 ` Christoph Lameter
2007-11-29 4:01 ` David Chinner
2007-11-29 1:11 ` [patch 11/19] Use page_cache_xxx in mm/mpage.c Christoph Lameter
2007-11-29 1:11 ` [patch 12/19] Use page_cache_xxx in mm/fadvise.c Christoph Lameter
2007-11-29 1:11 ` [patch 13/19] Use page_cache_xxx in fs/splice.c Christoph Lameter
2007-11-29 3:40 ` David Chinner
2007-11-29 3:50 ` Christoph Lameter
2007-11-29 4:02 ` David Chinner
2007-11-29 1:11 ` Christoph Lameter [this message]
2007-11-29 3:45 ` [patch 14/19] Use page_cache_xxx in ext2 David Chinner
2007-11-29 3:55 ` Christoph Lameter
2007-11-29 4:06 ` David Chinner
2007-11-29 4:15 ` Christoph Lameter
2007-11-29 4:19 ` David Chinner
2007-11-29 1:11 ` [patch 15/19] Use page_cache_xxx in fs/ext3 Christoph Lameter
2007-11-29 1:11 ` [patch 16/19] Use page_cache_xxx in fs/ext4 Christoph Lameter
2007-11-29 3:48 ` David Chinner
2007-11-29 3:58 ` Christoph Lameter
2007-11-29 4:07 ` David Chinner
2007-11-29 1:11 ` [patch 17/19] Use page_cache_xxx in fs/reiserfs Christoph Lameter
2007-11-29 3:54 ` David Chinner
2007-11-29 4:02 ` Christoph Lameter
2007-11-29 4:08 ` David Chinner
2007-11-29 1:11 ` [patch 18/19] Use page_cache_xxx for fs/xfs Christoph Lameter
2007-11-29 3:03 ` David Chinner
2007-11-29 3:28 ` Christoph Lameter
2007-11-29 3:58 ` David Chinner
2007-11-29 4:06 ` Christoph Lameter
2007-11-29 4:10 ` David Chinner
2007-11-29 8:24 ` Andrew Morton
2007-11-29 1:11 ` [patch 19/19] Use page_cache_xxx in drivers/block/rd.c Christoph Lameter
[not found] ` <E1Ixep7-0004SV-Pq@localhost>
2007-11-29 8:32 ` Fengguang Wu
2007-11-29 4:20 ` [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions David Chinner
2007-11-29 8:29 ` Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
2007-11-30 17:35 ` [patch 14/19] Use page_cache_xxx in ext2 Christoph Lameter
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=20071129011147.567317218@sgi.com \
--to=clameter@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).