linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: clameter@sgi.com
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>, Mel Gorman <mel@skynet.ie>
Cc: William Lee Irwin III <wli@holomorphy.com>, David Chinner <dgc@sgi.com>
Cc: Jens Axboe <jens.axboe@oracle.com>, Badari Pulavarty <pbadari@gmail.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Subject: [17/37] Use page_cache_xxx in fs/ext4
Date: Wed, 20 Jun 2007 11:29:24 -0700	[thread overview]
Message-ID: <20070620183009.909068099@sgi.com> (raw)
In-Reply-To: 20070620182907.506775016@sgi.com

[-- Attachment #1: vps_fs_ext4 --]
[-- Type: text/plain, Size: 10218 bytes --]

Signed-off-by: Christoph Lameter <clameter@sgi.com>

---
 fs/ext4/dir.c       |    3 ++-
 fs/ext4/inode.c     |   34 +++++++++++++++++-----------------
 fs/ext4/writeback.c |   35 +++++++++++++++++++----------------
 3 files changed, 38 insertions(+), 34 deletions(-)

Index: linux-2.6.22-rc4-mm2/fs/ext4/dir.c
===================================================================
--- linux-2.6.22-rc4-mm2.orig/fs/ext4/dir.c	2007-06-18 19:01:00.000000000 -0700
+++ linux-2.6.22-rc4-mm2/fs/ext4/dir.c	2007-06-18 19:01:06.000000000 -0700
@@ -136,7 +136,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(node->i_mapping)
+					- inode->i_blkbits);
 			if (!ra_has_index(&filp->f_ra, index))
 				page_cache_readahead_ondemand(
 					sb->s_bdev->bd_inode->i_mapping,
Index: linux-2.6.22-rc4-mm2/fs/ext4/inode.c
===================================================================
--- linux-2.6.22-rc4-mm2.orig/fs/ext4/inode.c	2007-06-18 19:01:00.000000000 -0700
+++ linux-2.6.22-rc4-mm2/fs/ext4/inode.c	2007-06-18 19:01:06.000000000 -0700
@@ -1158,8 +1158,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:
@@ -1231,7 +1231,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),
@@ -1298,7 +1298,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) {
@@ -1460,6 +1460,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));
 
@@ -1482,8 +1483,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);
 
@@ -1500,13 +1500,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;
@@ -1558,6 +1557,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;
@@ -1574,17 +1574,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;
 		EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
