[patch 17/18] Use page_cache_xxx in fs/reiserfs
V2->V3: - reiserfs_commit_write(): Use common method to extract mapping from page->mapping->host chain Use page_cache_xxx in fs/reiserfs Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/reiserfs/file.c|5 +++-- fs/reiserfs/inode.c | 36 ++-- fs/reiserfs/ioctl.c |2 +- fs/reiserfs/stree.c |5 +++-- fs/reiserfs/tail_conversion.c |5 +++-- fs/reiserfs/xattr.c | 19 ++- 6 files changed, 42 insertions(+), 30 deletions(-) Index: linux-2.6/fs/reiserfs/file.c === --- linux-2.6.orig/fs/reiserfs/file.c 2008-02-14 15:19:13.573515455 -0800 +++ linux-2.6/fs/reiserfs/file.c2008-02-15 16:15:19.373226761 -0800 @@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *i int partial = 0; unsigned blocksize; struct buffer_head *bh, *head; - unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT; + unsigned long i_size_index = + page_cache_index(inode->i_mapping, inode->i_size); int new; int logit = reiserfs_file_data_log(inode); struct super_block *s = inode->i_sb; - int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize; + int bh_per_page = page_cache_size(inode->i_mapping) / s->s_blocksize; struct reiserfs_transaction_handle th; int ret = 0; Index: linux-2.6/fs/reiserfs/inode.c === --- linux-2.6.orig/fs/reiserfs/inode.c 2008-02-14 15:19:13.633515774 -0800 +++ linux-2.6/fs/reiserfs/inode.c 2008-02-15 16:15:19.397226989 -0800 @@ -337,7 +337,8 @@ static int _get_block_create_0(struct in goto finished; } // read file tail into part of page - offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1); + offset = page_cache_offset(inode->i_mapping, + cpu_key_k_offset(&key) - 1); fs_gen = get_generation(inode->i_sb); copy_item_head(&tmp_ih, ih); @@ -523,10 +524,10 @@ static int convert_tail_for_hole(struct return -EIO; /* always try to read until the end of the block */ - tail_start = tail_offset & (PAGE_CACHE_SIZE - 1); + tail_start = page_cache_offset(inode->i_mapping, tail_offset); tail_end = (tail_start | (bh_result->b_size - 1)) + 1; - index = tail_offset >> PAGE_CACHE_SHIFT; + index = page_cache_index(inode->i_mapping, tail_offset); /* hole_page can be zero in case of direct_io, we are sure that we cannot get here if we write with O_DIRECT into tail page */ @@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode * /* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ - unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT; + unsigned long index = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size - 1); unsigned long pos = 0; unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); struct buffer_head *bh; struct buffer_head *head; struct page *page; @@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode { struct reiserfs_transaction_handle th; /* we want the offset for the first byte after the end of the file */ - unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); unsigned blocksize = p_s_inode->i_sb->s_blocksize; unsigned length; struct page *page = NULL; @@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc } else if (is_direct_le_ih(ih)) { char *p; p = page_address(bh_result->b_page); - p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1); + p += page_cache_offset(inode->i_mapping, byte_offset - 1); copy_size = ih_item_len(ih) - pos_in_item; fs_gen = get_generation(inode->i_sb); @@ -2324,7 +2328,8 @@ static int reiserfs_write_full_page(stru struct writeback_control *wbc) { struct inode *inode = pa
[patch 18/18] Use page_cache_xxx for fs/xfs
V2->V3: - xfs_page_trace: Determine mapping from inode - xfs_probe_page: Make mapping check easier to read Use page_cache_xxx for fs/xfs Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/xfs/linux-2.6/xfs_aops.c | 58 ++-- fs/xfs/linux-2.6/xfs_lrw.c |4 +-- 2 files changed, 32 insertions(+), 30 deletions(-) Index: linux-2.6/fs/xfs/linux-2.6/xfs_aops.c === --- linux-2.6.orig/fs/xfs/linux-2.6/xfs_aops.c 2008-02-14 15:19:13.777516867 -0800 +++ linux-2.6/fs/xfs/linux-2.6/xfs_aops.c 2008-02-15 16:15:22.377251601 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_offset(page); + loff_t offset = page_cache_pos(inode->i_mapping, page->index, 0); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -599,11 +599,12 @@ xfs_probe_page( int mapped) { int ret = 0; + struct address_space*mapping = page->mapping; if (PageWriteback(page)) return 0; - if (page->mapping && PageDirty(page)) { + if (mapping && PageDirty(page)) { if (page_has_buffers(page)) { struct buffer_head *bh, *head; @@ -618,7 +619,7 @@ xfs_probe_page( break; } while ((bh = bh->b_this_page) != head); } else - ret = mapped ? 0 : PAGE_CACHE_SIZE; + ret = mapped ? 0 : page_cache_size(mapping); } return ret; @@ -645,7 +646,7 @@ xfs_probe_cluster( } while ((bh = bh->b_this_page) != head); /* if we reached the end of the page, sum forwards in following pages */ - tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT; + tlast = page_cache_index(inode->i_mapping, i_size_read(inode)); tindex = startpage->index + 1; /* Prune this back to avoid pathological behavior */ @@ -663,14 +664,14 @@ xfs_probe_cluster( size_t pg_offset, pg_len = 0; if (tindex == tlast) { - pg_offset = - i_size_read(inode) & (PAGE_CACHE_SIZE - 1); + pg_offset = page_cache_offset(inode->i_mapping, + i_size_read(inode)); if (!pg_offset) { done = 1; break; } } else - pg_offset = PAGE_CACHE_SIZE; + pg_offset = page_cache_size(inode->i_mapping); if (page->index == tindex && !TestSetPageLocked(page)) { pg_len = xfs_probe_page(page, pg_offset, mapped); @@ -752,7 +753,8 @@ xfs_convert_page( int bbits = inode->i_blkbits; int len, page_dirty; int count = 0, done = 0, uptodate = 1; - xfs_off_t offset = page_offset(page); + struct address_space*map = inode->i_mapping; + xfs_off_t offset = page_cache_pos(map, page->index, 0); if (page->index != tindex) goto fail; @@ -760,7 +762,7 @@ xfs_convert_page( goto fail; if (PageWriteback(page)) goto fail_unlock_page; - if (page->mapping != inode->i_mapping) + if (page->mapping != map) goto fail_unlock_page; if (!xfs_is_delayed_page(page, (*ioendp)->io_type)) goto fail_unlock_page; @@ -772,20 +774,19 @@ xfs_convert_page( * Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset & page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT, + (xfs_off_t)page_cache_pos(map
[patch 15/18] Use page_cache_xxx in fs/ext3
Use page_cache_xxx in fs/ext3 Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext3/dir.c |3 ++- fs/ext3/inode.c | 39 --- 2 files changed, 22 insertions(+), 20 deletions(-) Index: linux-2.6/fs/ext3/dir.c === --- linux-2.6.orig/fs/ext3/dir.c2008-02-14 15:19:11.977504226 -0800 +++ linux-2.6/fs/ext3/dir.c 2008-02-15 16:15:13.021174127 -0800 @@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_shift(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: linux-2.6/fs/ext3/inode.c === --- linux-2.6.orig/fs/ext3/inode.c 2008-02-14 15:19:11.977504226 -0800 +++ linux-2.6/fs/ext3/inode.c 2008-02-15 16:15:13.049174361 -0800 @@ -1147,8 +1147,8 @@ static int ext3_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1244,7 +1244,7 @@ static int ext3_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1314,7 +1314,7 @@ static int ext3_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1477,6 +1477,7 @@ static int ext3_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1499,8 +1500,7 @@ static int ext3_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext3_get_block, wbc); @@ -1517,13 +1517,12 @@ static int ext3_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, - NULL, journal_dirty_data_fn); + err = walk_page_buffers(handle, page_bufs, 0, pagesize, + NULL, journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext3_journal_stop(handle); if (!ret) ret = err; @@ -1571,10 +1570,12 @@ out_fail: static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext3_journal_current_handle()) goto no_write; @@ -1591,17 +1592,16 @@ static int ext3_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext3_get_block); + ret = block_prepare_write(page, 0, pagesize, ext3_get_block); if (ret != 0) { ext3_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_
[patch 16/18] Use page_cache_xxx in fs/ext4
Use page_cache_xxx in fs/ext4 Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext4/dir.c |3 ++- fs/ext4/inode.c | 34 +- 2 files changed, 19 insertions(+), 18 deletions(-) Index: linux-2.6/fs/ext4/dir.c === --- linux-2.6.orig/fs/ext4/dir.c2008-02-14 15:19:11.993504338 -0800 +++ linux-2.6/fs/ext4/dir.c 2008-02-15 16:15:16.385202022 -0800 @@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_size(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: linux-2.6/fs/ext4/inode.c === --- linux-2.6.orig/fs/ext4/inode.c 2008-02-14 15:19:12.005504520 -0800 +++ linux-2.6/fs/ext4/inode.c 2008-02-15 16:15:16.389202066 -0800 @@ -1142,8 +1142,8 @@ static int ext4_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1238,7 +1238,7 @@ static int ext4_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1308,7 +1308,7 @@ static int ext4_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1471,6 +1471,7 @@ static int ext4_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1493,8 +1494,7 @@ static int ext4_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext4_get_block, wbc); @@ -1511,13 +1511,12 @@ static int ext4_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, + err = walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, jbd2_journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext4_journal_stop(handle); if (!ret) ret = err; @@ -1569,6 +1568,7 @@ static int ext4_journalled_writepage(str handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext4_journal_current_handle()) goto no_write; @@ -1585,17 +1585,16 @@ static int ext4_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext4_get_block); + ret = block_prepare_write(page, 0, pagesize, ext4_get_block); if (ret != 0) { ext4_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, write_end_fn); + pagesize, NULL, write_end_fn); if (ret == 0)
[patch 14/18] Use page_cache_xxx in ext2
Use page_cache_xxx functions in fs/ext2/* Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext2/dir.c | 41 +++-- 1 file changed, 23 insertions(+), 18 deletions(-) Index: linux-2.6/fs/ext2/dir.c === --- linux-2.6.orig/fs/ext2/dir.c2008-02-14 15:19:11.961504128 -0800 +++ linux-2.6/fs/ext2/dir.c 2008-02-15 16:15:09.997149018 -0800 @@ -63,7 +63,7 @@ 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 page_cache_next(inode->i_mapping, inode->i_size); } /* @@ -74,10 +74,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_cache_pos(mapping, page_nr, 0); + if (last_byte > page_cache_size(mapping)) + last_byte = page_cache_size(mapping); return last_byte; } @@ -105,18 +106,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 +170,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<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 +179,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<i_ino, page_cache_pos(mapping, page->index, offs), (unsigned long) le32_to_cpu(p->inode)); fail: SetPageChecked(page); @@ -276,8 +278,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 +301,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<f_pos = page_cache_pos(mapping, n, offset); } filp->f_version = inode->i_version; need_revalidate = 0; @@ -328,7 +331,7 @@ ext2_readdir (struct file * filp, void * offset = (char *)de - kaddr; over = filldir(d
[patch 12/18] Use page_cache_xxx in mm/fadvise.c
Use page_cache_xxx in mm/fadvise.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/fadvise.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6/mm/fadvise.c === --- linux-2.6.orig/mm/fadvise.c 2008-02-14 15:20:25.566017193 -0800 +++ linux-2.6/mm/fadvise.c 2008-02-15 16:15:04.157100371 -0800 @@ -91,8 +91,8 @@ asmlinkage long sys_fadvise64_64(int fd, } /* First and last PARTIAL page! */ - start_index = offset >> PAGE_CACHE_SHIFT; - end_index = endbyte >> PAGE_CACHE_SHIFT; + start_index = page_cache_index(mapping, offset); + end_index = page_cache_index(mapping, endbyte); /* Careful about overflow on the "+1" */ nrpages = end_index - start_index + 1; @@ -112,8 +112,8 @@ asmlinkage long sys_fadvise64_64(int fd, filemap_flush(mapping); /* First and last FULL page! */ - start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT; - end_index = (endbyte >> PAGE_CACHE_SHIFT); + start_index = page_cache_next(mapping, offset); + end_index = page_cache_index(mapping, endbyte); if (end_index >= start_index) invalidate_mapping_pages(mapping, start_index, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 11/18] Use page_cache_xxx in mm/mpage.c
Use page_cache_xxx in mm/mpage.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/mpage.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) Index: linux-2.6/fs/mpage.c === --- linux-2.6.orig/fs/mpage.c 2008-02-14 15:19:12.989511284 -0800 +++ linux-2.6/fs/mpage.c2008-02-15 16:14:58.093049603 -0800 @@ -125,7 +125,8 @@ mpage_alloc(struct block_device *bdev, static void map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; struct buffer_head *page_bh, *head; int block = 0; @@ -134,9 +135,9 @@ map_buffer_to_page(struct page *page, st * don't make any buffers if there is only one buffer on * the page and the page just needs to be set up to date */ - if (inode->i_blkbits == PAGE_CACHE_SHIFT && + if (inode->i_blkbits == page_cache_shift(mapping) && buffer_uptodate(bh)) { - SetPageUptodate(page); + SetPageUptodate(page); return; } create_empty_buffers(page, 1 << inode->i_blkbits, 0); @@ -169,9 +170,10 @@ do_mpage_readpage(struct bio *bio, struc sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; const unsigned blocksize = 1 << blkbits; sector_t block_in_file; sector_t last_block; @@ -188,7 +190,7 @@ do_mpage_readpage(struct bio *bio, struc if (page_has_buffers(page)) goto confused; - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << (page_cache_shift(mapping) - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -276,7 +278,8 @@ do_mpage_readpage(struct bio *bio, struc } if (first_hole != blocks_per_page) { - zero_user_segment(page, first_hole << blkbits, PAGE_CACHE_SIZE); + zero_user_segment(page, first_hole << blkbits, + page_cache_size(mapping)); if (first_hole == 0) { SetPageUptodate(page); unlock_page(page); @@ -454,7 +457,7 @@ static int __mpage_writepage(struct page struct inode *inode = page->mapping->host; const unsigned blkbits = inode->i_blkbits; unsigned long end_index; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; sector_t last_block; sector_t block_in_file; sector_t blocks[MAX_BUF_PER_PAGE]; @@ -523,7 +526,8 @@ static int __mpage_writepage(struct page * The page has no buffers: map it to disk */ BUG_ON(!PageUptodate(page)); - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << + (page_cache_shift(mapping) - blkbits); last_block = (i_size - 1) >> blkbits; map_bh.b_page = page; for (page_block = 0; page_block < blocks_per_page; ) { @@ -555,7 +559,7 @@ static int __mpage_writepage(struct page first_unmapped = page_block; page_is_mapped: - end_index = i_size >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, i_size); if (page->index >= end_index) { /* * The page straddles i_size. It must be zeroed out on each @@ -565,11 +569,11 @@ page_is_mapped: * is zeroed when mapped, and writes to that region are not * written out to the file." */ - unsigned offset = i_size & (PAGE_CACHE_SIZE - 1); + unsigned offset = page_cache_offset(mapping, i_size); if (page->index > end_index || !offset) goto confused; -
[patch 13/18] Use page_cache_xxx in fs/splice.c
Use page_cache_xxx in fs/splice.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/splice.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) Index: linux-2.6/fs/splice.c === --- linux-2.6.orig/fs/splice.c 2008-02-14 15:19:13.645515948 -0800 +++ linux-2.6/fs/splice.c 2008-02-15 16:15:07.021124374 -0800 @@ -285,9 +285,9 @@ __generic_file_splice_read(struct file * .spd_release = spd_release_page, }; - index = *ppos >> PAGE_CACHE_SHIFT; - loff = *ppos & ~PAGE_CACHE_MASK; - req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); + loff = page_cache_offset(mapping, *ppos); + req_pages = page_cache_next(mapping, len + loff); nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS); /* @@ -342,7 +342,7 @@ __generic_file_splice_read(struct file * * Now loop over the map and see if we need to start IO on any * pages, fill in the partial map, etc. */ - index = *ppos >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); nr_pages = spd.nr_pages; spd.nr_pages = 0; for (page_nr = 0; page_nr < nr_pages; page_nr++) { @@ -354,7 +354,8 @@ __generic_file_splice_read(struct file * /* * this_len is the max we'll use from this page */ - this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); + this_len = min_t(unsigned long, len, + page_cache_size(mapping) - loff); page = pages[page_nr]; if (PageReadahead(page)) @@ -414,7 +415,7 @@ fill_it: * i_size must be checked after PageUptodate. */ isize = i_size_read(mapping->host); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) break; @@ -428,7 +429,7 @@ fill_it: /* * max good bytes in this page */ - plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + plen = page_cache_offset(mapping, isize - 1) + 1; if (plen <= loff) break; @@ -453,7 +454,7 @@ fill_it: */ while (page_nr < nr_pages) page_cache_release(pages[page_nr++]); - in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; + in->f_ra.prev_pos = page_cache_pos(mapping, index, 0); if (spd.nr_pages) return splice_to_pipe(pipe, &spd); @@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inod if (unlikely(ret)) return ret; - offset = sd->pos & ~PAGE_CACHE_MASK; + offset = page_cache_offset(mapping, sd->pos); this_len = sd->len; - if (this_len + offset > PAGE_CACHE_SIZE) - this_len = PAGE_CACHE_SIZE - offset; + if (this_len + offset > page_cache_size(mapping)) + this_len = page_cache_size(mapping) - offset; ret = pagecache_write_begin(file, mapping, sd->pos, this_len, AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata); @@ -790,7 +791,7 @@ generic_file_splice_write_nolock(struct unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, @@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_in unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 09/18] Use page_cache_xxx in fs/sync
Use page_cache_xxx in fs/sync. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/sync.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6/fs/sync.c === --- linux-2.6.orig/fs/sync.c2008-02-14 15:19:13.645515948 -0800 +++ linux-2.6/fs/sync.c 2008-02-15 16:14:52.000998613 -0800 @@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address ret = 0; if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); if (ret < 0) goto out; } @@ -275,8 +275,8 @@ int do_sync_mapping_range(struct address if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); } out: return ret; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 10/18] Use page_cache_xxx in fs/buffer.c
V2->V3: - alloc_page_buffers(): Add comment to explain use of page->mapping - Consistently determine mapping if there is a reference chain page->mapping->host to determine the inode. Use page_cache_xxx in fs/buffer.c. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/buffer.c | 112 ++-- 1 file changed, 65 insertions(+), 47 deletions(-) Index: linux-2.6/fs/buffer.c === --- linux-2.6.orig/fs/buffer.c 2008-02-15 16:11:18.567307640 -0800 +++ linux-2.6/fs/buffer.c 2008-02-15 16:14:54.753021832 -0800 @@ -270,7 +270,7 @@ __find_get_block_slow(struct block_devic struct page *page; int all_mapped = 1; - index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits); + index = block >> (page_cache_shift(bd_mapping) - bd_inode->i_blkbits); page = find_get_page(bd_mapping, index); if (!page) goto out; @@ -712,7 +712,7 @@ static int __set_page_dirty(struct page __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); @@ -924,7 +924,13 @@ struct buffer_head *alloc_page_buffers(s try_again: head = NULL; - offset = PAGE_SIZE; + + /* +* Page is locked to serialize alloc_page_buffers() +* so we can use page->mapping here. +*/ + offset = page_cache_size(page->mapping); + while ((offset -= size) >= 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -1636,6 +1642,7 @@ static int __block_write_full_page(struc struct buffer_head *bh, *head; const unsigned blocksize = 1 << inode->i_blkbits; int nr_underway = 0; + struct address_space *mapping = inode->i_mapping; BUG_ON(!PageLocked(page)); @@ -1656,7 +1663,8 @@ static int __block_write_full_page(struc * handle that here by just cleaning them. */ - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + block = (sector_t)page->index << + (page_cache_shift(mapping) - inode->i_blkbits); head = page_buffers(page); bh = head; @@ -1772,7 +1780,7 @@ recover: } while ((bh = bh->b_this_page) != head); SetPageError(page); BUG_ON(PageWriteback(page)); - mapping_set_error(page->mapping, err); + mapping_set_error(mapping, err); set_page_writeback(page); do { struct buffer_head *next = bh->b_this_page; @@ -1839,8 +1847,8 @@ static int __block_prepare_write(struct struct buffer_head *bh, *head, *wait[2], **wait_bh=wait; BUG_ON(!PageLocked(page)); - BUG_ON(from > PAGE_CACHE_SIZE); - BUG_ON(to > PAGE_CACHE_SIZE); + BUG_ON(from > page_cache_size(inode->i_mapping)); + BUG_ON(to > page_cache_size(inode->i_mapping)); BUG_ON(from > to); blocksize = 1 << inode->i_blkbits; @@ -1849,7 +1857,8 @@ static int __block_prepare_write(struct head = page_buffers(page); bbits = inode->i_blkbits; - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits); + block = (sector_t)page->index << + (page_cache_shift(inode->i_mapping) - bbits); for(bh = head, block_start = 0; bh != head || !block_start; block++, block_start=block_end, bh = bh->b_this_page) { @@ -1964,8 +1973,8 @@ int block_write_begin(struct file *file, unsigned start, end; int ownpage = 0; - index = pos >> PAGE_CACHE_SHIFT; - start = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + start = page_cache_offset(mapping, pos); end = start + len; page = *pagep; @@ -2012,7 +2021,7 @@ int block_write_end(struct file *file, s struct inode *inode = mapping->host; unsigned start; - start = pos & (PAGE_CACHE_SIZE - 1); + start = page_cache_offset(mapping, pos); if (unlikely(copied < len)) { /* @@ -2077,7 +2086,8 @@ EXPORT_SYMBOL(generic_write_end); */ int block_read_full_page(struct page *page, get_block_t *get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->h
[patch 08/18] Use page_cache_xxx in fs/libfs.c
Use page_cache_xxx in fs/libfs.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/libfs.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) Index: linux-2.6/fs/libfs.c === --- linux-2.6.orig/fs/libfs.c 2008-02-14 15:19:12.777509805 -0800 +++ linux-2.6/fs/libfs.c2008-02-15 16:14:49.160975533 -0800 @@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt, { struct inode *inode = dentry->d_inode; generic_fillattr(inode, stat); - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + stat->blocks = inode->i_mapping->nrpages << + (page_cache_shift(inode->i_mapping) - 9); return 0; } @@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi unsigned from, unsigned to) { if (!PageUptodate(page)) { - if (to - from != PAGE_CACHE_SIZE) + if (to - from != page_cache_size(file->f_mapping)) zero_user_segments(page, 0, from, - to, PAGE_CACHE_SIZE); + to, page_cache_size(file->f_mapping)); } return 0; } @@ -372,8 +373,9 @@ int simple_write_begin(struct file *file static int simple_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct inode *inode = page->mapping->host; - loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; + loff_t pos = page_cache_pos(mapping, page->index, to); if (!PageUptodate(page)) SetPageUptodate(page); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 07/18] Use page_cache_xxx in mm/migrate.c
V2->V3: - Only use mapping in remove_file_migration_ptes after it was checked for NULL. Use page_cache_xxx in mm/migrate.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/migrate.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: linux-2.6/mm/migrate.c === --- linux-2.6.orig/mm/migrate.c 2008-02-14 15:20:25.570017244 -0800 +++ linux-2.6/mm/migrate.c 2008-02-15 16:14:46.304954466 -0800 @@ -197,11 +197,12 @@ static void remove_file_migration_ptes(s struct vm_area_struct *vma; struct address_space *mapping = page_mapping(new); struct prio_tree_iter iter; - pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; if (!mapping) return; + pgoff = new->index << mapping_order(mapping); spin_lock(&mapping->i_mmap_lock); vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 06/18] Use page_cache_xxx in mm/filemap_xip.c
Use page_cache_xxx in mm/filemap_xip.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap_xip.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) Index: linux-2.6/mm/filemap_xip.c === --- linux-2.6.orig/mm/filemap_xip.c 2008-02-14 15:20:25.570017244 -0800 +++ linux-2.6/mm/filemap_xip.c 2008-02-15 16:14:43.296931634 -0800 @@ -62,24 +62,24 @@ do_xip_mapping_read(struct address_space BUG_ON(!mapping->a_ops->get_xip_page); - index = *ppos >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + offset = page_cache_offset(mapping, *ppos); isize = i_size_read(inode); if (!isize) goto out; - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); for (;;) { struct page *page; unsigned long nr, ret; /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index >= end_index) { if (index > end_index) goto out; - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_next(mapping, isize); if (nr <= offset) { goto out; } @@ -118,8 +118,8 @@ do_xip_mapping_read(struct address_space */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); if (ret == nr && desc->count) continue; @@ -132,7 +132,7 @@ no_xip_page: } out: - *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; + *ppos = page_cache_pos(mapping, index, offset); if (filp) file_accessed(filp); } @@ -221,7 +221,7 @@ static int xip_file_fault(struct vm_area /* XXX: are VM_FAULT_ codes OK? */ - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + size = page_cache_next(mapping, i_size_read(inode)); if (vmf->pgoff >= size) return VM_FAULT_SIGBUS; @@ -291,9 +291,9 @@ __xip_file_write(struct file *filp, cons size_t copied; char *kaddr; - offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ - index = pos >> PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; + offset = page_cache_offset(mapping, pos); /* Within page */ + index = page_cache_index(mapping, pos); + bytes = page_cache_size(mapping) - offset; if (bytes > count) bytes = count; @@ -404,8 +404,8 @@ EXPORT_SYMBOL_GPL(xip_file_write); int xip_truncate_page(struct address_space *mapping, loff_t from) { - pgoff_t index = from >> PAGE_CACHE_SHIFT; - unsigned offset = from & (PAGE_CACHE_SIZE-1); + pgoff_t index = page_cache_index(mapping, from); + unsigned offset = page_cache_offset(mapping, from); unsigned blocksize; unsigned length; struct page *page; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 04/18] Use page_cache_xxx in mm/truncate.c
Use page_cache_xxx in mm/truncate.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/truncate.c | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/truncate.c === --- linux-2.6.24-rc6-mm1.orig/mm/truncate.c 2007-12-26 20:06:38.863513630 -0800 +++ linux-2.6.24-rc6-mm1/mm/truncate.c 2007-12-26 20:06:48.143568906 -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); } @@ -101,7 +102,7 @@ truncate_complete_page(struct address_sp if (PagePrivate(page)) do_invalidatepage(page, 0); - cancel_dirty_page(page, PAGE_CACHE_SIZE); + cancel_dirty_page(page, page_cache_size(mapping)); remove_from_page_cache(page); ClearPageUptodate(page); @@ -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<http://vger.kernel.org/majordomo-info.html
[patch 05/18] Use page_cache_xxx in mm/rmap.c
V2->V3: - vma_address(): Check for truncation if this is a file based page. return -EFAULT if truncation occurred. - page_referenced_file(): Only use mapping after we have made sure that the mapping is valid and the page is locked. Use page_cache_xxx in mm/rmap.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/rmap.c | 23 +++ 1 file changed, 19 insertions(+), 4 deletions(-) Index: linux-2.6/mm/rmap.c === --- linux-2.6.orig/mm/rmap.c2008-02-14 15:20:25.574017171 -0800 +++ linux-2.6/mm/rmap.c 2008-02-15 16:14:40.016907160 -0800 @@ -190,9 +190,21 @@ static void page_unlock_anon_vma(struct static inline unsigned long vma_address(struct page *page, struct vm_area_struct *vma) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; unsigned long address; + if (PageAnon(page)) + pgoff = page->index; + else { + struct address_space *mapping = page->mapping; + + if (!mapping) + /* Page was truncated */ + return -EFAULT; + + pgoff = page->index << mapping_order(mapping); + } + address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); if (unlikely(address < vma->vm_start || address >= vma->vm_end)) { /* page should be within @vma mapping range */ @@ -348,7 +360,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; @@ -368,6 +380,9 @@ static int page_referenced_file(struct p */ BUG_ON(!PageLocked(page)); + /* Safe to use mapping */ + pgoff = page->index << mapping_order(mapping); + spin_lock(&mapping->i_mmap_lock); /* @@ -468,7 +483,7 @@ out: static int page_mkclean_file(struct address_space *mapping, struct page *page) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = 0; @@ -899,7 +914,7 @@ static int try_to_unmap_anon(struct page static int try_to_unmap_file(struct page *page, int migration) { struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = SWAP_AGAIN; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 02/18] Use page_cache_xxx functions in mm/filemap.c
Convert the uses of PAGE_CACHE_xxx. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap.c | 91 +-- 1 file changed, 46 insertions(+), 45 deletions(-) Index: linux-2.6/mm/filemap.c === --- linux-2.6.orig/mm/filemap.c 2008-02-14 15:20:25.570017244 -0800 +++ linux-2.6/mm/filemap.c 2008-02-15 16:14:31.616843824 -0800 @@ -325,8 +325,8 @@ int wait_on_page_writeback_range(struct int sync_page_range(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -357,8 +357,8 @@ EXPORT_SYMBOL(sync_page_range); int sync_page_range_nolock(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -387,7 +387,7 @@ int filemap_fdatawait(struct address_spa return 0; return wait_on_page_writeback_range(mapping, 0, - (i_size - 1) >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, i_size - 1)); } EXPORT_SYMBOL(filemap_fdatawait); @@ -435,8 +435,8 @@ int filemap_write_and_wait_range(struct /* See comment of filemap_write_and_wait() */ if (err != -EIO) { int err2 = wait_on_page_writeback_range(mapping, - lstart >> PAGE_CACHE_SHIFT, - lend >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, lstart), + page_cache_index(mapping, lend)); if (!err) err = err2; } @@ -900,11 +900,11 @@ static void do_generic_file_read(struct unsigned int prev_offset; int error; - index = *ppos >> PAGE_CACHE_SHIFT; - prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT; - prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1); - last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + prev_index = page_cache_index(mapping, ra->prev_pos); + prev_offset = page_cache_offset(mapping, ra->prev_pos); + last_index = page_cache_next(mapping, *ppos + desc->count); + offset = page_cache_offset(mapping, *ppos); for (;;) { struct page *page; @@ -941,16 +941,16 @@ page_ok: */ isize = i_size_read(inode); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) { page_cache_release(page); goto out; } /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index == end_index) { - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_offset(mapping, isize - 1) + 1; if (nr <= offset) { page_cache_release(page); goto out; @@ -985,8 +985,8 @@ page_ok: */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); prev_offset = offset; page_cache_release(page); @@ -1076,11 +1076,8 @@ no_cached_page: } out: - ra->prev_pos = prev_index; - ra->prev_pos <<= PAGE_CACHE_SHIFT; - ra->prev_pos |= prev_offset; - - *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset; + ra->prev_pos = page_cache_pos(mapping, prev_index, prev_offset); +
[patch 03/18] Use page_cache_xxx in mm/page-writeback.c
Use page_cache_xxx in mm/page-writeback.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/page-writeback.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: mm/mm/page-writeback.c === --- mm.orig/mm/page-writeback.c 2007-11-28 12:27:32.211962401 -0800 +++ mm/mm/page-writeback.c 2007-11-28 14:10:34.338227137 -0800 @@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa index = mapping->writeback_index; /* Start from prev offset */ end = -1; } else { - index = wbc->range_start >> PAGE_CACHE_SHIFT; - end = wbc->range_end >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, wbc->range_start); + end = page_cache_index(mapping, wbc->range_end); if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; scanned = 1; @@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 01/18] Define functions for page cache handling
V2->V3: - Use "mapping" instead of "a" as the address space parameter We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK and PAGE_CACHE_ALIGN in various places in the kernel. Many times common operations like calculating the offset or the index are coded using shifts and adds. This patch provides inline functions to get the calculations accomplished without having to explicitly shift and add constants. All functions take an address_space pointer. The address space pointer will be used in the future to eventually support a variable size page cache. Information reachable via the mapping may then determine page size. New functionRelated base page constant page_cache_shift(a) PAGE_CACHE_SHIFT page_cache_size(a) PAGE_CACHE_SIZE page_cache_mask(a) PAGE_CACHE_MASK page_cache_index(a, pos)Calculate page number from position page_cache_next(addr, pos) Page number of next page page_cache_offset(a, pos) Calculate offset into a page page_cache_pos(a, index, offset) Form position based on page number and an offset. This provides a basis that would allow the conversion of all page cache handling in the kernel and ultimately allow the removal of the PAGE_CACHE_* constants. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- include/linux/pagemap.h | 53 +++- 1 file changed, 52 insertions(+), 1 deletion(-) Index: linux-2.6.24-rc6-mm1/include/linux/pagemap.h === --- linux-2.6.24-rc6-mm1.orig/include/linux/pagemap.h 2007-12-26 21:12:59.773000516 -0800 +++ linux-2.6.24-rc6-mm1/include/linux/pagemap.h2007-12-26 21:19:15.537477621 -0800 @@ -52,12 +52,61 @@ static inline void mapping_set_gfp_mask( * space in smaller chunks for same flexibility). * * Or rather, it _will_ be done in larger chunks. + * + * The following constants can be used if a filesystem only supports a single + * page size. */ #define PAGE_CACHE_SHIFT PAGE_SHIFT #define PAGE_CACHE_SIZEPAGE_SIZE #define PAGE_CACHE_MASKPAGE_MASK #define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK) +/* + * Functions that are currently setup for a fixed PAGE_SIZE. The use of + * these may allow larger page sizes in the future. + */ +static inline int mapping_order(struct address_space *mapping) +{ + return 0; +} + +static inline int page_cache_shift(struct address_space *mapping) +{ + return PAGE_SHIFT; +} + +static inline unsigned int page_cache_size(struct address_space *mapping) +{ + return PAGE_SIZE; +} + +static inline unsigned int page_cache_offset(struct address_space *mapping, + loff_t pos) +{ + return pos & ~PAGE_MASK; +} + +static inline pgoff_t page_cache_index(struct address_space *mapping, + loff_t pos) +{ + return pos >> page_cache_shift(mapping); +} + +/* + * Index of the page starting on or after the given position. + */ +static inline pgoff_t page_cache_next(struct address_space *mapping, + loff_t pos) +{ + return page_cache_index(mapping, pos + page_cache_size(mapping) - 1); +} + +static inline loff_t page_cache_pos(struct address_space *mapping, + pgoff_t index, unsigned long offset) +{ + return ((loff_t)index << page_cache_shift(mapping)) + offset; +} + #define page_cache_get(page) get_page(page) #define page_cache_release(page) put_page(page) void release_pages(struct page **pages, int nr, int cold); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 00/18] Page cache: Replace PAGE_CACHE_xx with inline functions V4
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls. The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices. Patchset against upstream as of today (2.6.25-rc2) Patchset can be pulled from git://git.kernel.org/pub/scm/linux/kernel/git/christoph/vm.git pagecache-inline V2->V4: - Rediff to upstream. Surprisingly no rejects at all so it seems that all of the pagecache patches that were in mm were merged. Just had to refresh the patches. V2->V3: - Audit to check that uses of page->mapping are valid. Improve a couple of places. Make it clearer how the mappings are determined and handled (see the comments of each patch for detailed descriptions). - Use a consistent method to determine the mapping if a function already does determine the inode via page->mapping->host. V1->V2: - Review by Dave Chinner. Multiple improvements and fixes. - Review by Fengguand Wu with more improvements. -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 18/18] Use page_cache_xxx for fs/xfs
V2->V3: - xfs_page_trace: Determine mapping from inode - xfs_probe_page: Make mapping check easier to read Use page_cache_xxx for fs/xfs Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/xfs/linux-2.6/xfs_aops.c | 58 ++-- fs/xfs/linux-2.6/xfs_lrw.c |4 +-- 2 files changed, 32 insertions(+), 30 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/xfs/linux-2.6/xfs_aops.c === --- linux-2.6.24-rc6-mm1.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-12-26 20:14:13.078250056 -0800 +++ linux-2.6.24-rc6-mm1/fs/xfs/linux-2.6/xfs_aops.c2007-12-26 21:11:38.200980834 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_offset(page); + loff_t offset = page_cache_pos(inode->i_mapping, page->index, 0); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -599,11 +599,12 @@ xfs_probe_page( int mapped) { int ret = 0; + struct address_space*mapping = page->mapping; if (PageWriteback(page)) return 0; - if (page->mapping && PageDirty(page)) { + if (mapping && PageDirty(page)) { if (page_has_buffers(page)) { struct buffer_head *bh, *head; @@ -618,7 +619,7 @@ xfs_probe_page( break; } while ((bh = bh->b_this_page) != head); } else - ret = mapped ? 0 : PAGE_CACHE_SIZE; + ret = mapped ? 0 : page_cache_size(mapping); } return ret; @@ -645,7 +646,7 @@ xfs_probe_cluster( } while ((bh = bh->b_this_page) != head); /* if we reached the end of the page, sum forwards in following pages */ - tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT; + tlast = page_cache_index(inode->i_mapping, i_size_read(inode)); tindex = startpage->index + 1; /* Prune this back to avoid pathological behavior */ @@ -663,14 +664,14 @@ xfs_probe_cluster( size_t pg_offset, pg_len = 0; if (tindex == tlast) { - pg_offset = - i_size_read(inode) & (PAGE_CACHE_SIZE - 1); + pg_offset = page_cache_offset(inode->i_mapping, + i_size_read(inode)); if (!pg_offset) { done = 1; break; } } else - pg_offset = PAGE_CACHE_SIZE; + pg_offset = page_cache_size(inode->i_mapping); if (page->index == tindex && !TestSetPageLocked(page)) { pg_len = xfs_probe_page(page, pg_offset, mapped); @@ -752,7 +753,8 @@ xfs_convert_page( int bbits = inode->i_blkbits; int len, page_dirty; int count = 0, done = 0, uptodate = 1; - xfs_off_t offset = page_offset(page); + struct address_space*map = inode->i_mapping; + xfs_off_t offset = page_cache_pos(map, page->index, 0); if (page->index != tindex) goto fail; @@ -760,7 +762,7 @@ xfs_convert_page( goto fail; if (PageWriteback(page)) goto fail_unlock_page; - if (page->mapping != inode->i_mapping) + if (page->mapping != map) goto fail_unlock_page; if (!xfs_is_delayed_page(page, (*ioendp)->io_type)) goto fail_unlock_page; @@ -772,20 +774,19 @@ xfs_convert_page( * Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset & page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT, +
[patch 17/18] Use page_cache_xxx in fs/reiserfs
V2->V3: - reiserfs_commit_write(): Use common method to extract mapping from page->mapping->host chain Use page_cache_xxx in fs/reiserfs Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/reiserfs/file.c|5 +++-- fs/reiserfs/inode.c | 36 ++-- fs/reiserfs/ioctl.c |2 +- fs/reiserfs/stree.c |5 +++-- fs/reiserfs/tail_conversion.c |5 +++-- fs/reiserfs/xattr.c | 19 ++- 6 files changed, 42 insertions(+), 30 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/reiserfs/file.c === --- linux-2.6.24-rc6-mm1.orig/fs/reiserfs/file.c2007-12-26 20:14:13.130250237 -0800 +++ linux-2.6.24-rc6-mm1/fs/reiserfs/file.c 2007-12-26 21:05:14.432903071 -0800 @@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *i int partial = 0; unsigned blocksize; struct buffer_head *bh, *head; - unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT; + unsigned long i_size_index = + page_cache_index(inode->i_mapping, inode->i_size); int new; int logit = reiserfs_file_data_log(inode); struct super_block *s = inode->i_sb; - int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize; + int bh_per_page = page_cache_size(inode->i_mapping) / s->s_blocksize; struct reiserfs_transaction_handle th; int ret = 0; Index: linux-2.6.24-rc6-mm1/fs/reiserfs/inode.c === --- linux-2.6.24-rc6-mm1.orig/fs/reiserfs/inode.c 2007-12-26 20:14:13.142250082 -0800 +++ linux-2.6.24-rc6-mm1/fs/reiserfs/inode.c2007-12-26 21:07:16.172906276 -0800 @@ -337,7 +337,8 @@ static int _get_block_create_0(struct in goto finished; } // read file tail into part of page - offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1); + offset = page_cache_offset(inode->i_mapping, + cpu_key_k_offset(&key) - 1); fs_gen = get_generation(inode->i_sb); copy_item_head(&tmp_ih, ih); @@ -523,10 +524,10 @@ static int convert_tail_for_hole(struct return -EIO; /* always try to read until the end of the block */ - tail_start = tail_offset & (PAGE_CACHE_SIZE - 1); + tail_start = page_cache_offset(inode->i_mapping, tail_offset); tail_end = (tail_start | (bh_result->b_size - 1)) + 1; - index = tail_offset >> PAGE_CACHE_SHIFT; + index = page_cache_index(inode->i_mapping, tail_offset); /* hole_page can be zero in case of direct_io, we are sure that we cannot get here if we write with O_DIRECT into tail page */ @@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode * /* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ - unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT; + unsigned long index = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size - 1); unsigned long pos = 0; unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); struct buffer_head *bh; struct buffer_head *head; struct page *page; @@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode { struct reiserfs_transaction_handle th; /* we want the offset for the first byte after the end of the file */ - unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); unsigned blocksize = p_s_inode->i_sb->s_blocksize; unsigned length; struct page *page = NULL; @@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc } else if (is_direct_le_ih(ih)) { char *p; p = page_address(bh_result->b_page); - p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1); + p += page_cache_offset(inode->i_mapping, byte_offset - 1); copy_size = ih_item_len(ih) - pos_in_item; fs_gen = get_generation(inode->i_sb); @@ -2324,7 +2328,8 @@ static int reiserfs_write_full_page(stru struct writeback_control *wbc)
[patch 16/18] Use page_cache_xxx in fs/ext4
Use page_cache_xxx in fs/ext4 Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext4/dir.c |3 ++- fs/ext4/inode.c | 34 +- 2 files changed, 19 insertions(+), 18 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/ext4/dir.c === --- linux-2.6.24-rc6-mm1.orig/fs/ext4/dir.c 2007-12-26 17:47:01.995405564 -0800 +++ linux-2.6.24-rc6-mm1/fs/ext4/dir.c 2007-12-26 19:51:08.130145646 -0800 @@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_size(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: linux-2.6.24-rc6-mm1/fs/ext4/inode.c === --- linux-2.6.24-rc6-mm1.orig/fs/ext4/inode.c 2007-12-26 17:47:01.999405549 -0800 +++ linux-2.6.24-rc6-mm1/fs/ext4/inode.c2007-12-26 19:51:08.150145767 -0800 @@ -1110,8 +1110,8 @@ static int ext4_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1206,7 +1206,7 @@ static int ext4_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1276,7 +1276,7 @@ static int ext4_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1579,6 +1579,7 @@ static int ext4_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1601,8 +1602,7 @@ static int ext4_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext4_get_block, wbc); @@ -1619,13 +1619,12 @@ static int ext4_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, + err = walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, jbd2_journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext4_journal_stop(handle); if (!ret) ret = err; @@ -1677,6 +1676,7 @@ static int ext4_journalled_writepage(str handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext4_journal_current_handle()) goto no_write; @@ -1693,17 +1693,16 @@ static int ext4_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext4_get_block); + ret = block_prepare_write(page, 0, pagesize, ext4_get_block); if (ret != 0) { ext4_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, write_end_fn); +
[patch 15/18] Use page_cache_xxx in fs/ext3
Use page_cache_xxx in fs/ext3 Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext3/dir.c |3 ++- fs/ext3/inode.c | 39 --- 2 files changed, 22 insertions(+), 20 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/ext3/dir.c === --- linux-2.6.24-rc6-mm1.orig/fs/ext3/dir.c 2007-12-20 17:25:48.0 -0800 +++ linux-2.6.24-rc6-mm1/fs/ext3/dir.c 2007-12-26 19:51:08.038145100 -0800 @@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_shift(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: linux-2.6.24-rc6-mm1/fs/ext3/inode.c === --- linux-2.6.24-rc6-mm1.orig/fs/ext3/inode.c 2007-12-26 17:47:01.991405709 -0800 +++ linux-2.6.24-rc6-mm1/fs/ext3/inode.c2007-12-26 19:51:08.106145500 -0800 @@ -1157,8 +1157,8 @@ static int ext3_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1254,7 +1254,7 @@ static int ext3_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1324,7 +1324,7 @@ static int ext3_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1487,6 +1487,7 @@ static int ext3_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1509,8 +1510,7 @@ static int ext3_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext3_get_block, wbc); @@ -1527,13 +1527,12 @@ static int ext3_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, - NULL, journal_dirty_data_fn); + err = walk_page_buffers(handle, page_bufs, 0, pagesize, + NULL, journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext3_journal_stop(handle); if (!ret) ret = err; @@ -1581,10 +1580,12 @@ out_fail: static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext3_journal_current_handle()) goto no_write; @@ -1601,17 +1602,16 @@ static int ext3_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext3_get_block); + ret = block_prepare_write(page, 0, pagesize, ext3_get_block); if (ret != 0) { ext3_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, -
[patch 14/18] Use page_cache_xxx in ext2
Use page_cache_xxx functions in fs/ext2/* Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext2/dir.c | 41 +++-- 1 file changed, 23 insertions(+), 18 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/ext2/dir.c === --- linux-2.6.24-rc6-mm1.orig/fs/ext2/dir.c 2007-12-20 17:25:48.0 -0800 +++ linux-2.6.24-rc6-mm1/fs/ext2/dir.c 2007-12-26 19:51:08.002144959 -0800 @@ -63,7 +63,7 @@ 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 page_cache_next(inode->i_mapping, inode->i_size); } /* @@ -74,10 +74,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_cache_pos(mapping, page_nr, 0); + if (last_byte > page_cache_size(mapping)) + last_byte = page_cache_size(mapping); return last_byte; } @@ -105,18 +106,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 +170,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<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 +179,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<i_ino, page_cache_pos(mapping, page->index, offs), (unsigned long) le32_to_cpu(p->inode)); fail: SetPageChecked(page); @@ -276,8 +278,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 +301,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<f_pos = page_cache_pos(mapping, n, offset); } filp->f_version = inode->i_version; need_revalidate = 0; @@ -328,7 +331,7 @@ ext2_readdir (struct file * filp, void * offset = (char *)de - kaddr;
[patch 12/18] Use page_cache_xxx in mm/fadvise.c
Use page_cache_xxx in mm/fadvise.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/fadvise.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/fadvise.c === --- linux-2.6.24-rc6-mm1.orig/mm/fadvise.c 2007-12-20 17:25:48.0 -0800 +++ linux-2.6.24-rc6-mm1/mm/fadvise.c 2007-12-26 19:51:07.918144462 -0800 @@ -79,8 +79,8 @@ asmlinkage long sys_fadvise64_64(int fd, } /* First and last PARTIAL page! */ - start_index = offset >> PAGE_CACHE_SHIFT; - end_index = endbyte >> PAGE_CACHE_SHIFT; + start_index = page_cache_index(mapping, offset); + end_index = page_cache_index(mapping, endbyte); /* Careful about overflow on the "+1" */ nrpages = end_index - start_index + 1; @@ -100,8 +100,8 @@ asmlinkage long sys_fadvise64_64(int fd, filemap_flush(mapping); /* First and last FULL page! */ - start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT; - end_index = (endbyte >> PAGE_CACHE_SHIFT); + start_index = page_cache_next(mapping, offset); + end_index = page_cache_index(mapping, endbyte); if (end_index >= start_index) invalidate_mapping_pages(mapping, start_index, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 13/18] Use page_cache_xxx in fs/splice.c
Use page_cache_xxx in fs/splice.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/splice.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/splice.c === --- linux-2.6.24-rc6-mm1.orig/fs/splice.c 2007-12-26 17:47:05.535424632 -0800 +++ linux-2.6.24-rc6-mm1/fs/splice.c2007-12-26 19:51:07.954144671 -0800 @@ -285,9 +285,9 @@ __generic_file_splice_read(struct file * .spd_release = spd_release_page, }; - index = *ppos >> PAGE_CACHE_SHIFT; - loff = *ppos & ~PAGE_CACHE_MASK; - req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); + loff = page_cache_offset(mapping, *ppos); + req_pages = page_cache_next(mapping, len + loff); nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS); /* @@ -342,7 +342,7 @@ __generic_file_splice_read(struct file * * Now loop over the map and see if we need to start IO on any * pages, fill in the partial map, etc. */ - index = *ppos >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); nr_pages = spd.nr_pages; spd.nr_pages = 0; for (page_nr = 0; page_nr < nr_pages; page_nr++) { @@ -354,7 +354,8 @@ __generic_file_splice_read(struct file * /* * this_len is the max we'll use from this page */ - this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); + this_len = min_t(unsigned long, len, + page_cache_size(mapping) - loff); page = pages[page_nr]; if (PageReadahead(page)) @@ -414,7 +415,7 @@ fill_it: * i_size must be checked after PageUptodate. */ isize = i_size_read(mapping->host); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) break; @@ -428,7 +429,7 @@ fill_it: /* * max good bytes in this page */ - plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + plen = page_cache_offset(mapping, isize - 1) + 1; if (plen <= loff) break; @@ -453,7 +454,7 @@ fill_it: */ while (page_nr < nr_pages) page_cache_release(pages[page_nr++]); - in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; + in->f_ra.prev_pos = page_cache_pos(mapping, index, 0); if (spd.nr_pages) return splice_to_pipe(pipe, &spd); @@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inod if (unlikely(ret)) return ret; - offset = sd->pos & ~PAGE_CACHE_MASK; + offset = page_cache_offset(mapping, sd->pos); this_len = sd->len; - if (this_len + offset > PAGE_CACHE_SIZE) - this_len = PAGE_CACHE_SIZE - offset; + if (this_len + offset > page_cache_size(mapping)) + this_len = page_cache_size(mapping) - offset; ret = pagecache_write_begin(file, mapping, sd->pos, this_len, AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata); @@ -790,7 +791,7 @@ generic_file_splice_write_nolock(struct unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, @@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_in unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 11/18] Use page_cache_xxx in mm/mpage.c
Use page_cache_xxx in mm/mpage.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/mpage.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/mpage.c === --- linux-2.6.24-rc6-mm1.orig/fs/mpage.c2007-12-26 20:14:13.518252389 -0800 +++ linux-2.6.24-rc6-mm1/fs/mpage.c 2007-12-26 21:01:38.441189402 -0800 @@ -127,7 +127,8 @@ mpage_alloc(struct block_device *bdev, static void map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; struct buffer_head *page_bh, *head; int block = 0; @@ -136,9 +137,9 @@ map_buffer_to_page(struct page *page, st * don't make any buffers if there is only one buffer on * the page and the page just needs to be set up to date */ - if (inode->i_blkbits == PAGE_CACHE_SHIFT && + if (inode->i_blkbits == page_cache_shift(mapping) && buffer_uptodate(bh)) { - SetPageUptodate(page); + SetPageUptodate(page); return; } create_empty_buffers(page, 1 << inode->i_blkbits, 0); @@ -171,9 +172,10 @@ do_mpage_readpage(struct bio *bio, struc sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; const unsigned blocksize = 1 << blkbits; sector_t block_in_file; sector_t last_block; @@ -190,7 +192,7 @@ do_mpage_readpage(struct bio *bio, struc if (page_has_buffers(page)) goto confused; - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << (page_cache_shift(mapping) - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -278,7 +280,8 @@ do_mpage_readpage(struct bio *bio, struc } if (first_hole != blocks_per_page) { - zero_user_segment(page, first_hole << blkbits, PAGE_CACHE_SIZE); + zero_user_segment(page, first_hole << blkbits, + page_cache_size(mapping)); if (first_hole == 0) { SetPageUptodate(page); unlock_page(page); @@ -456,7 +459,7 @@ static int __mpage_writepage(struct page struct inode *inode = page->mapping->host; const unsigned blkbits = inode->i_blkbits; unsigned long end_index; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; sector_t last_block; sector_t block_in_file; sector_t blocks[MAX_BUF_PER_PAGE]; @@ -525,7 +528,8 @@ static int __mpage_writepage(struct page * The page has no buffers: map it to disk */ BUG_ON(!PageUptodate(page)); - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << + (page_cache_shift(mapping) - blkbits); last_block = (i_size - 1) >> blkbits; map_bh.b_page = page; for (page_block = 0; page_block < blocks_per_page; ) { @@ -557,7 +561,7 @@ static int __mpage_writepage(struct page first_unmapped = page_block; page_is_mapped: - end_index = i_size >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, i_size); if (page->index >= end_index) { /* * The page straddles i_size. It must be zeroed out on each @@ -567,11 +571,11 @@ page_is_mapped: * is zeroed when mapped, and writes to that region are not * written out to the file." */ - unsigned offset = i_size & (PAGE_CACHE_SIZE - 1); + unsigned offset = page_cache_offset(mapping, i_size); if (page->index > end_index || !offset)
[patch 08/18] Use page_cache_xxx in fs/libfs.c
Use page_cache_xxx in fs/libfs.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/libfs.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/libfs.c === --- linux-2.6.24-rc6-mm1.orig/fs/libfs.c2007-12-26 17:47:02.519408561 -0800 +++ linux-2.6.24-rc6-mm1/fs/libfs.c 2007-12-26 19:51:07.826143940 -0800 @@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt, { struct inode *inode = dentry->d_inode; generic_fillattr(inode, stat); - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + stat->blocks = inode->i_mapping->nrpages << + (page_cache_shift(inode->i_mapping) - 9); return 0; } @@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi unsigned from, unsigned to) { if (!PageUptodate(page)) { - if (to - from != PAGE_CACHE_SIZE) + if (to - from != page_cache_size(file->f_mapping)) zero_user_segments(page, 0, from, - to, PAGE_CACHE_SIZE); + to, page_cache_size(file->f_mapping)); } return 0; } @@ -372,8 +373,9 @@ int simple_write_begin(struct file *file static int simple_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct inode *inode = page->mapping->host; - loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; + loff_t pos = page_cache_pos(mapping, page->index, to); if (!PageUptodate(page)) SetPageUptodate(page); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 09/18] Use page_cache_xxx in fs/sync
Use page_cache_xxx in fs/sync. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/sync.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/sync.c === --- linux-2.6.24-rc6-mm1.orig/fs/sync.c 2007-12-20 17:25:48.0 -0800 +++ linux-2.6.24-rc6-mm1/fs/sync.c 2007-12-26 19:51:07.850144128 -0800 @@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address ret = 0; if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); if (ret < 0) goto out; } @@ -275,8 +275,8 @@ int do_sync_mapping_range(struct address if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); } out: return ret; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 10/18] Use page_cache_xxx in fs/buffer.c
V2->V3: - alloc_page_buffers(): Add comment to explain use of page->mapping - Consistently determine mapping if there is a reference chain page->mapping->host to determine the inode. Use page_cache_xxx in fs/buffer.c. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/buffer.c | 112 ++-- 1 file changed, 65 insertions(+), 47 deletions(-) Index: linux-2.6.24-rc6-mm1/fs/buffer.c === --- linux-2.6.24-rc6-mm1.orig/fs/buffer.c 2007-12-26 20:14:13.570253343 -0800 +++ linux-2.6.24-rc6-mm1/fs/buffer.c2007-12-26 20:59:44.345078534 -0800 @@ -278,7 +278,7 @@ __find_get_block_slow(struct block_devic struct page *page; int all_mapped = 1; - index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits); + index = block >> (page_cache_shift(bd_mapping) - bd_inode->i_blkbits); page = find_get_page(bd_mapping, index); if (!page) goto out; @@ -720,7 +720,7 @@ static int __set_page_dirty(struct page __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); @@ -917,7 +917,13 @@ struct buffer_head *alloc_page_buffers(s try_again: head = NULL; - offset = PAGE_SIZE; + + /* +* Page is locked to serialize alloc_page_buffers() +* so we can use page->mapping here. +*/ + offset = page_cache_size(page->mapping); + while ((offset -= size) >= 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -1641,6 +1647,7 @@ static int __block_write_full_page(struc struct buffer_head *bh, *head; const unsigned blocksize = 1 << inode->i_blkbits; int nr_underway = 0; + struct address_space *mapping = inode->i_mapping; BUG_ON(!PageLocked(page)); @@ -1661,7 +1668,8 @@ static int __block_write_full_page(struc * handle that here by just cleaning them. */ - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + block = (sector_t)page->index << + (page_cache_shift(mapping) - inode->i_blkbits); head = page_buffers(page); bh = head; @@ -1778,7 +1786,7 @@ recover: } while ((bh = bh->b_this_page) != head); SetPageError(page); BUG_ON(PageWriteback(page)); - mapping_set_error(page->mapping, err); + mapping_set_error(mapping, err); set_page_writeback(page); do { struct buffer_head *next = bh->b_this_page; @@ -1845,8 +1853,8 @@ static int __block_prepare_write(struct struct buffer_head *bh, *head, *wait[2], **wait_bh=wait; BUG_ON(!PageLocked(page)); - BUG_ON(from > PAGE_CACHE_SIZE); - BUG_ON(to > PAGE_CACHE_SIZE); + BUG_ON(from > page_cache_size(inode->i_mapping)); + BUG_ON(to > page_cache_size(inode->i_mapping)); BUG_ON(from > to); blocksize = 1 << inode->i_blkbits; @@ -1855,7 +1863,8 @@ static int __block_prepare_write(struct head = page_buffers(page); bbits = inode->i_blkbits; - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits); + block = (sector_t)page->index << + (page_cache_shift(inode->i_mapping) - bbits); for(bh = head, block_start = 0; bh != head || !block_start; block++, block_start=block_end, bh = bh->b_this_page) { @@ -1970,8 +1979,8 @@ int block_write_begin(struct file *file, unsigned start, end; int ownpage = 0; - index = pos >> PAGE_CACHE_SHIFT; - start = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + start = page_cache_offset(mapping, pos); end = start + len; page = *pagep; @@ -2018,7 +2027,7 @@ int block_write_end(struct file *file, s struct inode *inode = mapping->host; unsigned start; - start = pos & (PAGE_CACHE_SIZE - 1); + start = page_cache_offset(mapping, pos); if (unlikely(copied < len)) { /* @@ -2083,7 +2092,8 @@ EXPORT_SYMBOL(generic_write_end); */ int block_read_full_page(struct page *page, get_block_t *get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; +
[patch 06/18] Use page_cache_xxx in mm/filemap_xip.c
Use page_cache_xxx in mm/filemap_xip.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap_xip.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/filemap_xip.c === --- linux-2.6.24-rc6-mm1.orig/mm/filemap_xip.c 2007-12-26 20:06:34.799489470 -0800 +++ linux-2.6.24-rc6-mm1/mm/filemap_xip.c 2007-12-26 20:06:58.159627986 -0800 @@ -61,24 +61,24 @@ do_xip_mapping_read(struct address_space BUG_ON(!mapping->a_ops->get_xip_page); - index = *ppos >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + offset = page_cache_offset(mapping, *ppos); isize = i_size_read(inode); if (!isize) goto out; - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); for (;;) { struct page *page; unsigned long nr, ret; /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index >= end_index) { if (index > end_index) goto out; - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_next(mapping, isize); if (nr <= offset) { goto out; } @@ -117,8 +117,8 @@ do_xip_mapping_read(struct address_space */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); if (ret == nr && desc->count) continue; @@ -131,7 +131,7 @@ no_xip_page: } out: - *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; + *ppos = page_cache_pos(mapping, index, offset); if (filp) file_accessed(filp); } @@ -220,7 +220,7 @@ static int xip_file_fault(struct vm_area /* XXX: are VM_FAULT_ codes OK? */ - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + size = page_cache_next(mapping, i_size_read(inode)); if (vmf->pgoff >= size) return VM_FAULT_SIGBUS; @@ -290,9 +290,9 @@ __xip_file_write(struct file *filp, cons size_t copied; char *kaddr; - offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ - index = pos >> PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; + offset = page_cache_offset(mapping, pos); /* Within page */ + index = page_cache_index(mapping, pos); + bytes = page_cache_size(mapping) - offset; if (bytes > count) bytes = count; @@ -403,8 +403,8 @@ EXPORT_SYMBOL_GPL(xip_file_write); int xip_truncate_page(struct address_space *mapping, loff_t from) { - pgoff_t index = from >> PAGE_CACHE_SHIFT; - unsigned offset = from & (PAGE_CACHE_SIZE-1); + pgoff_t index = page_cache_index(mapping, from); + unsigned offset = page_cache_offset(mapping, from); unsigned blocksize; unsigned length; struct page *page; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 05/18] Use page_cache_xxx in mm/rmap.c
V2->V3: - vma_address(): Check for truncation if this is a file based page. return -EFAULT if truncation occurred. - page_referenced_file(): Only use mapping after we have made sure that the mapping is valid and the page is locked. Use page_cache_xxx in mm/rmap.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/rmap.c | 23 +++ 1 file changed, 19 insertions(+), 4 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/rmap.c === --- linux-2.6.24-rc6-mm1.orig/mm/rmap.c 2007-12-26 20:35:03.773114182 -0800 +++ linux-2.6.24-rc6-mm1/mm/rmap.c 2007-12-26 20:40:28.693800636 -0800 @@ -190,9 +190,21 @@ static void page_unlock_anon_vma(struct static inline unsigned long vma_address(struct page *page, struct vm_area_struct *vma) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; unsigned long address; + if (PageAnon(page)) + pgoff = page->index; + else { + struct address_space *mapping = page->mapping; + + if (!mapping) + /* Page was truncated */ + return -EFAULT; + + pgoff = page->index << mapping_order(mapping); + } + address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); if (unlikely(address < vma->vm_start || address >= vma->vm_end)) { /* page should be within @vma mapping range */ @@ -348,7 +360,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; @@ -368,6 +380,9 @@ static int page_referenced_file(struct p */ BUG_ON(!PageLocked(page)); + /* Safe to use mapping */ + pgoff = page->index << mapping_order(mapping); + spin_lock(&mapping->i_mmap_lock); /* @@ -467,7 +482,7 @@ out: static int page_mkclean_file(struct address_space *mapping, struct page *page) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = 0; @@ -900,7 +915,7 @@ static int try_to_unmap_anon(struct page static int try_to_unmap_file(struct page *page, int migration) { struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = SWAP_AGAIN; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 07/18] Use page_cache_xxx in mm/migrate.c
V2->V3: - Only use mapping in remove_file_migration_ptes after it was checked for NULL. Use page_cache_xxx in mm/migrate.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/migrate.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: linux-2.6.24-rc6-mm1/mm/migrate.c === --- linux-2.6.24-rc6-mm1.orig/mm/migrate.c 2007-12-26 20:14:13.726253698 -0800 +++ linux-2.6.24-rc6-mm1/mm/migrate.c 2007-12-26 20:20:50.804618309 -0800 @@ -197,11 +197,12 @@ static void remove_file_migration_ptes(s struct vm_area_struct *vma; struct address_space *mapping = page_mapping(new); struct prio_tree_iter iter; - pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; if (!mapping) return; + pgoff = new->index << mapping_order(mapping); spin_lock(&mapping->i_mmap_lock); vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 02/18] Use page_cache_xxx functions in mm/filemap.c
Convert the uses of PAGE_CACHE_xxx. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap.c | 91 +-- 1 file changed, 46 insertions(+), 45 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/filemap.c === --- linux-2.6.24-rc6-mm1.orig/mm/filemap.c 2007-12-26 17:47:14.195470924 -0800 +++ linux-2.6.24-rc6-mm1/mm/filemap.c 2007-12-26 19:50:59.874095174 -0800 @@ -326,8 +326,8 @@ EXPORT_SYMBOL(add_to_page_cache_lru); int sync_page_range(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -358,8 +358,8 @@ EXPORT_SYMBOL(sync_page_range); int sync_page_range_nolock(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -388,7 +388,7 @@ int filemap_fdatawait(struct address_spa return 0; return wait_on_page_writeback_range(mapping, 0, - (i_size - 1) >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, i_size - 1)); } EXPORT_SYMBOL(filemap_fdatawait); @@ -436,8 +436,8 @@ int filemap_write_and_wait_range(struct /* See comment of filemap_write_and_wait() */ if (err != -EIO) { int err2 = wait_on_page_writeback_range(mapping, - lstart >> PAGE_CACHE_SHIFT, - lend >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, lstart), + page_cache_index(mapping, lend)); if (!err) err = err2; } @@ -909,11 +909,11 @@ void do_generic_mapping_read(struct addr unsigned int prev_offset; int error; - index = *ppos >> PAGE_CACHE_SHIFT; - prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT; - prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1); - last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + prev_index = page_cache_index(mapping, ra->prev_pos); + prev_offset = page_cache_offset(mapping, ra->prev_pos); + last_index = page_cache_next(mapping, *ppos + desc->count); + offset = page_cache_offset(mapping, *ppos); for (;;) { struct page *page; @@ -950,16 +950,16 @@ page_ok: */ isize = i_size_read(inode); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) { page_cache_release(page); goto out; } /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index == end_index) { - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_offset(mapping, isize - 1) + 1; if (nr <= offset) { page_cache_release(page); goto out; @@ -994,8 +994,8 @@ page_ok: */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); prev_offset = offset; page_cache_release(page); @@ -1085,11 +1085,8 @@ no_cached_page: } out: - ra->prev_pos = prev_index; - ra->prev_pos <<= PAGE_CACHE_SHIFT; - ra->prev_pos |= prev_offset; - - *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset; + ra->prev_pos = page_cache_pos(mapping, prev_index
[patch 04/18] Use page_cache_xxx in mm/truncate.c
Use page_cache_xxx in mm/truncate.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/truncate.c | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) Index: linux-2.6.24-rc6-mm1/mm/truncate.c === --- linux-2.6.24-rc6-mm1.orig/mm/truncate.c 2007-12-26 20:06:38.863513630 -0800 +++ linux-2.6.24-rc6-mm1/mm/truncate.c 2007-12-26 20:06:48.143568906 -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); } @@ -101,7 +102,7 @@ truncate_complete_page(struct address_sp if (PagePrivate(page)) do_invalidatepage(page, 0); - cancel_dirty_page(page, PAGE_CACHE_SIZE); + cancel_dirty_page(page, page_cache_size(mapping)); remove_from_page_cache(page); ClearPageUptodate(page); @@ -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<http://vger.kernel.org/majordomo-info.html
[patch 03/18] Use page_cache_xxx in mm/page-writeback.c
Use page_cache_xxx in mm/page-writeback.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/page-writeback.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: mm/mm/page-writeback.c === --- mm.orig/mm/page-writeback.c 2007-11-28 12:27:32.211962401 -0800 +++ mm/mm/page-writeback.c 2007-11-28 14:10:34.338227137 -0800 @@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa index = mapping->writeback_index; /* Start from prev offset */ end = -1; } else { - index = wbc->range_start >> PAGE_CACHE_SHIFT; - end = wbc->range_end >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, wbc->range_start); + end = page_cache_index(mapping, wbc->range_end); if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; scanned = 1; @@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 00/18] Page cache: Replace PAGE_CACHE_xx with inline functions V3
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls. The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices. Patchset against 2.6.24-rc6-mm1. V2->V3: - Audit to check that uses of page->mapping are valid. Improve a couple of places. Make it clearer how the mappings are determined and handled (see the comments of each patch for detailed descriptions). - Use a consistent method to determine the mapping if a function already does determine the inode via page->mapping->host. V1->V2: - Review by Dave Chinner. Multiple improvements and fixes. - Review by Fengguand Wu with more improvements. -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 01/18] Define functions for page cache handling
V2->V3: - Use "mapping" instead of "a" as the address space parameter We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK and PAGE_CACHE_ALIGN in various places in the kernel. Many times common operations like calculating the offset or the index are coded using shifts and adds. This patch provides inline functions to get the calculations accomplished without having to explicitly shift and add constants. All functions take an address_space pointer. The address space pointer will be used in the future to eventually support a variable size page cache. Information reachable via the mapping may then determine page size. New functionRelated base page constant page_cache_shift(a) PAGE_CACHE_SHIFT page_cache_size(a) PAGE_CACHE_SIZE page_cache_mask(a) PAGE_CACHE_MASK page_cache_index(a, pos)Calculate page number from position page_cache_next(addr, pos) Page number of next page page_cache_offset(a, pos) Calculate offset into a page page_cache_pos(a, index, offset) Form position based on page number and an offset. This provides a basis that would allow the conversion of all page cache handling in the kernel and ultimately allow the removal of the PAGE_CACHE_* constants. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- include/linux/pagemap.h | 53 +++- 1 file changed, 52 insertions(+), 1 deletion(-) Index: linux-2.6.24-rc6-mm1/include/linux/pagemap.h === --- linux-2.6.24-rc6-mm1.orig/include/linux/pagemap.h 2007-12-26 21:12:59.773000516 -0800 +++ linux-2.6.24-rc6-mm1/include/linux/pagemap.h2007-12-26 21:19:15.537477621 -0800 @@ -52,12 +52,61 @@ static inline void mapping_set_gfp_mask( * space in smaller chunks for same flexibility). * * Or rather, it _will_ be done in larger chunks. + * + * The following constants can be used if a filesystem only supports a single + * page size. */ #define PAGE_CACHE_SHIFT PAGE_SHIFT #define PAGE_CACHE_SIZEPAGE_SIZE #define PAGE_CACHE_MASKPAGE_MASK #define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK) +/* + * Functions that are currently setup for a fixed PAGE_SIZE. The use of + * these may allow larger page sizes in the future. + */ +static inline int mapping_order(struct address_space *mapping) +{ + return 0; +} + +static inline int page_cache_shift(struct address_space *mapping) +{ + return PAGE_SHIFT; +} + +static inline unsigned int page_cache_size(struct address_space *mapping) +{ + return PAGE_SIZE; +} + +static inline unsigned int page_cache_offset(struct address_space *mapping, + loff_t pos) +{ + return pos & ~PAGE_MASK; +} + +static inline pgoff_t page_cache_index(struct address_space *mapping, + loff_t pos) +{ + return pos >> page_cache_shift(mapping); +} + +/* + * Index of the page starting on or after the given position. + */ +static inline pgoff_t page_cache_next(struct address_space *mapping, + loff_t pos) +{ + return page_cache_index(mapping, pos + page_cache_size(mapping) - 1); +} + +static inline loff_t page_cache_pos(struct address_space *mapping, + pgoff_t index, unsigned long offset) +{ + return ((loff_t)index << page_cache_shift(mapping)) + offset; +} + #define page_cache_get(page) get_page(page) #define page_cache_release(page) put_page(page) void release_pages(struct page **pages, int nr, int cold); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 01/19] Define functions for page cache handling
On Mon, 3 Dec 2007, Andrew Morton wrote: > These will of course all work OK as they are presently implemented. > > But you have callsites doing things like > > page_cache_size(page_mapping(page)); > > which is a whole different thing. Once page_cache_size() is changed to > look inside the address_space we need to handle races against truncation > and we need to handle the address_space getting reclaimed, etc. Right. The page must be locked for that to work right. I tried to avoid the above construct as much as possible by relying on the inode mapping. I can go over this again to make sure that there is nothing amiss after the recent changes. > So I think it would be misleading to merge these changes at present - they > make it _look_ like we can have variable PAGE_CACHE_SIZE just by tweaking a > bit of core code, but we in fact cannot do that without a careful review of > all callsites and perhaps the addition of new locking and null-checking. The mapping is generally available in some form if you cannot get it from the page. In some cases I added a new parameter to functions to pass the mapping so that we do not have to use page->mapping. I can recheck that all is fine on that level. > And a coding nit: when you implement the out-of-line versions of these > functions you're going to stick with VFS conventions and use the identifier > `mapping' to identify the address_space*. So I think it would be better to > also call in `mapping' in these inlined stubbed functions, rather than `a'. > No? Ok. A trivial change. But a is shorter and made the functions more concise. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 16/19] Use page_cache_xxx in fs/ext4
Use page_cache_xxx in fs/ext4 Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext4/dir.c |3 ++- fs/ext4/inode.c | 34 +- 2 files changed, 19 insertions(+), 18 deletions(-) Index: mm/fs/ext4/dir.c === --- mm.orig/fs/ext4/dir.c 2007-11-29 11:24:20.922866366 -0800 +++ mm/fs/ext4/dir.c2007-11-29 11:29:12.515367251 -0800 @@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_size(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: mm/fs/ext4/inode.c === --- mm.orig/fs/ext4/inode.c 2007-11-29 11:24:20.934867896 -0800 +++ mm/fs/ext4/inode.c 2007-11-29 11:29:20.370866280 -0800 @@ -1110,8 +1110,8 @@ static int ext4_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1206,7 +1206,7 @@ static int ext4_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1276,7 +1276,7 @@ static int ext4_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1579,6 +1579,7 @@ static int ext4_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1601,8 +1602,7 @@ static int ext4_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext4_get_block, wbc); @@ -1619,13 +1619,12 @@ static int ext4_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, + err = walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, jbd2_journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext4_journal_stop(handle); if (!ret) ret = err; @@ -1677,6 +1676,7 @@ static int ext4_journalled_writepage(str handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext4_journal_current_handle()) goto no_write; @@ -1693,17 +1693,16 @@ static int ext4_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext4_get_block); + ret = block_prepare_write(page, 0, pagesize, ext4_get_block); if (ret != 0) { ext4_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, write_end_fn); + pagesize, NULL, write_end_fn); if (ret == 0) ret = err;
[patch 19/19] Use page_cache_xxx in drivers/block/rd.c
Use page_cache_xxx in drivers/block/rd.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- drivers/block/rd.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/drivers/block/rd.c === --- mm.orig/drivers/block/rd.c 2007-11-28 16:54:34.007439863 -0800 +++ mm/drivers/block/rd.c 2007-11-29 11:23:58.900823092 -0800 @@ -122,7 +122,7 @@ static void make_page_uptodate(struct pa } } while ((bh = bh->b_this_page) != head); } else { - memset(page_address(page), 0, PAGE_CACHE_SIZE); + memset(page_address(page), 0, page_cache_size(page_mapping(page))); } flush_dcache_page(page); SetPageUptodate(page); @@ -215,9 +215,9 @@ static const struct address_space_operat static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector, struct address_space *mapping) { - pgoff_t index = sector >> (PAGE_CACHE_SHIFT - 9); + pgoff_t index = sector >> (page_cache_shift(mapping) - 9); unsigned int vec_offset = vec->bv_offset; - int offset = (sector << 9) & ~PAGE_CACHE_MASK; + int offset = page_cache_offset(mapping, (sector << 9)); int size = vec->bv_len; int err = 0; @@ -227,7 +227,7 @@ static int rd_blkdev_pagecache_IO(int rw char *src; char *dst; - count = PAGE_CACHE_SIZE - offset; + count = page_cache_size(mapping) - offset; if (count > size) count = size; size -= count; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 17/19] Use page_cache_xxx in fs/reiserfs
Use page_cache_xxx in fs/reiserfs Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/reiserfs/file.c|6 -- fs/reiserfs/inode.c | 33 - fs/reiserfs/ioctl.c |2 +- fs/reiserfs/stree.c |5 +++-- fs/reiserfs/tail_conversion.c |5 +++-- fs/reiserfs/xattr.c | 19 ++- 6 files changed, 41 insertions(+), 29 deletions(-) Index: mm/fs/reiserfs/file.c === --- mm.orig/fs/reiserfs/file.c 2007-11-29 11:24:20.387116374 -0800 +++ mm/fs/reiserfs/file.c 2007-11-29 11:29:27.850866491 -0800 @@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *i int partial = 0; unsigned blocksize; struct buffer_head *bh, *head; - unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT; + unsigned long i_size_index = + page_cache_index(inode->i_mapping, inode->i_size); int new; int logit = reiserfs_file_data_log(inode); struct super_block *s = inode->i_sb; - int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize; + int bh_per_page = page_cache_size(inode->i_mapping) / s->s_blocksize; struct reiserfs_transaction_handle th; int ret = 0; Index: mm/fs/reiserfs/inode.c === --- mm.orig/fs/reiserfs/inode.c 2007-11-29 11:24:20.395117533 -0800 +++ mm/fs/reiserfs/inode.c 2007-11-29 11:29:36.146866339 -0800 @@ -337,7 +337,8 @@ static int _get_block_create_0(struct in goto finished; } // read file tail into part of page - offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1); + offset = page_cache_offset(inode->i_mapping, + cpu_key_k_offset(&key) - 1); fs_gen = get_generation(inode->i_sb); copy_item_head(&tmp_ih, ih); @@ -523,10 +524,10 @@ static int convert_tail_for_hole(struct return -EIO; /* always try to read until the end of the block */ - tail_start = tail_offset & (PAGE_CACHE_SIZE - 1); + tail_start = page_cache_offset(inode->i_mapping, tail_offset); tail_end = (tail_start | (bh_result->b_size - 1)) + 1; - index = tail_offset >> PAGE_CACHE_SHIFT; + index = page_cache_index(inode->i_mapping, tail_offset); /* hole_page can be zero in case of direct_io, we are sure that we cannot get here if we write with O_DIRECT into tail page */ @@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode * /* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ - unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT; + unsigned long index = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size - 1); unsigned long pos = 0; unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); struct buffer_head *bh; struct buffer_head *head; struct page *page; @@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode { struct reiserfs_transaction_handle th; /* we want the offset for the first byte after the end of the file */ - unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); unsigned blocksize = p_s_inode->i_sb->s_blocksize; unsigned length; struct page *page = NULL; @@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc } else if (is_direct_le_ih(ih)) { char *p; p = page_address(bh_result->b_page); - p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1); + p += page_cache_offset(inode->i_mapping, byte_offset - 1); copy_size = ih_item_len(ih) - pos_in_item; fs_gen = get_generation(inode->i_sb); @@ -2324,7 +2328,8 @@ static int reiserfs_write_full_page(stru struct writeback_control *wbc) { struct inode *inode = page->mapping->host; - unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT; + unsigned long end_index = page_cache_index(inode->i_mapping, +
[patch 10/19] Use page_cache_xxx in fs/buffer.c
Use page_cache_xxx in fs/buffer.c. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/buffer.c | 103 +--- 1 file changed, 57 insertions(+), 46 deletions(-) Index: mm/fs/buffer.c === --- mm.orig/fs/buffer.c 2007-11-29 11:24:22.711616548 -0800 +++ mm/fs/buffer.c 2007-11-29 11:28:05.439616400 -0800 @@ -278,7 +278,7 @@ __find_get_block_slow(struct block_devic struct page *page; int all_mapped = 1; - index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits); + index = block >> (page_cache_shift(bd_mapping) - bd_inode->i_blkbits); page = find_get_page(bd_mapping, index); if (!page) goto out; @@ -720,7 +720,7 @@ static int __set_page_dirty(struct page __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); @@ -917,7 +917,7 @@ struct buffer_head *alloc_page_buffers(s try_again: head = NULL; - offset = PAGE_SIZE; + offset = page_cache_size(page->mapping); while ((offset -= size) >= 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -1640,6 +1640,7 @@ static int __block_write_full_page(struc struct buffer_head *bh, *head; const unsigned blocksize = 1 << inode->i_blkbits; int nr_underway = 0; + struct address_space *mapping = inode->i_mapping; BUG_ON(!PageLocked(page)); @@ -1660,7 +1661,8 @@ static int __block_write_full_page(struc * handle that here by just cleaning them. */ - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + block = (sector_t)page->index << + (page_cache_shift(mapping) - inode->i_blkbits); head = page_buffers(page); bh = head; @@ -1777,7 +1779,7 @@ recover: } while ((bh = bh->b_this_page) != head); SetPageError(page); BUG_ON(PageWriteback(page)); - mapping_set_error(page->mapping, err); + mapping_set_error(mapping, err); set_page_writeback(page); do { struct buffer_head *next = bh->b_this_page; @@ -1844,8 +1846,8 @@ static int __block_prepare_write(struct struct buffer_head *bh, *head, *wait[2], **wait_bh=wait; BUG_ON(!PageLocked(page)); - BUG_ON(from > PAGE_CACHE_SIZE); - BUG_ON(to > PAGE_CACHE_SIZE); + BUG_ON(from > page_cache_size(inode->i_mapping)); + BUG_ON(to > page_cache_size(inode->i_mapping)); BUG_ON(from > to); blocksize = 1 << inode->i_blkbits; @@ -1854,7 +1856,8 @@ static int __block_prepare_write(struct head = page_buffers(page); bbits = inode->i_blkbits; - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits); + block = (sector_t)page->index << + (page_cache_shift(inode->i_mapping) - bbits); for(bh = head, block_start = 0; bh != head || !block_start; block++, block_start=block_end, bh = bh->b_this_page) { @@ -1969,8 +1972,8 @@ int block_write_begin(struct file *file, unsigned start, end; int ownpage = 0; - index = pos >> PAGE_CACHE_SHIFT; - start = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + start = page_cache_offset(mapping, pos); end = start + len; page = *pagep; @@ -2017,7 +2020,7 @@ int block_write_end(struct file *file, s struct inode *inode = mapping->host; unsigned start; - start = pos & (PAGE_CACHE_SIZE - 1); + start = page_cache_offset(mapping, pos); if (unlikely(copied < len)) { /* @@ -2095,7 +2098,8 @@ int block_read_full_page(struct page *pa create_empty_buffers(page, blocksize, 0); head = page_buffers(page); - iblock = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + iblock = (sector_t)page->index << + (page_cache_shift(page->mapping) - inode->i_blkbits); lblock = (i_size_read(inode)+blocksize-1) >> inode->i_blkbits; bh = head; nr = 0; @@ -2213,16 +2217,17 @@ int cont_expand_zero(struct file *file, unsigned zerofrom, offset, len; int err = 0; - index = pos >>
[patch 08/19] Use page_cache_xxx in fs/libfs.c
Use page_cache_xxx in fs/libfs.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/libfs.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) Index: mm/fs/libfs.c === --- mm.orig/fs/libfs.c 2007-11-28 12:24:57.449215408 -0800 +++ mm/fs/libfs.c 2007-11-28 14:10:51.773477763 -0800 @@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt, { struct inode *inode = dentry->d_inode; generic_fillattr(inode, stat); - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + stat->blocks = inode->i_mapping->nrpages << + (page_cache_shift(inode->i_mapping) - 9); return 0; } @@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi unsigned from, unsigned to) { if (!PageUptodate(page)) { - if (to - from != PAGE_CACHE_SIZE) + if (to - from != page_cache_size(file->f_mapping)) zero_user_segments(page, 0, from, - to, PAGE_CACHE_SIZE); + to, page_cache_size(file->f_mapping)); } return 0; } @@ -372,8 +373,9 @@ int simple_write_begin(struct file *file static int simple_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct inode *inode = page->mapping->host; - loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; + loff_t pos = page_cache_pos(mapping, page->index, to); if (!PageUptodate(page)) SetPageUptodate(page); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 18/19] Use page_cache_xxx for fs/xfs
Use page_cache_xxx for fs/xfs Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/xfs/linux-2.6/xfs_aops.c | 55 ++-- fs/xfs/linux-2.6/xfs_lrw.c |4 +-- 2 files changed, 30 insertions(+), 29 deletions(-) Index: mm/fs/xfs/linux-2.6/xfs_aops.c === --- mm.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-11-29 11:24:19.606866627 -0800 +++ mm/fs/xfs/linux-2.6/xfs_aops.c 2007-11-29 11:29:55.115116317 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_offset(page); + loff_t offset = page_cache_pos(page->mapping, page->index, 0); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -618,7 +618,7 @@ xfs_probe_page( break; } while ((bh = bh->b_this_page) != head); } else - ret = mapped ? 0 : PAGE_CACHE_SIZE; + ret = mapped ? 0 : page_cache_size(page->mapping); } return ret; @@ -645,7 +645,7 @@ xfs_probe_cluster( } while ((bh = bh->b_this_page) != head); /* if we reached the end of the page, sum forwards in following pages */ - tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT; + tlast = page_cache_index(inode->i_mapping, i_size_read(inode)); tindex = startpage->index + 1; /* Prune this back to avoid pathological behavior */ @@ -663,14 +663,14 @@ xfs_probe_cluster( size_t pg_offset, pg_len = 0; if (tindex == tlast) { - pg_offset = - i_size_read(inode) & (PAGE_CACHE_SIZE - 1); + pg_offset = page_cache_offset(inode->i_mapping, + i_size_read(inode)); if (!pg_offset) { done = 1; break; } } else - pg_offset = PAGE_CACHE_SIZE; + pg_offset = page_cache_size(inode->i_mapping); if (page->index == tindex && !TestSetPageLocked(page)) { pg_len = xfs_probe_page(page, pg_offset, mapped); @@ -752,7 +752,8 @@ xfs_convert_page( int bbits = inode->i_blkbits; int len, page_dirty; int count = 0, done = 0, uptodate = 1; - xfs_off_t offset = page_offset(page); + struct address_space*map = inode->i_mapping; + xfs_off_t offset = page_cache_pos(map, page->index, 0); if (page->index != tindex) goto fail; @@ -760,7 +761,7 @@ xfs_convert_page( goto fail; if (PageWriteback(page)) goto fail_unlock_page; - if (page->mapping != inode->i_mapping) + if (page->mapping != map) goto fail_unlock_page; if (!xfs_is_delayed_page(page, (*ioendp)->io_type)) goto fail_unlock_page; @@ -772,20 +773,19 @@ xfs_convert_page( * Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset & page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT, + (xfs_off_t)page_cache_pos(map, page->index + 1, 0), i_size_read(inode)); len = 1 << inode->i_blkbits; - p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1), - PAGE_CACHE_SIZE); - p_offset = p_offset ? roundup(p_offset, len) : PAGE_CACHE_SIZE; + p_offset = page_cache_offset(map, end_offset); + p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map); page_dirty = p_offset / len; bh = head = page_buffers(page); @@ -941,6 +941,7 @@ xfs_page_state_con
[patch 14/19] Use page_cache_xxx in ext2
Use page_cache_xxx functions in fs/ext2/* Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext2/dir.c | 41 +++-- 1 file changed, 23 insertions(+), 18 deletions(-) Index: mm/fs/ext2/dir.c === --- mm.orig/fs/ext2/dir.c 2007-11-29 11:30:12.447616737 -0800 +++ mm/fs/ext2/dir.c2007-11-29 11:53:40.599116418 -0800 @@ -63,7 +63,7 @@ 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 page_cache_next(inode->i_mapping, inode->i_size); } /* @@ -74,10 +74,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_cache_pos(mapping, page_nr, 0); + if (last_byte > page_cache_size(mapping)) + last_byte = page_cache_size(mapping); return last_byte; } @@ -105,18 +106,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 +170,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<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 +179,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<i_ino, page_cache_pos(mapping, page->index, offs), (unsigned long) le32_to_cpu(p->inode)); fail: SetPageChecked(page); @@ -276,8 +278,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 +301,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<f_pos = page_cache_pos(mapping, n, offset); } filp->f_version = inode->i_version; need_revalidate = 0; @@ -328,7 +331,7 @@ ext2_readdir (struct file * filp, void * offset = (char *)de - kaddr; over = filldir(dirent, de->nam
[patch 15/19] Use page_cache_xxx in fs/ext3
Use page_cache_xxx in fs/ext3 Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext3/dir.c |3 ++- fs/ext3/inode.c | 39 --- 2 files changed, 22 insertions(+), 20 deletions(-) Index: mm/fs/ext3/dir.c === --- mm.orig/fs/ext3/dir.c 2007-11-16 21:16:36.0 -0800 +++ mm/fs/ext3/dir.c2007-11-28 14:11:16.689227316 -0800 @@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_shift(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: mm/fs/ext3/inode.c === --- mm.orig/fs/ext3/inode.c 2007-11-28 12:24:24.567962333 -0800 +++ mm/fs/ext3/inode.c 2007-11-28 14:11:16.701086757 -0800 @@ -1159,8 +1159,8 @@ static int ext3_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1256,7 +1256,7 @@ static int ext3_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1326,7 +1326,7 @@ static int ext3_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1489,6 +1489,7 @@ static int ext3_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1511,8 +1512,7 @@ static int ext3_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext3_get_block, wbc); @@ -1529,13 +1529,12 @@ static int ext3_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, - NULL, journal_dirty_data_fn); + err = walk_page_buffers(handle, page_bufs, 0, pagesize, + NULL, journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext3_journal_stop(handle); if (!ret) ret = err; @@ -1583,10 +1582,12 @@ out_fail: static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext3_journal_current_handle()) goto no_write; @@ -1603,17 +1604,16 @@ static int ext3_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext3_get_block); + ret = block_prepare_write(page, 0, pagesize, ext3_get_block); if (ret != 0) { ext3_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, N
[patch 13/19] Use page_cache_xxx in fs/splice.c
Use page_cache_xxx in fs/splice.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/splice.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) Index: mm/fs/splice.c === --- mm.orig/fs/splice.c 2007-11-29 11:24:21.758866659 -0800 +++ mm/fs/splice.c 2007-11-29 11:28:38.627616484 -0800 @@ -285,9 +285,9 @@ __generic_file_splice_read(struct file * .spd_release = spd_release_page, }; - index = *ppos >> PAGE_CACHE_SHIFT; - loff = *ppos & ~PAGE_CACHE_MASK; - req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); + loff = page_cache_offset(mapping, *ppos); + req_pages = page_cache_next(mapping, len + loff); nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS); /* @@ -342,7 +342,7 @@ __generic_file_splice_read(struct file * * Now loop over the map and see if we need to start IO on any * pages, fill in the partial map, etc. */ - index = *ppos >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); nr_pages = spd.nr_pages; spd.nr_pages = 0; for (page_nr = 0; page_nr < nr_pages; page_nr++) { @@ -354,7 +354,8 @@ __generic_file_splice_read(struct file * /* * this_len is the max we'll use from this page */ - this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); + this_len = min_t(unsigned long, len, + page_cache_size(mapping) - loff); page = pages[page_nr]; if (PageReadahead(page)) @@ -414,7 +415,7 @@ fill_it: * i_size must be checked after PageUptodate. */ isize = i_size_read(mapping->host); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) break; @@ -428,7 +429,7 @@ fill_it: /* * max good bytes in this page */ - plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + plen = page_cache_offset(mapping, isize - 1) + 1; if (plen <= loff) break; @@ -453,7 +454,7 @@ fill_it: */ while (page_nr < nr_pages) page_cache_release(pages[page_nr++]); - in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; + in->f_ra.prev_pos = page_cache_pos(mapping, index, 0); if (spd.nr_pages) return splice_to_pipe(pipe, &spd); @@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inod if (unlikely(ret)) return ret; - offset = sd->pos & ~PAGE_CACHE_MASK; + offset = page_cache_offset(mapping, sd->pos); this_len = sd->len; - if (this_len + offset > PAGE_CACHE_SIZE) - this_len = PAGE_CACHE_SIZE - offset; + if (this_len + offset > page_cache_size(mapping)) + this_len = page_cache_size(mapping) - offset; ret = pagecache_write_begin(file, mapping, sd->pos, this_len, AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata); @@ -790,7 +791,7 @@ generic_file_splice_write_nolock(struct unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, @@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_in unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 09/19] Use page_cache_xxx in fs/sync
Use page_cache_xxx in fs/sync. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/sync.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/fs/sync.c === --- mm.orig/fs/sync.c 2007-11-16 21:16:36.0 -0800 +++ mm/fs/sync.c2007-11-28 14:10:56.269227507 -0800 @@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address ret = 0; if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); if (ret < 0) goto out; } @@ -275,8 +275,8 @@ int do_sync_mapping_range(struct address if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); } out: return ret; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 02/19] Use page_cache_xxx functions in mm/filemap.c
Convert the uses of PAGE_CACHE_xxx. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap.c | 91 +-- 1 file changed, 46 insertions(+), 45 deletions(-) Index: mm/mm/filemap.c === --- mm.orig/mm/filemap.c2007-11-29 12:05:41.419866445 -0800 +++ mm/mm/filemap.c 2007-11-29 12:08:07.364365995 -0800 @@ -314,8 +314,8 @@ EXPORT_SYMBOL(add_to_page_cache_lru); int sync_page_range(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -346,8 +346,8 @@ EXPORT_SYMBOL(sync_page_range); int sync_page_range_nolock(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -376,7 +376,7 @@ int filemap_fdatawait(struct address_spa return 0; return wait_on_page_writeback_range(mapping, 0, - (i_size - 1) >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, i_size - 1)); } EXPORT_SYMBOL(filemap_fdatawait); @@ -424,8 +424,8 @@ int filemap_write_and_wait_range(struct /* See comment of filemap_write_and_wait() */ if (err != -EIO) { int err2 = wait_on_page_writeback_range(mapping, - lstart >> PAGE_CACHE_SHIFT, - lend >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, lstart), + page_cache_index(mapping, lend)); if (!err) err = err2; } @@ -897,11 +897,11 @@ void do_generic_mapping_read(struct addr unsigned int prev_offset; int error; - index = *ppos >> PAGE_CACHE_SHIFT; - prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT; - prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1); - last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + prev_index = page_cache_index(mapping, ra->prev_pos); + prev_offset = page_cache_offset(mapping, ra->prev_pos); + last_index = page_cache_next(mapping, *ppos + desc->count); + offset = page_cache_offset(mapping, *ppos); for (;;) { struct page *page; @@ -938,16 +938,16 @@ page_ok: */ isize = i_size_read(inode); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) { page_cache_release(page); goto out; } /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index == end_index) { - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_offset(mapping, isize - 1) + 1; if (nr <= offset) { page_cache_release(page); goto out; @@ -982,8 +982,8 @@ page_ok: */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); prev_offset = offset; page_cache_release(page); @@ -1073,11 +1073,8 @@ no_cached_page: } out: - ra->prev_pos = prev_index; - ra->prev_pos <<= PAGE_CACHE_SHIFT; - ra->prev_pos |= prev_offset; - - *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset; + ra->prev_pos = page_cache_pos(mapping, prev_index, prev_offset); + *ppos = page_cache_
[patch 06/19] Use page_cache_xxx in mm/filemap_xip.c
Use page_cache_xxx in mm/filemap_xip.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap_xip.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) Index: mm/mm/filemap_xip.c === --- mm.orig/mm/filemap_xip.c2007-11-29 11:24:22.988616641 -0800 +++ mm/mm/filemap_xip.c 2007-11-29 11:27:35.295767656 -0800 @@ -60,24 +60,24 @@ do_xip_mapping_read(struct address_space BUG_ON(!mapping->a_ops->get_xip_page); - index = *ppos >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + offset = page_cache_offset(mapping, *ppos); isize = i_size_read(inode); if (!isize) goto out; - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); for (;;) { struct page *page; unsigned long nr, ret; /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index >= end_index) { if (index > end_index) goto out; - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_next(mapping, isize); if (nr <= offset) { goto out; } @@ -116,8 +116,8 @@ do_xip_mapping_read(struct address_space */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); if (ret == nr && desc->count) continue; @@ -130,7 +130,7 @@ no_xip_page: } out: - *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; + *ppos = page_cache_pos(mapping, index, offset); if (filp) file_accessed(filp); } @@ -219,7 +219,7 @@ static int xip_file_fault(struct vm_area /* XXX: are VM_FAULT_ codes OK? */ - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + size = page_cache_next(mapping, i_size_read(inode)); if (vmf->pgoff >= size) return VM_FAULT_SIGBUS; @@ -289,9 +289,9 @@ __xip_file_write(struct file *filp, cons size_t copied; char *kaddr; - offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ - index = pos >> PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; + offset = page_cache_offset(mapping, pos); /* Within page */ + index = page_cache_index(mapping, pos); + bytes = page_cache_size(mapping) - offset; if (bytes > count) bytes = count; @@ -402,8 +402,8 @@ EXPORT_SYMBOL_GPL(xip_file_write); int xip_truncate_page(struct address_space *mapping, loff_t from) { - pgoff_t index = from >> PAGE_CACHE_SHIFT; - unsigned offset = from & (PAGE_CACHE_SIZE-1); + pgoff_t index = page_cache_index(mapping, from); + unsigned offset = page_cache_offset(mapping, from); unsigned blocksize; unsigned length; struct page *page; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 12/19] Use page_cache_xxx in mm/fadvise.c
Use page_cache_xxx in mm/fadvise.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/fadvise.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/mm/fadvise.c === --- mm.orig/mm/fadvise.c2007-11-29 11:24:21.818866688 -0800 +++ mm/mm/fadvise.c 2007-11-29 11:28:23.520116366 -0800 @@ -79,8 +79,8 @@ asmlinkage long sys_fadvise64_64(int fd, } /* First and last PARTIAL page! */ - start_index = offset >> PAGE_CACHE_SHIFT; - end_index = endbyte >> PAGE_CACHE_SHIFT; + start_index = page_cache_index(mapping, offset); + end_index = page_cache_index(mapping, endbyte); /* Careful about overflow on the "+1" */ nrpages = end_index - start_index + 1; @@ -100,8 +100,8 @@ asmlinkage long sys_fadvise64_64(int fd, filemap_flush(mapping); /* First and last FULL page! */ - start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT; - end_index = (endbyte >> PAGE_CACHE_SHIFT); + start_index = page_cache_next(mapping, offset); + end_index = page_cache_index(mapping, endbyte); if (end_index >= start_index) invalidate_mapping_pages(mapping, start_index, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 04/19] Use page_cache_xxx in mm/truncate.c
Use page_cache_xxx in mm/truncate.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- 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.c2007-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<http://vger.kernel.org/majordomo-info.html
[patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls. The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices. Patchset against 2.6.24-rc3-mm2. V1->V2: - Review by Dave Chinner. Multiple improvements and fixes. - Review by Fengguand Wu with more improvements. -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 07/19] Use page_cache_xxx in mm/migrate.c
Use page_cache_xxx in mm/migrate.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/migrate.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: mm/mm/migrate.c === --- mm.orig/mm/migrate.c2007-11-28 12:27:32.184464256 -0800 +++ mm/mm/migrate.c 2007-11-28 14:10:49.200977227 -0800 @@ -197,7 +197,7 @@ static void remove_file_migration_ptes(s struct vm_area_struct *vma; struct address_space *mapping = page_mapping(new); struct prio_tree_iter iter; - pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = new->index << mapping_order(mapping); if (!mapping) return; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 03/19] Use page_cache_xxx in mm/page-writeback.c
Use page_cache_xxx in mm/page-writeback.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/page-writeback.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: mm/mm/page-writeback.c === --- mm.orig/mm/page-writeback.c 2007-11-28 12:27:32.211962401 -0800 +++ mm/mm/page-writeback.c 2007-11-28 14:10:34.338227137 -0800 @@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa index = mapping->writeback_index; /* Start from prev offset */ end = -1; } else { - index = wbc->range_start >> PAGE_CACHE_SHIFT; - end = wbc->range_end >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, wbc->range_start); + end = page_cache_index(mapping, wbc->range_end); if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; scanned = 1; @@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 11/19] Use page_cache_xxx in mm/mpage.c
Use page_cache_xxx in mm/mpage.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/mpage.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) Index: mm/fs/mpage.c === --- mm.orig/fs/mpage.c 2007-11-29 11:24:22.074866737 -0800 +++ mm/fs/mpage.c 2007-11-29 11:28:19.422866356 -0800 @@ -127,7 +127,8 @@ mpage_alloc(struct block_device *bdev, static void map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; struct buffer_head *page_bh, *head; int block = 0; @@ -136,9 +137,9 @@ map_buffer_to_page(struct page *page, st * don't make any buffers if there is only one buffer on * the page and the page just needs to be set up to date */ - if (inode->i_blkbits == PAGE_CACHE_SHIFT && + if (inode->i_blkbits == page_cache_shift(mapping) && buffer_uptodate(bh)) { - SetPageUptodate(page); + SetPageUptodate(page); return; } create_empty_buffers(page, 1 << inode->i_blkbits, 0); @@ -171,9 +172,10 @@ do_mpage_readpage(struct bio *bio, struc sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; const unsigned blocksize = 1 << blkbits; sector_t block_in_file; sector_t last_block; @@ -190,7 +192,7 @@ do_mpage_readpage(struct bio *bio, struc if (page_has_buffers(page)) goto confused; - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << (page_cache_shift(mapping) - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -278,7 +280,8 @@ do_mpage_readpage(struct bio *bio, struc } if (first_hole != blocks_per_page) { - zero_user_segment(page, first_hole << blkbits, PAGE_CACHE_SIZE); + zero_user_segment(page, first_hole << blkbits, + page_cache_size(mapping)); if (first_hole == 0) { SetPageUptodate(page); unlock_page(page); @@ -456,7 +459,7 @@ static int __mpage_writepage(struct page struct inode *inode = page->mapping->host; const unsigned blkbits = inode->i_blkbits; unsigned long end_index; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; sector_t last_block; sector_t block_in_file; sector_t blocks[MAX_BUF_PER_PAGE]; @@ -525,7 +528,8 @@ static int __mpage_writepage(struct page * The page has no buffers: map it to disk */ BUG_ON(!PageUptodate(page)); - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << + (page_cache_shift(mapping) - blkbits); last_block = (i_size - 1) >> blkbits; map_bh.b_page = page; for (page_block = 0; page_block < blocks_per_page; ) { @@ -557,7 +561,7 @@ static int __mpage_writepage(struct page first_unmapped = page_block; page_is_mapped: - end_index = i_size >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, i_size); if (page->index >= end_index) { /* * The page straddles i_size. It must be zeroed out on each @@ -567,11 +571,11 @@ page_is_mapped: * is zeroed when mapped, and writes to that region are not * written out to the file." */ - unsigned offset = i_size & (PAGE_CACHE_SIZE - 1); + unsigned offset = page_cache_offset(mapping, i_size); if (page->index > end_index || !offset) goto confused; - zero_user_s
[patch 01/19] Define functions for page cache handling
We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK and PAGE_CACHE_ALIGN in various places in the kernel. Many times common operations like calculating the offset or the index are coded using shifts and adds. This patch provides inline functions to get the calculations accomplished without having to explicitly shift and add constants. All functions take an address_space pointer. The address space pointer will be used in the future to eventually support a variable size page cache. Information reachable via the mapping may then determine page size. New functionRelated base page constant page_cache_shift(a) PAGE_CACHE_SHIFT page_cache_size(a) PAGE_CACHE_SIZE page_cache_mask(a) PAGE_CACHE_MASK page_cache_index(a, pos)Calculate page number from position page_cache_next(addr, pos) Page number of next page page_cache_offset(a, pos) Calculate offset into a page page_cache_pos(a, index, offset) Form position based on page number and an offset. This provides a basis that would allow the conversion of all page cache handling in the kernel and ultimately allow the removal of the PAGE_CACHE_* constants. Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- include/linux/pagemap.h | 53 +++- 1 file changed, 52 insertions(+), 1 deletion(-) Index: mm/include/linux/pagemap.h === --- mm.orig/include/linux/pagemap.h 2007-11-29 12:27:53.878812858 -0800 +++ mm/include/linux/pagemap.h 2007-11-29 12:28:42.063283655 -0800 @@ -52,12 +52,61 @@ static inline void mapping_set_gfp_mask( * space in smaller chunks for same flexibility). * * Or rather, it _will_ be done in larger chunks. + * + * The following constants can be used if a filesystem only supports a single + * page size. */ #define PAGE_CACHE_SHIFT PAGE_SHIFT #define PAGE_CACHE_SIZEPAGE_SIZE #define PAGE_CACHE_MASKPAGE_MASK #define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK) +/* + * Functions that are currently setup for a fixed PAGE_SIZEd. The use of + * these will allow the user of largere page sizes in the future. + */ +static inline int mapping_order(struct address_space *a) +{ + return 0; +} + +static inline int page_cache_shift(struct address_space *a) +{ + return PAGE_SHIFT; +} + +static inline unsigned int page_cache_size(struct address_space *a) +{ + return PAGE_SIZE; +} + +static inline unsigned int page_cache_offset(struct address_space *a, + loff_t pos) +{ + return pos & ~PAGE_MASK; +} + +static inline pgoff_t page_cache_index(struct address_space *a, + loff_t pos) +{ + return pos >> page_cache_shift(a); +} + +/* + * Index of the page starting on or after the given position. + */ +static inline pgoff_t page_cache_next(struct address_space *a, + loff_t pos) +{ + return page_cache_index(a, pos + page_cache_size(a) - 1); +} + +static inline loff_t page_cache_pos(struct address_space *a, + pgoff_t index, unsigned long offset) +{ + return ((loff_t)index << page_cache_shift(a)) + offset; +} + #define page_cache_get(page) get_page(page) #define page_cache_release(page) put_page(page) void release_pages(struct page **pages, int nr, int cold); @@ -142,10 +191,12 @@ extern void __remove_from_page_cache(str /* * Return byte-offset into filesystem object for page. + * Note: Assumes a mapping of order 0. + * Use page_cache_pos to allow larger pages. */ static inline loff_t page_offset(struct page *page) { - return ((loff_t)page->index) << PAGE_CACHE_SHIFT; + return page->index << PAGE_CACHE_SHIFT; } static inline pgoff_t linear_page_index(struct vm_area_struct *vma, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 05/19] Use page_cache_xxx in mm/rmap.c
Use page_cache_xxx in mm/rmap.c Reviewed-by: Dave Chinner <[EMAIL PROTECTED]> Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/rmap.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) Index: mm/mm/rmap.c === --- mm.orig/mm/rmap.c 2007-11-29 11:24:23.371116810 -0800 +++ mm/mm/rmap.c2007-11-29 11:25:27.551396075 -0800 @@ -190,9 +190,14 @@ static void page_unlock_anon_vma(struct static inline unsigned long vma_address(struct page *page, struct vm_area_struct *vma) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; unsigned long address; + if (PageAnon(page)) + pgoff = page->index; + else + pgoff = page->index << mapping_order(page->mapping); + address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); if (unlikely(address < vma->vm_start || address >= vma->vm_end)) { /* page should be within @vma mapping range */ @@ -345,7 +350,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; @@ -464,7 +469,7 @@ out: static int page_mkclean_file(struct address_space *mapping, struct page *page) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = 0; @@ -897,7 +902,7 @@ static int try_to_unmap_anon(struct page static int try_to_unmap_file(struct page *page, int migration) { struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = SWAP_AGAIN; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 01/19] Define functions for page cache handling
On Thu, 29 Nov 2007, Fengguang Wu wrote: > On Wed, Nov 28, 2007 at 05:10:53PM -0800, Christoph Lameter wrote: > > +static inline loff_t page_cache_mask(struct address_space *a) > > +{ > > + return (loff_t)PAGE_MASK; > > +} > > A tiny question: Why choose loff_t instead of 'unsigned long'? > > It's not obvious because page_cache_mask() is not referenced in this > patchset at all ;-) Ok Then lets drop page_cache_mask completely. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 14/19] Use page_cache_xxx in ext2
On Thu, 29 Nov 2007, David Chinner wrote: > I don't think that gives the same return value. The return value > is supposed to be clamped at a maximum of page_cache_size(mapping). Ok. So this? ext2: Simplify some functions Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext2/dir.c |5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) Index: mm/fs/ext2/dir.c === --- mm.orig/fs/ext2/dir.c 2007-11-28 20:13:07.387132777 -0800 +++ mm/fs/ext2/dir.c2007-11-28 20:14:35.739632586 -0800 @@ -63,8 +63,7 @@ static inline void ext2_put_page(struct static inline unsigned long dir_pages(struct inode *inode) { - return (inode->i_size+page_cache_size(inode->i_mapping)-1)>> - page_cache_shift(inode->i_mapping); + return page_cache_next(inode->i_mapping, inode->i_size); } /* @@ -77,7 +76,7 @@ ext2_last_byte(struct inode *inode, unsi unsigned last_byte = inode->i_size; struct address_space *mapping = inode->i_mapping; - last_byte -= page_nr << page_cache_shift(mapping); + last_byte -= page_cache_pos(mapping, page_nr, 0); if (last_byte > page_cache_size(mapping)) last_byte = page_cache_size(mapping); return last_byte; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
On Thu, 29 Nov 2007, David Chinner wrote: > And the other two occurrences of this in the first patch? Ahh... Ok they are also in rmap.c: rmap: simplify page_referenced_file use of page cache inlines Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/rmap.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: mm/mm/rmap.c === --- mm.orig/mm/rmap.c 2007-11-28 20:03:15.255240262 -0800 +++ mm/mm/rmap.c2007-11-28 20:08:50.278132294 -0800 @@ -350,7 +350,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; @@ -469,7 +469,7 @@ out: static int page_mkclean_file(struct address_space *mapping, struct page *page) { - pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = 0; @@ -902,7 +902,7 @@ static int try_to_unmap_anon(struct page static int try_to_unmap_file(struct page *page, int migration) { struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = SWAP_AGAIN; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
Is this correct? Fixes to the use of page_cache_xx functions in xfs Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/xfs/linux-2.6/xfs_aops.c | 18 -- fs/xfs/linux-2.6/xfs_lrw.c |2 +- 2 files changed, 9 insertions(+), 11 deletions(-) Index: mm/fs/xfs/linux-2.6/xfs_aops.c === --- mm.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-11-28 19:13:13.323382722 -0800 +++ mm/fs/xfs/linux-2.6/xfs_aops.c 2007-11-28 20:04:24.230882714 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_cache_offset(page->mapping); + loff_t offset = page_cache_pos(page->mapping, page->index, 0); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -780,12 +780,11 @@ xfs_convert_page( * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << page_cache_shift(map), + (xfs_off_t)page_cache_pos(map, page->index + 1, 0), i_size_read(inode)); len = 1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - page_cache_size(map)); + p_offset = page_cache_offset(map, end_offset); p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map); page_dirty = p_offset / len; @@ -943,7 +942,6 @@ xfs_page_state_convert( int trylock = 0; int all_bh = unmapped; struct address_space*map = inode->i_mapping; - int pagesize = page_cache_size(map); if (startio) { if (wbc->sync_mode == WB_SYNC_NONE && wbc->nonblocking) @@ -979,9 +977,9 @@ xfs_page_state_convert( end_offset = min_t(unsigned long long, (xfs_off_t)page_cache_pos(map, page->index + 1, 0), offset); len = 1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - pagesize); - p_offset = p_offset ? roundup(p_offset, len) : pagesize; + p_offset = page_cache_offset(map, end_offset); + p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map); + page_dirty = p_offset / len; bh = head = page_buffers(page); @@ -1132,8 +1130,8 @@ xfs_page_state_convert( xfs_start_page_writeback(page, wbc, 1, count); if (ioend && iomap_valid) { - offset = (iomap.iomap_offset + iomap.iomap_bsize - 1) >> - page_cache_shift(map); + offset = page_cache_index(map, + (iomap.iomap_offset + iomap.iomap_bsize - 1)); tlast = min_t(pgoff_t, offset, last_index); xfs_cluster_write(inode, page->index + 1, &iomap, &ioend, wbc, startio, all_bh, tlast); Index: mm/fs/xfs/linux-2.6/xfs_lrw.c === --- mm.orig/fs/xfs/linux-2.6/xfs_lrw.c 2007-11-28 19:22:35.454383115 -0800 +++ mm/fs/xfs/linux-2.6/xfs_lrw.c 2007-11-28 19:22:59.222132796 -0800 @@ -142,7 +142,7 @@ xfs_iozero( unsigned offset, bytes; void *fsdata; - offset = page_cache_offset(mapping, pos); /* Within page */ + offset = page_cache_offset(mapping, pos); bytes = page_cache_size(mapping) - offset; if (bytes > count) bytes = count; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 17/19] Use page_cache_xxx in fs/reiserfs
On Thu, 29 Nov 2007, David Chinner wrote: > > unsigned long start = 0; > > unsigned long blocksize = p_s_inode->i_sb->s_blocksize; > > - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); > > + unsigned long offset = page_cache_index(p_s_inode->i_mapping, > > + p_s_inode->i_size); > > unsigned long offset = page_cache_offset(p_s_inode->i_mapping, > Reiserfs: Wrong type of inline function Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/reiserfs/inode.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: mm/fs/reiserfs/inode.c === --- mm.orig/fs/reiserfs/inode.c 2007-11-28 19:59:41.083133259 -0800 +++ mm/fs/reiserfs/inode.c 2007-11-28 20:00:23.317882809 -0800 @@ -2006,7 +2006,7 @@ static int grab_tail_page(struct inode * unsigned long pos = 0; unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = page_cache_index(p_s_inode->i_mapping, + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, p_s_inode->i_size); struct buffer_head *bh; struct buffer_head *head; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 16/19] Use page_cache_xxx in fs/ext4
On Thu, 29 Nov 2007, David Chinner wrote: > These three should use the pagesize variable. ext4: use pagesize variable instead of the inline function Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext4/inode.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) Index: mm/fs/ext4/inode.c === --- mm.orig/fs/ext4/inode.c 2007-11-28 19:56:18.234382799 -0800 +++ mm/fs/ext4/inode.c 2007-11-28 19:57:10.774132672 -0800 @@ -1693,17 +1693,16 @@ static int ext4_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, page_cache_size(mapping), - ext4_get_block); + ret = block_prepare_write(page, 0, pagesize, ext4_get_block); if (ret != 0) { ext4_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - page_cache_size(mapping), NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page), 0, - page_cache_size(mapping), NULL, write_end_fn); + pagesize, NULL, write_end_fn); if (ret == 0) ret = err; EXT4_I(inode)->i_state |= EXT4_STATE_JDATA; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 14/19] Use page_cache_xxx in ext2
ext2: Simplify some functions Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext2/dir.c |9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) Index: mm/fs/ext2/dir.c === --- mm.orig/fs/ext2/dir.c 2007-11-28 19:51:05.038882954 -0800 +++ mm/fs/ext2/dir.c2007-11-28 19:53:59.074132710 -0800 @@ -63,8 +63,7 @@ static inline void ext2_put_page(struct static inline unsigned long dir_pages(struct inode *inode) { - return (inode->i_size+page_cache_size(inode->i_mapping)-1)>> - page_cache_shift(inode->i_mapping); + return page_cache_next(inode->i_mapping, inode->i_size); } /* @@ -74,13 +73,9 @@ static inline unsigned long dir_pages(st 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(mapping); - if (last_byte > page_cache_size(mapping)) - last_byte = page_cache_size(mapping); - return last_byte; + return inode->i_size - page_cache_pos(mapping, page_nr, 0); } static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len) - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 13/19] Use page_cache_xxx in fs/splice.c
On Thu, 29 Nov 2007, David Chinner wrote: > On Wed, Nov 28, 2007 at 05:11:05PM -0800, Christoph Lameter wrote: > > @@ -453,7 +454,7 @@ fill_it: > > */ > > while (page_nr < nr_pages) > > page_cache_release(pages[page_nr++]); > > - in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; > > + in->f_ra.prev_pos = page_cache_index(mapping, index); > > in->f_ra.prev_pos = page_cache_pos(mapping, index, 0); > splice.c: Wrong inline function used Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/splice.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: mm/fs/splice.c === --- mm.orig/fs/splice.c 2007-11-28 19:48:43.246633219 -0800 +++ mm/fs/splice.c 2007-11-28 19:49:06.405882592 -0800 @@ -454,7 +454,7 @@ fill_it: */ while (page_nr < nr_pages) page_cache_release(pages[page_nr++]); - in->f_ra.prev_pos = page_cache_index(mapping, index); + in->f_ra.prev_pos = page_cache_pos(mapping, index, 0); if (spd.nr_pages) return splice_to_pipe(pipe, &spd); - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 10/19] Use page_cache_xxx in fs/buffer.c
On Thu, 29 Nov 2007, David Chinner wrote: > > - while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT)) { > > - zerofrom = curpos & ~PAGE_CACHE_MASK; > > + while (index > (curidx = page_cache_index(mapping, (curpos = *bytes > > { > > + zerofrom = page_cache_offset(mapping, curpos); > > That doesn't get any prettier. Perhaps: > > while (index > (curidx = page_cache_index(mapping, *bytes))) { > curpos = *bytes; > zerofrom = page_cache_offset(mapping, curpos); Results in a gcc warning about the possible use of an unitialized variable. How about this? fs/buffer.c enhancements and fixes Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/buffer.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/fs/buffer.c === --- mm.orig/fs/buffer.c 2007-11-28 19:39:23.606383803 -0800 +++ mm/fs/buffer.c 2007-11-28 19:46:10.238382715 -0800 @@ -914,11 +914,10 @@ struct buffer_head *alloc_page_buffers(s { struct buffer_head *bh, *head; long offset; - unsigned int page_size = page_cache_size(page->mapping); try_again: head = NULL; - offset = page_size; + offset = page_cache_size(page->mapping); while ((offset -= size) >= 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -2221,7 +2220,8 @@ int cont_expand_zero(struct file *file, index = page_cache_index(mapping, pos); offset = page_cache_offset(mapping, pos); - while (index > (curidx = page_cache_index(mapping, (curpos = *bytes { + while (curpos = *bytes, curidx = page_cache_index(mapping, curpos), + index > curidx) { zerofrom = page_cache_offset(mapping, curpos); if (zerofrom & (blocksize-1)) { *bytes |= (blocksize-1); @@ -2368,7 +2368,7 @@ block_page_mkwrite(struct vm_area_struct mapping = page->mapping; size = i_size_read(inode); if ((mapping != inode->i_mapping) || - (page_offset(page) > size)) { + (page_cache_pos(mapping, page->index, 0) > size)) { /* page got truncated out from underneath us */ goto out_unlock; } - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
On Thu, 29 Nov 2007, David Chinner wrote: > > unsigned int mapcount; > > struct address_space *mapping = page->mapping; > > - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); > > + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); > > Based on the first hunk, shouldn't this be: > > pgoff_t pgoff = page->index << mapping_order(mapping); Yes that is much simpler rmap: simplify page_referenced_file use of page cache inlines Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/rmap.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: mm/mm/rmap.c === --- mm.orig/mm/rmap.c 2007-11-28 19:28:45.689883608 -0800 +++ mm/mm/rmap.c2007-11-28 19:29:35.090382690 -0800 @@ -350,7 +350,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); + pgoff_t pgoff = page->index << mapping_order(mapping); struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
In other words the following patch? Fixes to the use of page_cache_xx functions in xfs Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/xfs/linux-2.6/xfs_aops.c | 17 ++--- fs/xfs/linux-2.6/xfs_lrw.c |2 +- 2 files changed, 7 insertions(+), 12 deletions(-) Index: mm/fs/xfs/linux-2.6/xfs_aops.c === --- mm.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-11-28 19:13:13.323382722 -0800 +++ mm/fs/xfs/linux-2.6/xfs_aops.c 2007-11-28 19:22:15.686920219 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_cache_offset(page->mapping); + loff_t offset = page_cache_pos(page->mapping, page->index, 0); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -780,13 +780,11 @@ xfs_convert_page( * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << page_cache_shift(map), + (xfs_off_t)page_cache_pos(map, page->index + 1, 0), i_size_read(inode)); len = 1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - page_cache_size(map)); - p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map); + p_offset = page_cache_offset(map, end_offset); page_dirty = p_offset / len; bh = head = page_buffers(page); @@ -943,7 +941,6 @@ xfs_page_state_convert( int trylock = 0; int all_bh = unmapped; struct address_space*map = inode->i_mapping; - int pagesize = page_cache_size(map); if (startio) { if (wbc->sync_mode == WB_SYNC_NONE && wbc->nonblocking) @@ -979,9 +976,7 @@ xfs_page_state_convert( end_offset = min_t(unsigned long long, (xfs_off_t)page_cache_pos(map, page->index + 1, 0), offset); len = 1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - pagesize); - p_offset = p_offset ? roundup(p_offset, len) : pagesize; + p_offset = page_cache_offset(map, end_offset); page_dirty = p_offset / len; bh = head = page_buffers(page); @@ -1132,8 +1127,8 @@ xfs_page_state_convert( xfs_start_page_writeback(page, wbc, 1, count); if (ioend && iomap_valid) { - offset = (iomap.iomap_offset + iomap.iomap_bsize - 1) >> - page_cache_shift(map); + offset = page_cache_index(map, + (iomap.iomap_offset + iomap.iomap_bsize - 1)); tlast = min_t(pgoff_t, offset, last_index); xfs_cluster_write(inode, page->index + 1, &iomap, &ioend, wbc, startio, all_bh, tlast); Index: mm/fs/xfs/linux-2.6/xfs_lrw.c === --- mm.orig/fs/xfs/linux-2.6/xfs_lrw.c 2007-11-28 19:22:35.454383115 -0800 +++ mm/fs/xfs/linux-2.6/xfs_lrw.c 2007-11-28 19:22:59.222132796 -0800 @@ -142,7 +142,7 @@ xfs_iozero( unsigned offset, bytes; void *fsdata; - offset = page_cache_offset(mapping, pos); /* Within page */ + offset = page_cache_offset(mapping, pos); bytes = page_cache_size(mapping) - offset; if (bytes > count) bytes = count; - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 01/19] Define functions for page cache handling
On Thu, 29 Nov 2007, David Chinner wrote: > On Wed, Nov 28, 2007 at 05:10:53PM -0800, Christoph Lameter wrote: > > +/* > > + * Index of the page starting on or after the given position. > > + */ > > +static inline pgoff_t page_cache_next(struct address_space *a, > > + loff_t pos) > > +{ > > + return page_cache_index(a, pos + page_cache_size(a) - 1); > > return page_cache_index(a, pos + page_cache_mask(a)); Na that is confusing. We really want to go to one byte before the end of the page. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 19/19] Use page_cache_xxx in drivers/block/rd.c
Use page_cache_xxx in drivers/block/rd.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- drivers/block/rd.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/drivers/block/rd.c === --- mm.orig/drivers/block/rd.c 2007-11-28 12:19:49.673905513 -0800 +++ mm/drivers/block/rd.c 2007-11-28 14:13:01.076977633 -0800 @@ -122,7 +122,7 @@ static void make_page_uptodate(struct pa } } while ((bh = bh->b_this_page) != head); } else { - memset(page_address(page), 0, PAGE_CACHE_SIZE); + memset(page_address(page), 0, page_cache_size(page_mapping(page))); } flush_dcache_page(page); SetPageUptodate(page); @@ -215,9 +215,9 @@ static const struct address_space_operat static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector, struct address_space *mapping) { - pgoff_t index = sector >> (PAGE_CACHE_SHIFT - 9); + pgoff_t index = sector >> (page_cache_size(mapping) - 9); unsigned int vec_offset = vec->bv_offset; - int offset = (sector << 9) & ~PAGE_CACHE_MASK; + int offset = page_cache_offset(mapping, (sector << 9)); int size = vec->bv_len; int err = 0; @@ -227,7 +227,7 @@ static int rd_blkdev_pagecache_IO(int rw char *src; char *dst; - count = PAGE_CACHE_SIZE - offset; + count = page_cache_size(mapping) - offset; if (count > size) count = size; size -= count; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 01/19] Define functions for page cache handling
We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK and PAGE_CACHE_ALIGN in various places in the kernel. Many times common operations like calculating the offset or the index are coded using shifts and adds. This patch provides inline functions to get the calculations accomplished without having to explicitly shift and add constants. All functions take an address_space pointer. The address space pointer will be used in the future to eventually support a larger buffers. Information reachable via the mapping may then determine page size. New functionRelated base page constant page_cache_shift(a) PAGE_CACHE_SHIFT page_cache_size(a) PAGE_CACHE_SIZE page_cache_mask(a) PAGE_CACHE_MASK page_cache_index(a, pos)Calculate page number from position page_cache_next(addr, pos) Page number of next page page_cache_offset(a, pos) Calculate offset into a page page_cache_pos(a, index, offset) Form position based on page number and an offset. This provides a basis that would allow the conversion of all page cache handling in the kernel and ultimately allow the removal of the PAGE_CACHE_* constants. Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- include/linux/pagemap.h | 54 +++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 8a83537..836e9dd 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -52,12 +52,66 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) * space in smaller chunks for same flexibility). * * Or rather, it _will_ be done in larger chunks. + * + * The following constants can be used if a filesystem only supports a single + * page size. */ #define PAGE_CACHE_SHIFT PAGE_SHIFT #define PAGE_CACHE_SIZEPAGE_SIZE #define PAGE_CACHE_MASKPAGE_MASK #define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK) +/* + * Functions that are currently setup for a fixed PAGE_SIZEd. The use of + * these will allow a variable page size pagecache in the future. + */ +static inline int mapping_order(struct address_space *a) +{ + return 0; +} + +static inline int page_cache_shift(struct address_space *a) +{ + return PAGE_SHIFT; +} + +static inline unsigned int page_cache_size(struct address_space *a) +{ + return PAGE_SIZE; +} + +static inline loff_t page_cache_mask(struct address_space *a) +{ + return (loff_t)PAGE_MASK; +} + +static inline unsigned int page_cache_offset(struct address_space *a, + loff_t pos) +{ + return pos & ~PAGE_MASK; +} + +static inline pgoff_t page_cache_index(struct address_space *a, + loff_t pos) +{ + return pos >> page_cache_shift(a); +} + +/* + * Index of the page starting on or after the given position. + */ +static inline pgoff_t page_cache_next(struct address_space *a, + loff_t pos) +{ + return page_cache_index(a, pos + page_cache_size(a) - 1); +} + +static inline loff_t page_cache_pos(struct address_space *a, + pgoff_t index, unsigned long offset) +{ + return ((loff_t)index << page_cache_shift(a)) + offset; +} + #define page_cache_get(page) get_page(page) #define page_cache_release(page) put_page(page) void release_pages(struct page **pages, int nr, int cold); -- 1.5.2.5 -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 10/19] Use page_cache_xxx in fs/buffer.c
Use page_cache_xxx in fs/buffer.c. Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/buffer.c | 101 +--- 1 file changed, 56 insertions(+), 45 deletions(-) Index: mm/fs/buffer.c === --- mm.orig/fs/buffer.c 2007-11-28 14:09:42.757727389 -0800 +++ mm/fs/buffer.c 2007-11-28 14:10:59.728728042 -0800 @@ -278,7 +278,7 @@ __find_get_block_slow(struct block_devic struct page *page; int all_mapped = 1; - index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits); + index = block >> (page_cache_shift(bd_mapping) - bd_inode->i_blkbits); page = find_get_page(bd_mapping, index); if (!page) goto out; @@ -720,7 +720,7 @@ static int __set_page_dirty(struct page __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); @@ -914,10 +914,11 @@ struct buffer_head *alloc_page_buffers(s { struct buffer_head *bh, *head; long offset; + unsigned int page_size = page_cache_size(page->mapping); try_again: head = NULL; - offset = PAGE_SIZE; + offset = page_size; while ((offset -= size) >= 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -1640,6 +1641,7 @@ static int __block_write_full_page(struc struct buffer_head *bh, *head; const unsigned blocksize = 1 << inode->i_blkbits; int nr_underway = 0; + struct address_space *mapping = inode->i_mapping; BUG_ON(!PageLocked(page)); @@ -1660,7 +1662,8 @@ static int __block_write_full_page(struc * handle that here by just cleaning them. */ - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + block = (sector_t)page->index << + (page_cache_shift(mapping) - inode->i_blkbits); head = page_buffers(page); bh = head; @@ -1777,7 +1780,7 @@ recover: } while ((bh = bh->b_this_page) != head); SetPageError(page); BUG_ON(PageWriteback(page)); - mapping_set_error(page->mapping, err); + mapping_set_error(mapping, err); set_page_writeback(page); do { struct buffer_head *next = bh->b_this_page; @@ -1844,8 +1847,8 @@ static int __block_prepare_write(struct struct buffer_head *bh, *head, *wait[2], **wait_bh=wait; BUG_ON(!PageLocked(page)); - BUG_ON(from > PAGE_CACHE_SIZE); - BUG_ON(to > PAGE_CACHE_SIZE); + BUG_ON(from > page_cache_size(inode->i_mapping)); + BUG_ON(to > page_cache_size(inode->i_mapping)); BUG_ON(from > to); blocksize = 1 << inode->i_blkbits; @@ -1854,7 +1857,8 @@ static int __block_prepare_write(struct head = page_buffers(page); bbits = inode->i_blkbits; - block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits); + block = (sector_t)page->index << + (page_cache_shift(inode->i_mapping) - bbits); for(bh = head, block_start = 0; bh != head || !block_start; block++, block_start=block_end, bh = bh->b_this_page) { @@ -1969,8 +1973,8 @@ int block_write_begin(struct file *file, unsigned start, end; int ownpage = 0; - index = pos >> PAGE_CACHE_SHIFT; - start = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + start = page_cache_offset(mapping, pos); end = start + len; page = *pagep; @@ -2017,7 +2021,7 @@ int block_write_end(struct file *file, s struct inode *inode = mapping->host; unsigned start; - start = pos & (PAGE_CACHE_SIZE - 1); + start = page_cache_offset(mapping, pos); if (unlikely(copied < len)) { /* @@ -2095,7 +2099,8 @@ int block_read_full_page(struct page *pa create_empty_buffers(page, blocksize, 0); head = page_buffers(page); - iblock = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + iblock = (sector_t)page->index << + (page_cache_shift(page->mapping) - inode->i_blkbits); lblock = (i_size_read(inode)+blocksize-1) >> inode->i_blkbits; bh = head; nr = 0; @@ -2213,16 +2218,16 @@ int cont_expand_zero(struct file *file, unsigned zerofrom, offset, le
[patch 17/19] Use page_cache_xxx in fs/reiserfs
Use page_cache_xxx in fs/reiserfs Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/reiserfs/file.c|6 -- fs/reiserfs/inode.c | 33 - fs/reiserfs/ioctl.c |2 +- fs/reiserfs/stree.c |5 +++-- fs/reiserfs/tail_conversion.c |5 +++-- fs/reiserfs/xattr.c | 19 ++- 6 files changed, 41 insertions(+), 29 deletions(-) Index: mm/fs/reiserfs/file.c === --- mm.orig/fs/reiserfs/file.c 2007-11-16 21:16:36.0 -0800 +++ mm/fs/reiserfs/file.c 2007-11-28 14:12:52.242227141 -0800 @@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *i int partial = 0; unsigned blocksize; struct buffer_head *bh, *head; - unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT; + unsigned long i_size_index = + page_cache_index(inode->i_mapping, inode->i_size); int new; int logit = reiserfs_file_data_log(inode); struct super_block *s = inode->i_sb; - int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize; + int bh_per_page = page_cache_size(inode->i_mapping) / s->s_blocksize; struct reiserfs_transaction_handle th; int ret = 0; @@ -260,6 +261,7 @@ static ssize_t reiserfs_file_write(struc /* To simplify coding at this time, we store locked pages in array for now */ struct reiserfs_transaction_handle th; + struct address_space *mapping = inode->i_mapping; th.t_trans_id = 0; /* If a filesystem is converted from 3.5 to 3.6, we'll have v3.5 items Index: mm/fs/reiserfs/inode.c === --- mm.orig/fs/reiserfs/inode.c 2007-11-28 12:25:33.863963689 -0800 +++ mm/fs/reiserfs/inode.c 2007-11-28 14:12:52.242227141 -0800 @@ -337,7 +337,8 @@ static int _get_block_create_0(struct in goto finished; } // read file tail into part of page - offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1); + offset = page_cache_offset(inode->i_mapping, + cpu_key_k_offset(&key) - 1); fs_gen = get_generation(inode->i_sb); copy_item_head(&tmp_ih, ih); @@ -523,10 +524,10 @@ static int convert_tail_for_hole(struct return -EIO; /* always try to read until the end of the block */ - tail_start = tail_offset & (PAGE_CACHE_SIZE - 1); + tail_start = page_cache_offset(inode->i_mapping, tail_offset); tail_end = (tail_start | (bh_result->b_size - 1)) + 1; - index = tail_offset >> PAGE_CACHE_SHIFT; + index = page_cache_index(inode->i_mapping, tail_offset); /* hole_page can be zero in case of direct_io, we are sure that we cannot get here if we write with O_DIRECT into tail page */ @@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode * /* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ - unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT; + unsigned long index = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size - 1); unsigned long pos = 0; unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size); struct buffer_head *bh; struct buffer_head *head; struct page *page; @@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode { struct reiserfs_transaction_handle th; /* we want the offset for the first byte after the end of the file */ - unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_offset(p_s_inode->i_mapping, + p_s_inode->i_size); unsigned blocksize = p_s_inode->i_sb->s_blocksize; unsigned length; struct page *page = NULL; @@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc } else if (is_direct_le_ih(ih)) { char *p; p = page_address(bh_result->b_page); - p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1); + p += page_cache_offset(inode->i_mapping, byte_offset - 1); copy_size = ih_item_len(ih) - pos_in_item; fs_gen = get_generation(inode->i_sb); @@ -2324,7 +2328,8 @@ static int r
[patch 18/19] Use page_cache_xxx for fs/xfs
Use page_cache_xxx for fs/xfs Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/xfs/linux-2.6/xfs_aops.c | 55 +++- fs/xfs/linux-2.6/xfs_lrw.c |4 +-- 2 files changed, 31 insertions(+), 28 deletions(-) Index: mm/fs/xfs/linux-2.6/xfs_aops.c === --- mm.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-11-28 12:25:38.768212813 -0800 +++ mm/fs/xfs/linux-2.6/xfs_aops.c 2007-11-28 14:12:55.637977383 -0800 @@ -75,7 +75,7 @@ xfs_page_trace( xfs_inode_t *ip; bhv_vnode_t *vp = vn_from_inode(inode); loff_t isize = i_size_read(inode); - loff_t offset = page_offset(page); + loff_t offset = page_cache_offset(page->mapping); int delalloc = -1, unmapped = -1, unwritten = -1; if (page_has_buffers(page)) @@ -618,7 +618,7 @@ xfs_probe_page( break; } while ((bh = bh->b_this_page) != head); } else - ret = mapped ? 0 : PAGE_CACHE_SIZE; + ret = mapped ? 0 : page_cache_size(page->mapping); } return ret; @@ -645,7 +645,7 @@ xfs_probe_cluster( } while ((bh = bh->b_this_page) != head); /* if we reached the end of the page, sum forwards in following pages */ - tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT; + tlast = page_cache_index(inode->i_mapping, i_size_read(inode)); tindex = startpage->index + 1; /* Prune this back to avoid pathological behavior */ @@ -663,14 +663,14 @@ xfs_probe_cluster( size_t pg_offset, pg_len = 0; if (tindex == tlast) { - pg_offset = - i_size_read(inode) & (PAGE_CACHE_SIZE - 1); + pg_offset = page_cache_offset(inode->i_mapping, + i_size_read(inode)); if (!pg_offset) { done = 1; break; } } else - pg_offset = PAGE_CACHE_SIZE; + pg_offset = page_cache_size(inode->i_mapping); if (page->index == tindex && !TestSetPageLocked(page)) { pg_len = xfs_probe_page(page, pg_offset, mapped); @@ -752,7 +752,8 @@ xfs_convert_page( int bbits = inode->i_blkbits; int len, page_dirty; int count = 0, done = 0, uptodate = 1; - xfs_off_t offset = page_offset(page); + struct address_space*map = inode->i_mapping; + xfs_off_t offset = page_cache_pos(map, page->index, 0); if (page->index != tindex) goto fail; @@ -760,7 +761,7 @@ xfs_convert_page( goto fail; if (PageWriteback(page)) goto fail_unlock_page; - if (page->mapping != inode->i_mapping) + if (page->mapping != map) goto fail_unlock_page; if (!xfs_is_delayed_page(page, (*ioendp)->io_type)) goto fail_unlock_page; @@ -772,20 +773,20 @@ xfs_convert_page( * Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset & page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT, + (xfs_off_t)(page->index + 1) << page_cache_shift(map), i_size_read(inode)); len = 1 << inode->i_blkbits; - p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1), - PAGE_CACHE_SIZE); - p_offset = p_offset ? roundup(p_offset, len) : PAGE_CACHE_SIZE; + p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), + page_cache_size(map)); + p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map); page_dirty = p_offset / len; bh = head = page_buffers(page); @@ -941,6 +942,8 @@ xfs_page
[patch 16/19] Use page_cache_xxx in fs/ext4
Use page_cache_xxx in fs/ext4 Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext4/dir.c |3 ++- fs/ext4/inode.c | 33 + 2 files changed, 19 insertions(+), 17 deletions(-) Index: mm/fs/ext4/dir.c === --- mm.orig/fs/ext4/dir.c 2007-11-28 12:24:24.767962686 -0800 +++ mm/fs/ext4/dir.c2007-11-28 14:11:23.532977270 -0800 @@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_size(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: mm/fs/ext4/inode.c === --- mm.orig/fs/ext4/inode.c 2007-11-28 12:24:24.965213091 -0800 +++ mm/fs/ext4/inode.c 2007-11-28 14:12:47.716740818 -0800 @@ -1110,8 +1110,8 @@ static int ext4_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1206,7 +1206,7 @@ static int ext4_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1276,7 +1276,7 @@ static int ext4_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1579,6 +1579,7 @@ static int ext4_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1601,8 +1602,7 @@ static int ext4_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext4_get_block, wbc); @@ -1619,13 +1619,12 @@ static int ext4_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, + err = walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, jbd2_journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext4_journal_stop(handle); if (!ret) ret = err; @@ -1677,6 +1676,7 @@ static int ext4_journalled_writepage(str handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext4_journal_current_handle()) goto no_write; @@ -1693,17 +1693,17 @@ static int ext4_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, + ret = block_prepare_write(page, 0, page_cache_size(mapping), ext4_get_block); if (ret != 0) { ext4_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + page_cache_size(mapping), NULL, do_journal_get_write_access); err = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, write_end_fn); + page_cache_size(mapping), NULL, write_end_fn); if (ret == 0) ret = err; EXT4_I(inode)-&g
[patch 14/19] Use page_cache_xxx in ext2
Use page_cache_xxx functions in fs/ext2/* Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- 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.c2007-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<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<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<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;
[patch 15/19] Use page_cache_xxx in fs/ext3
Use page_cache_xxx in fs/ext3 Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/ext3/dir.c |3 ++- fs/ext3/inode.c | 39 --- 2 files changed, 22 insertions(+), 20 deletions(-) Index: mm/fs/ext3/dir.c === --- mm.orig/fs/ext3/dir.c 2007-11-16 21:16:36.0 -0800 +++ mm/fs/ext3/dir.c2007-11-28 14:11:16.689227316 -0800 @@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi &map_bh, 0, 0); if (err > 0) { pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_shift(inode->i_mapping) + - inode->i_blkbits); if (!ra_has_index(&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping, Index: mm/fs/ext3/inode.c === --- mm.orig/fs/ext3/inode.c 2007-11-28 12:24:24.567962333 -0800 +++ mm/fs/ext3/inode.c 2007-11-28 14:11:16.701086757 -0800 @@ -1159,8 +1159,8 @@ static int ext3_write_begin(struct file pgoff_t index; unsigned from, to; - index = pos >> PAGE_CACHE_SHIFT; - from = pos & (PAGE_CACHE_SIZE - 1); + index = page_cache_index(mapping, pos); + from = page_cache_offset(mapping, pos); to = from + len; retry: @@ -1256,7 +1256,7 @@ static int ext3_ordered_write_end(struct unsigned from, to; int ret = 0, ret2; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page), @@ -1326,7 +1326,7 @@ static int ext3_journalled_write_end(str int partial = 0; unsigned from, to; - from = pos & (PAGE_CACHE_SIZE - 1); + from = page_cache_offset(mapping, pos); to = from + len; if (copied < len) { @@ -1489,6 +1489,7 @@ static int ext3_ordered_writepage(struct handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); J_ASSERT(PageLocked(page)); @@ -1511,8 +1512,7 @@ static int ext3_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs = page_buffers(page); - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bget_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one); ret = block_write_full_page(page, ext3_get_block, wbc); @@ -1529,13 +1529,12 @@ static int ext3_ordered_writepage(struct * and generally junk. */ if (ret == 0) { - err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, - NULL, journal_dirty_data_fn); + err = walk_page_buffers(handle, page_bufs, 0, pagesize, + NULL, journal_dirty_data_fn); if (!ret) ret = err; } - walk_page_buffers(handle, page_bufs, 0, - PAGE_CACHE_SIZE, NULL, bput_one); + walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one); err = ext3_journal_stop(handle); if (!ret) ret = err; @@ -1583,10 +1582,12 @@ out_fail: static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; handle_t *handle = NULL; int ret = 0; int err; + int pagesize = page_cache_size(inode->i_mapping); if (ext3_journal_current_handle()) goto no_write; @@ -1603,17 +1604,16 @@ static int ext3_journalled_writepage(str * doesn't seem much point in redirtying the page here. */ ClearPageChecked(page); - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, - ext3_get_block); + ret = block_prepare_write(page, 0, pagesize, ext3_get_block); if (ret != 0) { ext3_journal_stop(handle); goto out_unlock; } ret = walk_page_buffers(handle, page_buffers(page), 0, - PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); + pagesize, NULL, do_journal_get_write_access); err = wa
[patch 13/19] Use page_cache_xxx in fs/splice.c
Use page_cache_xxx in fs/splice.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/splice.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) Index: mm/fs/splice.c === --- mm.orig/fs/splice.c 2007-11-28 12:25:34.032908404 -0800 +++ mm/fs/splice.c 2007-11-28 14:11:11.285227032 -0800 @@ -285,9 +285,9 @@ __generic_file_splice_read(struct file * .spd_release = spd_release_page, }; - index = *ppos >> PAGE_CACHE_SHIFT; - loff = *ppos & ~PAGE_CACHE_MASK; - req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); + loff = page_cache_offset(mapping, *ppos); + req_pages = page_cache_next(mapping, len + loff); nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS); /* @@ -342,7 +342,7 @@ __generic_file_splice_read(struct file * * Now loop over the map and see if we need to start IO on any * pages, fill in the partial map, etc. */ - index = *ppos >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, *ppos); nr_pages = spd.nr_pages; spd.nr_pages = 0; for (page_nr = 0; page_nr < nr_pages; page_nr++) { @@ -354,7 +354,8 @@ __generic_file_splice_read(struct file * /* * this_len is the max we'll use from this page */ - this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); + this_len = min_t(unsigned long, len, + page_cache_size(mapping) - loff); page = pages[page_nr]; if (PageReadahead(page)) @@ -414,7 +415,7 @@ fill_it: * i_size must be checked after PageUptodate. */ isize = i_size_read(mapping->host); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) break; @@ -428,7 +429,7 @@ fill_it: /* * max good bytes in this page */ - plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + plen = page_cache_offset(mapping, isize - 1) + 1; if (plen <= loff) break; @@ -453,7 +454,7 @@ fill_it: */ while (page_nr < nr_pages) page_cache_release(pages[page_nr++]); - in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; + in->f_ra.prev_pos = page_cache_index(mapping, index); if (spd.nr_pages) return splice_to_pipe(pipe, &spd); @@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inod if (unlikely(ret)) return ret; - offset = sd->pos & ~PAGE_CACHE_MASK; + offset = page_cache_offset(mapping, sd->pos); this_len = sd->len; - if (this_len + offset > PAGE_CACHE_SIZE) - this_len = PAGE_CACHE_SIZE - offset; + if (this_len + offset > page_cache_size(mapping)) + this_len = page_cache_size(mapping) - offset; ret = pagecache_write_begin(file, mapping, sd->pos, this_len, AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata); @@ -790,7 +791,7 @@ generic_file_splice_write_nolock(struct unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, @@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_in unsigned long nr_pages; *ppos += ret; - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = page_cache_next(mapping, ret); /* * If file or inode is SYNC and we actually wrote some data, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 09/19] Use page_cache_xxx in fs/sync
Use page_cache_xxx in fs/sync. Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/sync.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/fs/sync.c === --- mm.orig/fs/sync.c 2007-11-16 21:16:36.0 -0800 +++ mm/fs/sync.c2007-11-28 14:10:56.269227507 -0800 @@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address ret = 0; if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); if (ret < 0) goto out; } @@ -275,8 +275,8 @@ int do_sync_mapping_range(struct address if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { ret = wait_on_page_writeback_range(mapping, - offset >> PAGE_CACHE_SHIFT, - endbyte >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, offset), + page_cache_index(mapping, endbyte)); } out: return ret; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 12/19] Use page_cache_xxx in mm/fadvise.c
Use page_cache_xxx in mm/fadvise.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/fadvise.c |8 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/mm/fadvise.c === --- mm.orig/mm/fadvise.c2007-11-16 21:16:36.0 -0800 +++ mm/mm/fadvise.c 2007-11-28 14:11:06.164977155 -0800 @@ -79,8 +79,8 @@ asmlinkage long sys_fadvise64_64(int fd, } /* First and last PARTIAL page! */ - start_index = offset >> PAGE_CACHE_SHIFT; - end_index = endbyte >> PAGE_CACHE_SHIFT; + start_index = page_cache_index(mapping, offset); + end_index = page_cache_index(mapping, endbyte); /* Careful about overflow on the "+1" */ nrpages = end_index - start_index + 1; @@ -100,8 +100,8 @@ asmlinkage long sys_fadvise64_64(int fd, filemap_flush(mapping); /* First and last FULL page! */ - start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT; - end_index = (endbyte >> PAGE_CACHE_SHIFT); + start_index = page_cache_next(mapping, offset); + end_index = page_cache_index(mapping, endbyte); if (end_index >= start_index) invalidate_mapping_pages(mapping, start_index, -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 11/19] Use page_cache_xxx in mm/mpage.c
Use page_cache_xxx in mm/mpage.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/mpage.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) Index: linux-2.6/fs/mpage.c === --- linux-2.6.orig/fs/mpage.c 2007-11-26 17:51:53.347521636 -0800 +++ linux-2.6/fs/mpage.c2007-11-26 18:12:48.496772168 -0800 @@ -125,7 +125,8 @@ mpage_alloc(struct block_device *bdev, static void map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; struct buffer_head *page_bh, *head; int block = 0; @@ -134,9 +135,9 @@ map_buffer_to_page(struct page *page, st * don't make any buffers if there is only one buffer on * the page and the page just needs to be set up to date */ - if (inode->i_blkbits == PAGE_CACHE_SHIFT && + if (inode->i_blkbits == page_cache_shift(mapping) && buffer_uptodate(bh)) { - SetPageUptodate(page); + SetPageUptodate(page); return; } create_empty_buffers(page, 1 << inode->i_blkbits, 0); @@ -169,9 +170,10 @@ do_mpage_readpage(struct bio *bio, struc sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; const unsigned blocksize = 1 << blkbits; sector_t block_in_file; sector_t last_block; @@ -188,7 +190,7 @@ do_mpage_readpage(struct bio *bio, struc if (page_has_buffers(page)) goto confused; - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << (page_cache_shift(mapping) - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -276,7 +278,8 @@ do_mpage_readpage(struct bio *bio, struc } if (first_hole != blocks_per_page) { - zero_user_segment(page, first_hole << blkbits, PAGE_CACHE_SIZE); + zero_user_segment(page, first_hole << blkbits, + page_cache_size(mapping)); if (first_hole == 0) { SetPageUptodate(page); unlock_page(page); @@ -454,7 +457,7 @@ static int __mpage_writepage(struct page struct inode *inode = page->mapping->host; const unsigned blkbits = inode->i_blkbits; unsigned long end_index; - const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits; + const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits; sector_t last_block; sector_t block_in_file; sector_t blocks[MAX_BUF_PER_PAGE]; @@ -523,7 +526,8 @@ static int __mpage_writepage(struct page * The page has no buffers: map it to disk */ BUG_ON(!PageUptodate(page)); - block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t)page->index << + (page_cache_shift(mapping) - blkbits); last_block = (i_size - 1) >> blkbits; map_bh.b_page = page; for (page_block = 0; page_block < blocks_per_page; ) { @@ -555,7 +559,7 @@ static int __mpage_writepage(struct page first_unmapped = page_block; page_is_mapped: - end_index = i_size >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, i_size); if (page->index >= end_index) { /* * The page straddles i_size. It must be zeroed out on each @@ -565,11 +569,11 @@ page_is_mapped: * is zeroed when mapped, and writes to that region are not * written out to the file." */ - unsigned offset = i_size & (PAGE_CACHE_SIZE - 1); + unsigned offset = page_cache_offset(mapping, i_size); if (page->index > end_index || !offset) goto confused; - zero_user_segment(page, offset, PAGE_CACH
[patch 08/19] Use page_cache_xxx in fs/libfs.c
Use page_cache_xxx in fs/libfs.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- fs/libfs.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) Index: mm/fs/libfs.c === --- mm.orig/fs/libfs.c 2007-11-28 12:24:57.449215408 -0800 +++ mm/fs/libfs.c 2007-11-28 14:10:51.773477763 -0800 @@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt, { struct inode *inode = dentry->d_inode; generic_fillattr(inode, stat); - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + stat->blocks = inode->i_mapping->nrpages << + (page_cache_shift(inode->i_mapping) - 9); return 0; } @@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi unsigned from, unsigned to) { if (!PageUptodate(page)) { - if (to - from != PAGE_CACHE_SIZE) + if (to - from != page_cache_size(file->f_mapping)) zero_user_segments(page, 0, from, - to, PAGE_CACHE_SIZE); + to, page_cache_size(file->f_mapping)); } return 0; } @@ -372,8 +373,9 @@ int simple_write_begin(struct file *file static int simple_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct inode *inode = page->mapping->host; - loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; + struct address_space *mapping = page->mapping; + struct inode *inode = mapping->host; + loff_t pos = page_cache_pos(mapping, page->index, to); if (!PageUptodate(page)) SetPageUptodate(page); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 04/19] Use page_cache_xxx in mm/truncate.c
Use page_cache_xxx in mm/truncate.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- 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.c2007-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<http://vger.kernel.org/majordomo-info.html
[patch 06/19] Use page_cache_xxx in mm/filemap_xip.c
Use page_cache_xxx in mm/filemap_xip.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap_xip.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) Index: mm/mm/filemap_xip.c === --- mm.orig/mm/filemap_xip.c2007-11-28 12:27:32.155962689 -0800 +++ mm/mm/filemap_xip.c 2007-11-28 14:10:46.124978450 -0800 @@ -60,24 +60,24 @@ do_xip_mapping_read(struct address_space BUG_ON(!mapping->a_ops->get_xip_page); - index = *ppos >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + offset = page_cache_offset(mapping, *ppos); isize = i_size_read(inode); if (!isize) goto out; - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); for (;;) { struct page *page; unsigned long nr, ret; /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index >= end_index) { if (index > end_index) goto out; - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_next(mapping, size - 1) + 1; if (nr <= offset) { goto out; } @@ -116,8 +116,8 @@ do_xip_mapping_read(struct address_space */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); if (ret == nr && desc->count) continue; @@ -130,7 +130,7 @@ no_xip_page: } out: - *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; + *ppos = page_cache_pos(mapping, index, offset); if (filp) file_accessed(filp); } @@ -219,7 +219,7 @@ static int xip_file_fault(struct vm_area /* XXX: are VM_FAULT_ codes OK? */ - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + size = page_cache_next(mapping, i_size_read(inode)); if (vmf->pgoff >= size) return VM_FAULT_SIGBUS; @@ -289,9 +289,9 @@ __xip_file_write(struct file *filp, cons size_t copied; char *kaddr; - offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ - index = pos >> PAGE_CACHE_SHIFT; - bytes = PAGE_CACHE_SIZE - offset; + offset = page_cache_offset(mapping, pos); /* Within page */ + index = page_cache_index(mapping, pos); + bytes = page_cache_size(mapping) - offset; if (bytes > count) bytes = count; @@ -402,8 +402,8 @@ EXPORT_SYMBOL_GPL(xip_file_write); int xip_truncate_page(struct address_space *mapping, loff_t from) { - pgoff_t index = from >> PAGE_CACHE_SHIFT; - unsigned offset = from & (PAGE_CACHE_SIZE-1); + pgoff_t index = page_cache_index(mapping, from); + unsigned offset = page_cache_offset(mapping, from); unsigned blocksize; unsigned length; struct page *page; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 05/19] Use page_cache_xxx in mm/rmap.c
Use page_cache_xxx in mm/rmap.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/rmap.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) Index: mm/mm/rmap.c === --- mm.orig/mm/rmap.c 2007-11-28 12:27:32.312059099 -0800 +++ mm/mm/rmap.c2007-11-28 14:10:42.758227810 -0800 @@ -190,9 +190,14 @@ static void page_unlock_anon_vma(struct static inline unsigned long vma_address(struct page *page, struct vm_area_struct *vma) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff; unsigned long address; + if (PageAnon(page)) + pgoff = page->index; + else + pgoff = page->index << mapping_order(page->mapping); + address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); if (unlikely(address < vma->vm_start || address >= vma->vm_end)) { /* page should be within @vma mapping range */ @@ -345,7 +350,7 @@ static int page_referenced_file(struct p { unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); struct vm_area_struct *vma; struct prio_tree_iter iter; int referenced = 0; @@ -464,7 +469,7 @@ out: static int page_mkclean_file(struct address_space *mapping, struct page *page) { - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = 0; @@ -897,7 +902,7 @@ static int try_to_unmap_anon(struct page static int try_to_unmap_file(struct page *page, int migration) { struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT); struct vm_area_struct *vma; struct prio_tree_iter iter; int ret = SWAP_AGAIN; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 03/19] Use page_cache_xxx in mm/page-writeback.c
Use page_cache_xxx in mm/page-writeback.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/page-writeback.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: mm/mm/page-writeback.c === --- mm.orig/mm/page-writeback.c 2007-11-28 12:27:32.211962401 -0800 +++ mm/mm/page-writeback.c 2007-11-28 14:10:34.338227137 -0800 @@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa index = mapping->writeback_index; /* Start from prev offset */ end = -1; } else { - index = wbc->range_start >> PAGE_CACHE_SHIFT; - end = wbc->range_end >> PAGE_CACHE_SHIFT; + index = page_cache_index(mapping, wbc->range_start); + end = page_cache_index(mapping, wbc->range_end); if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; scanned = 1; @@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa __inc_zone_page_state(page, NR_FILE_DIRTY); __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE); - task_io_account_write(PAGE_CACHE_SIZE); + task_io_account_write(page_cache_size(mapping)); } radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 07/19] Use page_cache_xxx in mm/migrate.c
Use page_cache_xxx in mm/migrate.c Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/migrate.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: mm/mm/migrate.c === --- mm.orig/mm/migrate.c2007-11-28 12:27:32.184464256 -0800 +++ mm/mm/migrate.c 2007-11-28 14:10:49.200977227 -0800 @@ -197,7 +197,7 @@ static void remove_file_migration_ptes(s struct vm_area_struct *vma; struct address_space *mapping = page_mapping(new); struct prio_tree_iter iter; - pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = new->index << mapping_order(mapping); if (!mapping) return; -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 02/19] Use page_cache_xxx functions in mm/filemap.c
Convert the uses of PAGE_CACHE_xxx to use page_cache_xxx instead. Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- mm/filemap.c | 91 +-- 1 file changed, 46 insertions(+), 45 deletions(-) Index: mm/mm/filemap.c === --- mm.orig/mm/filemap.c2007-11-28 12:27:32.155962689 -0800 +++ mm/mm/filemap.c 2007-11-28 14:10:29.408977142 -0800 @@ -314,8 +314,8 @@ EXPORT_SYMBOL(add_to_page_cache_lru); int sync_page_range(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -346,8 +346,8 @@ EXPORT_SYMBOL(sync_page_range); int sync_page_range_nolock(struct inode *inode, struct address_space *mapping, loff_t pos, loff_t count) { - pgoff_t start = pos >> PAGE_CACHE_SHIFT; - pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT; + pgoff_t start = page_cache_index(mapping, pos); + pgoff_t end = page_cache_index(mapping, pos + count - 1); int ret; if (!mapping_cap_writeback_dirty(mapping) || !count) @@ -376,7 +376,7 @@ int filemap_fdatawait(struct address_spa return 0; return wait_on_page_writeback_range(mapping, 0, - (i_size - 1) >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, i_size - 1)); } EXPORT_SYMBOL(filemap_fdatawait); @@ -424,8 +424,8 @@ int filemap_write_and_wait_range(struct /* See comment of filemap_write_and_wait() */ if (err != -EIO) { int err2 = wait_on_page_writeback_range(mapping, - lstart >> PAGE_CACHE_SHIFT, - lend >> PAGE_CACHE_SHIFT); + page_cache_index(mapping, lstart), + page_cache_index(mapping, lend)); if (!err) err = err2; } @@ -897,11 +897,11 @@ void do_generic_mapping_read(struct addr unsigned int prev_offset; int error; - index = *ppos >> PAGE_CACHE_SHIFT; - prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT; - prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1); - last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; - offset = *ppos & ~PAGE_CACHE_MASK; + index = page_cache_index(mapping, *ppos); + prev_index = page_cache_index(mapping, ra->prev_pos); + prev_offset = page_cache_offset(mapping, ra->prev_pos); + last_index = page_cache_next(mapping, *ppos + desc->count); + offset = page_cache_offset(mapping, *ppos); for (;;) { struct page *page; @@ -938,16 +938,16 @@ page_ok: */ isize = i_size_read(inode); - end_index = (isize - 1) >> PAGE_CACHE_SHIFT; + end_index = page_cache_index(mapping, isize - 1); if (unlikely(!isize || index > end_index)) { page_cache_release(page); goto out; } /* nr is the maximum number of bytes to copy from this page */ - nr = PAGE_CACHE_SIZE; + nr = page_cache_size(mapping); if (index == end_index) { - nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; + nr = page_cache_offset(mapping, isize - 1) + 1; if (nr <= offset) { page_cache_release(page); goto out; @@ -982,8 +982,8 @@ page_ok: */ ret = actor(desc, page, offset, nr); offset += ret; - index += offset >> PAGE_CACHE_SHIFT; - offset &= ~PAGE_CACHE_MASK; + index += page_cache_index(mapping, offset); + offset = page_cache_offset(mapping, offset); prev_offset = offset; page_cache_release(page); @@ -1073,11 +1073,8 @@ no_cached_page: } out: - ra->prev_pos = prev_index; - ra->prev_pos <<= PAGE_CACHE_SHIFT; - ra->prev_pos |= prev_offset; - - *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset; + ra->prev_pos = page_cache_pos(mapping, prev_index, prev_offset); + *ppos = page_cache_pos(mapping, index, offs
[patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls. The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices. Patchset against 2.6.24-rc3-mm2. -- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: migratepage failures on reiserfs
On Mon, 5 Nov 2007, Mel Gorman wrote: > The grow_dev_page() pages should be reclaimable even though migration > is not supported for those pages? They were marked movable as it was > useful for lumpy reclaim taking back pages for hugepage allocations and > the like. Would it make sense for memory unremove to attempt migration > first and reclaim second? Note that a page is still movable even if there is no file system method for migration available. In that case the page needs to be cleaned before it can be moved. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 7/10] 9p: sysfs support for in-kenel servers
On Sat, 3 Nov 2007, Peter Zijlstra wrote: > On Fri, 2007-11-02 at 20:48 -0700, Greg KH wrote: > > > Also, a sysfs file that causes an action to happen just by reading the > > file is not a safe thing to have. Lots of scripts have been known to > > just walk the whole sysfs tree and open and read everything they can for > > no real good reason. So you should seriously reconsider this kind of > > interaction. > > Christoph, doesn't SLUB do exactly that? SLUB gathers statistics and summaries and displays them on read. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: More Large blocksize benchmarks
On Mon, 15 Oct 2007, Chris Mason wrote: > Dave reported that XFS saw much higher write throughput with large > blocksizes, but so far I'm seeing the most benefits during reads. Dave's tests were done with an early large blocksize patchset that had issues with readahead. More recent versions have the fixes by Fengguang that address the issue. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: SLUB performance regression vs SLAB
Patch 2/2 SLUB: Allow foreign objects on the per cpu object lists. In order to free objects we need to touch the page struct of the page that the object belongs to. If this occurs too frequently then we could generate a bouncing cacheline. We do not want that to occur too frequently. We can avoid the page struct touching for per cpu objects. Now we extend that to allow a limited number of objects that are not part of the cpu slab. Allow up to 4 times the objects that fit into a page in the per cpu list. If the objects are allocated before we need to free them then we have saved touching a page struct twice. The objects are presumably cache hot, so it is performance wise good to recycle these locally. Foreign objects are drained before deactivating cpu slabs and if too many objects accumulate. For kmem_cache_free() this also has the beneficial effect of getting virt_to_page() operations eliminated or grouped together which may help reduce the cache footprint and increase the speed of virt_to_page() lookups (they hopefully all come from the same pages). For kfree() we may have to do virt_to_page() in the worst case twice. Once grouped together. Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- include/linux/slub_def.h |1 mm/slub.c| 82 ++- 2 files changed, 68 insertions(+), 15 deletions(-) Index: linux-2.6.23-rc8-mm2/include/linux/slub_def.h === --- linux-2.6.23-rc8-mm2.orig/include/linux/slub_def.h 2007-10-04 22:42:08.0 -0700 +++ linux-2.6.23-rc8-mm2/include/linux/slub_def.h 2007-10-04 22:43:19.0 -0700 @@ -16,6 +16,7 @@ struct kmem_cache_cpu { struct page *page; int node; int remaining; + int drain_limit; unsigned int offset; unsigned int objsize; }; Index: linux-2.6.23-rc8-mm2/mm/slub.c === --- linux-2.6.23-rc8-mm2.orig/mm/slub.c 2007-10-04 22:42:08.0 -0700 +++ linux-2.6.23-rc8-mm2/mm/slub.c 2007-10-04 22:56:49.0 -0700 @@ -187,6 +187,12 @@ static inline void ClearSlabDebug(struct */ #define MAX_PARTIAL 10 +/* + * How many times the number of objects per slab can accumulate on the + * per cpu objects list before we drain it. + */ +#define DRAIN_FACTOR 4 + #define DEBUG_DEFAULT_FLAGS (SLAB_DEBUG_FREE | SLAB_RED_ZONE | \ SLAB_POISON | SLAB_STORE_USER) @@ -1375,6 +1381,54 @@ static void unfreeze_slab(struct kmem_ca } } +static void __slab_free(struct kmem_cache *s, struct page *page, + void *x, void *addr, unsigned int offset); + +/* + * Drain freelist of objects foreign to the slab. Interrupts must be off. + * + * This is called + * + * 1. Before taking the slub lock when a cpu slab is to be deactivated. + *Deactivation can only deal with native objects on the freelist. + * + * 2. If the number of objects in the per cpu structures grows beyond + *3 times the objects that fit in a slab. In that case we need to throw + *some objects away. Stripping the foreign objects does the job and + *localizes any new the allocations. + */ +static void drain_foreign(struct kmem_cache *s, struct kmem_cache_cpu *c, void *addr) +{ + void **freelist = c->freelist; + + if (unlikely(c->node < 0)) { + /* Slow path user */ + __slab_free(s, virt_to_head_page(freelist), freelist, addr, c->offset); + freelist = NULL; + c->remaining--; + } + + if (!freelist) + return; + + c->freelist = NULL; + c->remaining = 0; + + while (freelist) { + void **object = freelist; + struct page *page = virt_to_head_page(freelist); + + freelist = freelist[c->offset]; + if (page == c->page) { + /* Local object. Keep for future allocations */ + object[c->offset] = c->freelist; + c->freelist = object; + c->remaining++; + } else + __slab_free(s, page, object, NULL, c->offset); + } +} + /* * Remove the cpu slab */ @@ -1405,6 +1459,7 @@ static void deactivate_slab(struct kmem_ static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) { + drain_foreign(s, c, NULL); slab_lock(c->page); deactivate_slab(s, c); } @@ -1480,6 +1535,7 @@ static void *__slab_alloc(struct kmem_ca if (!c->page) goto new_slab; + drain_foreign(s, c, NULL); slab_lock(c->page); if (unlikely(!node_match(c, node))) goto another_slab; @@ -1553,6 +1609,7 @@ debug: c->page->inuse++; c->page->freelis
Re: SLUB performance regression vs SLAB
On Fri, 5 Oct 2007, Jens Axboe wrote: > It might not, it might. The point is trying to isolate the problem and > making a simple test case that could be used to reproduce it, so that > Christoph (or someone else) can easily fix it. In case there is someone who wants to hack on it: Here is what I got so far for batching the frees. I will try to come up with a test next week if nothing else happens before: Patch 1/2 on top of mm: SLUB: Keep counter of remaining objects on the per cpu list Add a counter to keep track of how many objects are on the per cpu list. Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]> --- include/linux/slub_def.h |1 + mm/slub.c|8 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) Index: linux-2.6.23-rc8-mm2/include/linux/slub_def.h === --- linux-2.6.23-rc8-mm2.orig/include/linux/slub_def.h 2007-10-04 22:41:58.0 -0700 +++ linux-2.6.23-rc8-mm2/include/linux/slub_def.h 2007-10-04 22:42:08.0 -0700 @@ -15,6 +15,7 @@ struct kmem_cache_cpu { void **freelist; struct page *page; int node; + int remaining; unsigned int offset; unsigned int objsize; }; Index: linux-2.6.23-rc8-mm2/mm/slub.c === --- linux-2.6.23-rc8-mm2.orig/mm/slub.c 2007-10-04 22:41:58.0 -0700 +++ linux-2.6.23-rc8-mm2/mm/slub.c 2007-10-04 22:42:08.0 -0700 @@ -1386,12 +1386,13 @@ static void deactivate_slab(struct kmem_ * because both freelists are empty. So this is unlikely * to occur. */ - while (unlikely(c->freelist)) { + while (unlikely(c->remaining)) { void **object; /* Retrieve object from cpu_freelist */ object = c->freelist; c->freelist = c->freelist[c->offset]; + c->remaining--; /* And put onto the regular freelist */ object[c->offset] = page->freelist; @@ -1491,6 +1492,7 @@ load_freelist: object = c->page->freelist; c->freelist = object[c->offset]; + c->remaining = s->objects - c->page->inuse - 1; c->page->inuse = s->objects; c->page->freelist = NULL; c->node = page_to_nid(c->page); @@ -1574,13 +1576,14 @@ static void __always_inline *slab_alloc( local_irq_save(flags); c = get_cpu_slab(s, smp_processor_id()); - if (unlikely(!c->freelist || !node_match(c, node))) + if (unlikely(!c->remaining || !node_match(c, node))) object = __slab_alloc(s, gfpflags, node, addr, c); else { object = c->freelist; c->freelist = object[c->offset]; + c->remaining--; } local_irq_restore(flags); @@ -1686,6 +1689,7 @@ static void __always_inline slab_free(st if (likely(page == c->page && c->node >= 0)) { object[c->offset] = c->freelist; c->freelist = object; + c->remaining++; } else __slab_free(s, page, x, addr, c->offset); - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: SLUB performance regression vs SLAB
On Fri, 5 Oct 2007, Matthew Wilcox wrote: > I vaguely remembered something called orasim, so I went looking for it. > I found http://oss.oracle.com/~wcoekaer/orasim/ which is dated from > 2004, and I found http://oss.oracle.com/projects/orasimjobfiles/ which > seems to be a stillborn project. Is there anything else I should know > about orasim? ;-) Too bad. If this would work then I would have a load to work against. I have a patch here that may address the issue for SMP (no NUMA for now) by batching all frees on the per cpu freelist and then dumping them in groups. But it is likely not too wise to have you run your weeklong tests on this one. Needs some more care first. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: SLUB performance regression vs SLAB
I just spend some time looking at the functions that you see high in the list. The trouble is that I have to speculate and that I have nothing to verify my thoughts. If you could give me the hitlist for each of the 3 runs then this would help to check my thinking. I could be totally off here. It seems that we miss the per cpu slab frequently on slab_free() which leads to the calling of __slab_free() and which in turn needs to take a lock on the page (in the page struct). Typically the page lock is uncontended which seems to not be the case here otherwise it would not be that high up. The per cpu patch in mm should reduce the contention on the page struct by not touching the page struct on alloc and on free. Does not seem to work all the way though. slab_free() still has to touch the page struct if the free is not to the currently active cpu slab. So there could still be page struct contention left if multiple processors frequently and simultaneously free to the same slab and that slab is not the per cpu slab of a cpu. That could be addressed by optimizing the object free handling further to not touch the page struct even if we miss the per cpu slab. That get_partial* is far up indicates contention on the list lock that should be addressable by either increasing the slab size or by changing the object free handling to batch in some form. This is an SMP system right? 2 cores with 4 cpus each? The main loop is always hitting on the same slabs? Which slabs would this be? Am I right in thinking that one process allocates objects and then lets multiple other processors do work and then the allocated object is freed from a cpu that did not allocate the object? If neighboring objects in one slab are allocated on one cpu and then are almost simultaneously freed from a set of different cpus then this may be explain the situation. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: SLUB performance regression vs SLAB
On Thu, 4 Oct 2007, Matthew Wilcox wrote: > Yet here we stand. Christoph is aggressively trying to get slab removed > from the tree. There is a testcase which shows slub performing worse > than slab. It's not my fault I can't publish it. And just because I > can't publish it doesn't mean it doesn't exist. > > Slab needs to not get removed until slub is as good a performer on this > benchmark. I agree with this SLAB will stay until we have worked through all the performance issues. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: SLUB performance regression vs SLAB
On Thu, 4 Oct 2007, Matthew Wilcox wrote: > We have three runs, all with 2.6.23-rc3 plus the patches that Suresh > applied from 20070922. The first run is with slab. The second run is > with SLUB and the third run is SLUB plus the tuning parameters you > recommended. There was quite a bit of communication on tuning parameters. Guess we got more confusion there and multiple configurations settings that I wanted to be tested separately were merged. Setting slub_min_order to more than zero can certainly be detrimental to performance since higher order page allocations can cause cacheline bouncing on zone locks. Which patches? 20070922 refers to a pull on the slab git tree on the performance branch? > I have a spreadsheet with Vtune data in it that was collected during > each of these test runs, so we can see which functions are the hottest. > I can grab that data and send it to you, if that's interesting. Please do. Add the kernel .configs please. Is there any slab queue tuning going on on boot with the SLAB configuration? Include any tuning that was done to the kernel please. > > Was the page allocator pass through patchset > > separately applied as I requested? > > I don't believe so. Suresh? If it was a git pull then the pass through was included and never taken out. > I think for future tests, it would be easiest if you send me a git > reference. That way we will all know precisely what is being tested. Sure we can do that. > > Finally: Is there some way that I can reproduce the tests on my machines? > > As usual for these kinds of setups ... take a two-CPU machine, 64GB > of memory, half a dozen fibre channel adapters, about 3000 discs, > a commercial database, a team of experts for three months worth of > tuning ... > > I don't know if anyone's tried to replicate a benchmark like this using > Postgres. Would be nice if they have ... Well we got our own performance test department here at SGI. If we get them involved then we can add another 3 months until we get the test results confirmed ;-). Seems that this is a small configuration. Why does it take that long? And the experts knew SLAB and not SLUB right? Lets look at all the data that you got and then see if this is enough to figure out what is wrong. - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html