[PATCH 26/29] nfs: teach the NFS client how to treat PG_swapcache pages
Replace all relevant occurences of page->index and page->mapping in the NFS client with the new page_file_index() and page_file_mapping() functions. Signed-off-by: Peter Zijlstra <[EMAIL PROTECTED]> --- fs/nfs/file.c |8 fs/nfs/internal.h |7 --- fs/nfs/pagelist.c |6 +++--- fs/nfs/read.c |6 +++--- fs/nfs/write.c| 49 + 5 files changed, 39 insertions(+), 37 deletions(-) Index: linux-2.6/fs/nfs/file.c === --- linux-2.6.orig/fs/nfs/file.c +++ linux-2.6/fs/nfs/file.c @@ -357,7 +357,7 @@ static void nfs_invalidate_page(struct p if (offset != 0) return; /* Cancel any unstarted writes on this page */ - nfs_wb_page_cancel(page->mapping->host, page); + nfs_wb_page_cancel(page_file_mapping(page)->host, page); } static int nfs_release_page(struct page *page, gfp_t gfp) @@ -368,7 +368,7 @@ static int nfs_release_page(struct page static int nfs_launder_page(struct page *page) { - return nfs_wb_page(page->mapping->host, page); + return nfs_wb_page(page_file_mapping(page)->host, page); } const struct address_space_operations nfs_file_aops = { @@ -397,13 +397,13 @@ static int nfs_vm_page_mkwrite(struct vm loff_t offset; lock_page(page); - mapping = page->mapping; + mapping = page_file_mapping(page); if (mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping) { unlock_page(page); return -EINVAL; } pagelen = nfs_page_length(page); - offset = (loff_t)page->index << PAGE_CACHE_SHIFT; + offset = (loff_t)page_file_index(page) << PAGE_CACHE_SHIFT; unlock_page(page); /* Index: linux-2.6/fs/nfs/pagelist.c === --- linux-2.6.orig/fs/nfs/pagelist.c +++ linux-2.6/fs/nfs/pagelist.c @@ -77,11 +77,11 @@ nfs_create_request(struct nfs_open_conte * update_nfs_request below if the region is not locked. */ req->wb_page= page; atomic_set(&req->wb_complete, 0); - req->wb_index = page->index; + req->wb_index = page_file_index(page); page_cache_get(page); BUG_ON(PagePrivate(page)); BUG_ON(!PageLocked(page)); - BUG_ON(page->mapping->host != inode); + BUG_ON(page_file_mapping(page)->host != inode); req->wb_offset = offset; req->wb_pgbase = offset; req->wb_bytes = count; @@ -383,7 +383,7 @@ void nfs_pageio_cond_complete(struct nfs * nfs_scan_list - Scan a list for matching requests * @nfsi: NFS inode * @dst: Destination list - * @idx_start: lower bound of page->index to scan + * @idx_start: lower bound of page_file_index(page) to scan * @npages: idx_start + npages sets the upper bound to scan. * @tag: tag to scan for * Index: linux-2.6/fs/nfs/read.c === --- linux-2.6.orig/fs/nfs/read.c +++ linux-2.6/fs/nfs/read.c @@ -460,11 +460,11 @@ static const struct rpc_call_ops nfs_rea int nfs_readpage(struct file *file, struct page *page) { struct nfs_open_context *ctx; - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; int error; dprintk("NFS: nfs_readpage (%p [EMAIL PROTECTED])\n", - page, PAGE_CACHE_SIZE, page->index); + page, PAGE_CACHE_SIZE, page_file_index(page)); nfs_inc_stats(inode, NFSIOS_VFSREADPAGE); nfs_add_stats(inode, NFSIOS_READPAGES, 1); @@ -511,7 +511,7 @@ static int readpage_async_filler(void *data, struct page *page) { struct nfs_readdesc *desc = (struct nfs_readdesc *)data; - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; struct nfs_page *new; unsigned int len; int error; Index: linux-2.6/fs/nfs/write.c === --- linux-2.6.orig/fs/nfs/write.c +++ linux-2.6/fs/nfs/write.c @@ -126,7 +126,7 @@ static struct nfs_page *nfs_page_find_re static struct nfs_page *nfs_page_find_request(struct page *page) { - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; struct nfs_page *req = NULL; spin_lock(&inode->i_lock); @@ -138,13 +138,13 @@ static struct nfs_page *nfs_page_find_re /* Adjust the file length if we're writing beyond the end */ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) { - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; loff_t end, i_size = i_size_read(inode); pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; - if (i_size > 0 && page->index
[PATCH 26/29] nfs: teach the NFS client how to treat PG_swapcache pages
Replace all relevant occurences of page->index and page->mapping in the NFS client with the new page_file_index() and page_file_mapping() functions. Signed-off-by: Peter Zijlstra <[EMAIL PROTECTED]> Cc: Trond Myklebust <[EMAIL PROTECTED]> --- fs/nfs/file.c |4 ++-- fs/nfs/internal.h |7 --- fs/nfs/pagelist.c |6 +++--- fs/nfs/read.c |6 +++--- fs/nfs/write.c| 35 ++- 5 files changed, 30 insertions(+), 28 deletions(-) Index: linux-2.6/fs/nfs/file.c === --- linux-2.6.orig/fs/nfs/file.c +++ linux-2.6/fs/nfs/file.c @@ -310,7 +310,7 @@ static void nfs_invalidate_page(struct p if (offset != 0) return; /* Cancel any unstarted writes on this page */ - nfs_wb_page_priority(page->mapping->host, page, FLUSH_INVALIDATE); + nfs_wb_page_priority(page_file_mapping(page)->host, page, FLUSH_INVALIDATE); } static int nfs_release_page(struct page *page, gfp_t gfp) @@ -321,7 +321,7 @@ static int nfs_release_page(struct page static int nfs_launder_page(struct page *page) { - return nfs_wb_page(page->mapping->host, page); + return nfs_wb_page(page_file_mapping(page)->host, page); } const struct address_space_operations nfs_file_aops = { Index: linux-2.6/fs/nfs/pagelist.c === --- linux-2.6.orig/fs/nfs/pagelist.c +++ linux-2.6/fs/nfs/pagelist.c @@ -81,11 +81,11 @@ nfs_create_request(struct nfs_open_conte * update_nfs_request below if the region is not locked. */ req->wb_page= page; atomic_set(&req->wb_complete, 0); - req->wb_index = page->index; + req->wb_index = page_file_index(page); page_cache_get(page); BUG_ON(PagePrivate(page)); BUG_ON(!PageLocked(page)); - BUG_ON(page->mapping->host != inode); + BUG_ON(page_file_mapping(page)->host != inode); req->wb_offset = offset; req->wb_pgbase = offset; req->wb_bytes = count; @@ -338,7 +338,7 @@ out: * @nfsi: NFS inode * @head: One of the NFS inode request lists * @dst: Destination list - * @idx_start: lower bound of page->index to scan + * @idx_start: lower bound of page_file_index(page) to scan * @npages: idx_start + npages sets the upper bound to scan. * * Moves elements from one of the inode request lists. Index: linux-2.6/fs/nfs/read.c === --- linux-2.6.orig/fs/nfs/read.c +++ linux-2.6/fs/nfs/read.c @@ -492,11 +492,11 @@ static const struct rpc_call_ops nfs_rea int nfs_readpage(struct file *file, struct page *page) { struct nfs_open_context *ctx; - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; int error; dprintk("NFS: nfs_readpage (%p [EMAIL PROTECTED])\n", - page, PAGE_CACHE_SIZE, page->index); + page, PAGE_CACHE_SIZE, page_file_index(page)); nfs_inc_stats(inode, NFSIOS_VFSREADPAGE); nfs_add_stats(inode, NFSIOS_READPAGES, 1); @@ -543,7 +543,7 @@ static int readpage_async_filler(void *data, struct page *page) { struct nfs_readdesc *desc = (struct nfs_readdesc *)data; - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; struct nfs_page *new; unsigned int len; Index: linux-2.6/fs/nfs/write.c === --- linux-2.6.orig/fs/nfs/write.c +++ linux-2.6/fs/nfs/write.c @@ -122,7 +122,7 @@ static struct nfs_page *nfs_page_find_re static struct nfs_page *nfs_page_find_request(struct page *page) { struct nfs_page *req = NULL; - spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock; + spinlock_t *req_lock = &NFS_I(page_file_mapping(page)->host)->req_lock; spin_lock(req_lock); req = nfs_page_find_request_locked(page); @@ -133,13 +133,13 @@ static struct nfs_page *nfs_page_find_re /* Adjust the file length if we're writing beyond the end */ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) { - struct inode *inode = page->mapping->host; + struct inode *inode = page_file_mapping(page)->host; loff_t end, i_size = i_size_read(inode); unsigned long end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; - if (i_size > 0 && page->index < end_index) + if (i_size > 0 && page_file_index(page) < end_index) return; - end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); + end = page_offset(page) + ((loff_t)offset+count); if (i_size >= end) return; nfs_inc_stats(inode, NFSIOS_EXTENDWRITE); @@ -150,7 +150,7 @@ static void nfs_grow_file(struct page *p static void nfs_set_pageerr