@@ -1824,8 +1823,8 @@ void ext4_set_aops(struct inode *inode)
 int ext4_block_truncate_page(handle_t *handle, struct page *page,
 		struct address_space *mapping, loff_t from)
 {
-	ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
-	unsigned offset = from & (PAGE_CACHE_SIZE-1);
+	ext4_fsblk_t index = page_cache_index(mapping, from);
+	unsigned offset = page_cache_offset(mapping, from);
 	unsigned blocksize, iblock, length, pos;
 	struct inode *inode = mapping->host;
 	struct buffer_head *bh;
@@ -1839,7 +1838,8 @@ int ext4_block_truncate_page(handle_t *h
 
 	blocksize = inode->i_sb->s_blocksize;
 	length = blocksize - (offset & (blocksize - 1));
-	iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
+	iblock = index <<
+		(page_cache_shift(mapping) - inode->i_sb->s_blocksize_bits);
 
 	/*
 	 * For "nobh" option,  we can only work if we don't need to
@@ -2325,7 +2325,7 @@ void ext4_truncate(struct inode *inode)
 		page = NULL;
 	} else {
 		page = grab_cache_page(mapping,
-				inode->i_size >> PAGE_CACHE_SHIFT);
+				page_cache_index(mapping, inode->i_size));
 		if (!page)
 			return;
 	}
Index: linux-2.6.22-rc4-mm2/fs/ext4/writeback.c
===================================================================
--- linux-2.6.22-rc4-mm2.orig/fs/ext4/writeback.c	2007-06-18 19:01:00.000000000 -0700
+++ linux-2.6.22-rc4-mm2/fs/ext4/writeback.c	2007-06-18 19:01:06.000000000 -0700
@@ -21,7 +21,7 @@
  *   MUST:
  *     - flush dirty pages in -ENOSPC case in order to free reserved blocks
  *     - direct I/O support
- *     - blocksize != PAGE_CACHE_SIZE support
+ *     - blocksize != PAGE_SIZE support
  *     - store last unwritten page in ext4_wb_writepages() and
  *       continue from it in a next run
  *   WISH:
@@ -285,7 +285,7 @@ static int ext4_wb_submit_extent(struct 
 	 * let's cook bios from them and start real I/O
 	 */
 
-	BUG_ON(PAGE_CACHE_SHIFT < blkbits);
+	BUG_ON(page_cache_shift(inode->i_mapping) < blkbits);
 	BUG_ON(list_empty(&wc->list));
 
 	wb_debug("cook and submit bios for %u/%u/%u for %lu/%u\n",
@@ -301,8 +301,9 @@ static int ext4_wb_submit_extent(struct 
 		if (page == NULL)
 			break;
 
-		pstart = page->index << (PAGE_CACHE_SHIFT - blkbits);
-		plen = PAGE_SIZE >> blkbits;
+		pstart = page->index <<
+				(page_cache_shift(node->i_mapping) - blkbits);
+		plen = page_cache_size(inode->i_mapping) >> blkbits;
 		if (pstart > blk) {
 			/* probably extent covers long space and page
 			 * to be written in the middle of it */
@@ -333,7 +334,8 @@ alloc_new_bio:
 			/* +2 because head/tail may belong to different pages */
 			nr_pages = (le16_to_cpu(ex->ee_len) -
 				    (blk - le32_to_cpu(ex->ee_block)));
-			nr_pages = (nr_pages >> (PAGE_CACHE_SHIFT - blkbits));
+			nr_pages = nr_pages >>
+					(page_cache_shift(inode->mapping) - blkbits);
 			off = le32_to_cpu(ex->ee_start) +
 			      (blk - le32_to_cpu(ex->ee_block));
 			off |= (ext4_fsblk_t)
@@ -832,11 +834,12 @@ int ext4_wb_writepages(struct address_sp
 static void ext4_wb_clear_page(struct page *page, int from, int to)
 {
 	void *kaddr;
+	struct address_space *mapping = page_mapping(page);
 
-	if (to < PAGE_CACHE_SIZE || from > 0) {
+	if (to < page_cache_size(mapping) || from > 0) {
 		kaddr = kmap_atomic(page, KM_USER0);
-		if (PAGE_CACHE_SIZE > to)
-			memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
+		if (page_cache_size(mapping) > to)
+			memset(kaddr + to, 0, page_cache_size(mapping) - to);
 		if (0 < from)
 			memset(kaddr, 0, from);
 		flush_dcache_page(page);
@@ -878,7 +881,7 @@ int ext4_wb_prepare_write(struct file *f
 		} else {
 			/* block is already mapped, so no need to reserve */
 			BUG_ON(PagePrivate(page));
-			if (to - from < PAGE_CACHE_SIZE) {
+			if (to - from < page_cache_size(inode->i_mapping)) {
 				wb_debug("read block %u\n",
 						(unsigned) bhw->b_blocknr);
 				set_bh_page(bhw, page, 0);
@@ -905,7 +908,7 @@ int ext4_wb_prepare_write(struct file *f
 int ext4_wb_commit_write(struct file *file, struct page *page,
 			     unsigned from, unsigned to)
 {
-	loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+	loff_t pos = page_cache_pos(file->f_mapping, page->index, to);
 	struct inode *inode = page->mapping->host;
 	int err = 0;
 
@@ -984,7 +987,7 @@ int ext4_wb_writepage(struct page *page,
 {
 	struct inode *inode = page->mapping->host;
 	loff_t i_size = i_size_read(inode);
-	pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
+	pgoff_t end_index = page_cache_index(inode->i_mapping, i_size);
 	unsigned offset;
 	void *kaddr;
 
@@ -1017,7 +1020,7 @@ int ext4_wb_writepage(struct page *page,
 		return ext4_wb_write_single_page(page, wbc);
 
 	/* Is the page fully outside i_size? (truncate in progress) */
-	offset = i_size & (PAGE_CACHE_SIZE-1);
+	offset = page_cache_offset(inode->i_mapping, i_size);
 	if (page->index >= end_index + 1 || !offset) {
 		/*
 		 * The page may have dirty, unmapped buffers.  For example,
@@ -1037,7 +1040,7 @@ int ext4_wb_writepage(struct page *page,
 	 * writes to that region are not written out to the file."
 	 */
 	kaddr = kmap_atomic(page, KM_USER0);
-	memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset);
+	memset(kaddr + offset, 0, page_cache_size(inode->i_mapping) - offset);
 	flush_dcache_page(page);
 	kunmap_atomic(kaddr, KM_USER0);
 	return ext4_wb_write_single_page(page, wbc);
@@ -1086,7 +1089,7 @@ void ext4_wb_invalidatepage(struct page 
 int ext4_wb_block_truncate_page(handle_t *handle, struct page *page,
 				struct address_space *mapping, loff_t from)
 {
-	unsigned offset = from & (PAGE_CACHE_SIZE-1);
+	unsigned offset = page_cache_offset(mapping, from);
 	struct inode *inode = mapping->host;
 	struct buffer_head bh, *bhw = &bh;
 	unsigned blocksize, length;
@@ -1147,9 +1150,9 @@ void ext4_wb_init(struct super_block *sb
 	if (!test_opt(sb, DELAYED_ALLOC))
 		return;
 
-	if (PAGE_CACHE_SHIFT != sb->s_blocksize_bits) {
+	if (PAGE_SHIFT != sb->s_blocksize_bits) {
 		printk(KERN_ERR "EXT4-fs: delayed allocation isn't"
-			"supported for PAGE_CACHE_SIZE != blocksize yet\n");
+			"supported for PAGE_SIZE != blocksize yet\n");
 		clear_opt (EXT4_SB(sb)->s_mount_opt, DELAYED_ALLOC);
 		return;
 	}

-- 

  parent reply	other threads:[~2007-06-20 18:30 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20 18:29 [00/37] Large Blocksize Support V4 clameter
2007-06-20 18:29 ` [01/37] Define functions for page cache handling clameter
2007-06-20 18:29 ` [02/37] Pagecache zeroing: zero_user_segment, zero_user_segments and zero_user clameter
2007-06-20 18:29 ` [03/37] Use page_cache_xxx function in mm/filemap.c clameter
2007-06-20 18:29 ` [04/37] Use page_cache_xxx in mm/page-writeback.c clameter
2007-06-20 18:29 ` [05/37] Use page_cache_xxx in mm/truncate.c clameter
2007-06-20 18:29 ` [06/37] Use page_cache_xxx in mm/rmap.c clameter
2007-06-20 18:29 ` [07/37] Use page_cache_xxx in mm/filemap_xip.c clameter
2007-06-20 18:29 ` [08/37] Use page_cache_xxx in mm/migrate.c clameter
2007-06-20 18:29 ` [09/37] Use page_cache_xxx in fs/libfs.c clameter
2007-06-20 18:29 ` [10/37] Use page_cache_xxx in fs/sync clameter
2007-06-20 18:29 ` [11/37] Use page_cache_xxx in fs/buffer.c clameter
2007-06-20 18:29 ` [12/37] Use page_cache_xxx in mm/mpage.c clameter
2007-06-20 18:29 ` [13/37] Use page_cache_xxx in mm/fadvise.c clameter
2007-06-20 18:29 ` [14/37] Use page_cache_xxx in fs/splice.c clameter
2007-06-20 18:29 ` [15/37] Use page_cache_xxx functions in fs/ext2 clameter
2007-06-20 18:29 ` [16/37] Use page_cache_xxx in fs/ext3 clameter
2007-06-20 18:29 ` clameter [this message]
2007-06-20 18:29 ` [18/37] Use page_cache_xxx in fs/reiserfs clameter
2007-06-20 18:29 ` [19/37] Use page_cache_xxx for fs/xfs clameter
2007-06-20 18:29 ` [20/37] Fix PAGE SIZE assumption in miscellaneous places clameter
2007-06-20 18:29 ` [21/37] Use page_cache_xxx in drivers/block/loop.c clameter
2007-06-20 18:29 ` [22/37] Use page_cache_xxx in drivers/block/rd.c clameter
2007-06-20 18:29 ` [23/37] compound pages: PageHead/PageTail instead of PageCompound clameter
2007-06-20 18:29 ` [24/37] compound pages: Add new support functions clameter
2007-06-20 18:29 ` [25/37] compound pages: vmstat support clameter
2007-06-20 18:29 ` [26/37] compound pages: Use new compound vmstat functions in SLUB clameter
2007-06-20 18:29 ` [27/37] compound pages: Allow use of get_page_unless_zero with compound pages clameter
2007-06-20 18:29 ` [28/37] compound pages: Allow freeing of compound pages via pagevec clameter
2007-06-20 18:29 ` [29/37] Large blocksize support: Fix up reclaim counters clameter
2007-06-20 18:29 ` [30/37] Add VM_BUG_ONs to check for correct page order clameter
2007-06-20 18:29 ` [31/37] Large blocksize support: Core piece clameter
2007-06-21  0:20   ` Bob Picco
2007-06-21  5:26     ` Christoph Lameter
2007-06-20 18:29 ` [32/37] Readahead changes to support large blocksize clameter
2007-06-20 18:29 ` [33/37] Large blocksize: Compound page zeroing and flushing clameter
2007-06-20 18:29 ` [34/37] Large blocksize support in ramfs clameter
2007-06-20 20:50   ` Andreas Dilger
2007-06-20 21:29     ` Christoph Lameter
2007-06-20 18:29 ` [35/37] Large blocksize support in XFS clameter
2007-06-20 18:29 ` [36/37] Large blocksize support for ext2 clameter
2007-06-20 20:56   ` Andreas Dilger
2007-06-20 21:27     ` Christoph Lameter
2007-06-20 22:19       ` Andreas Dilger
2007-06-20 18:29 ` [37/37] Reiserfs: Fix up for mapping_set_gfp_mask clameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070620183009.909068099@sgi.com \
    --to=clameter@sgi.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@skynet.ie \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).