aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2012-07-31 19:45:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:47 -0400
commitd56b4ddf7781ef8dd050542781cc7f55673af002 (patch)
treeafda2689b4944e5dc7fd6d4a2b31f901080ca977
parent5a178119b0fbe37f7dfb602b37df9cc4b1dc9d71 (diff)
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 <a.p.zijlstra@chello.nl> Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: David S. Miller <davem@davemloft.net> Cc: Eric B Munson <emunson@mgebm.net> Cc: Eric Paris <eparis@redhat.com> Cc: James Morris <jmorris@namei.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Mike Christie <michaelc@cs.wisc.edu> Cc: Neil Brown <neilb@suse.de> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: Xiaotian Feng <dfeng@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nfs/file.c6
-rw-r--r--fs/nfs/internal.h7
-rw-r--r--fs/nfs/pagelist.c2
-rw-r--r--fs/nfs/read.c6
-rw-r--r--fs/nfs/write.c36
5 files changed, 29 insertions, 28 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 70d124a61b98..acd4e4cd2906 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -430,7 +430,7 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)
430 if (offset != 0) 430 if (offset != 0)
431 return; 431 return;
432 /* Cancel any unstarted writes on this page */ 432 /* Cancel any unstarted writes on this page */
433 nfs_wb_page_cancel(page->mapping->host, page); 433 nfs_wb_page_cancel(page_file_mapping(page)->host, page);
434 434
435 nfs_fscache_invalidate_page(page, page->mapping->host); 435 nfs_fscache_invalidate_page(page, page->mapping->host);
436} 436}
@@ -472,7 +472,7 @@ static int nfs_release_page(struct page *page, gfp_t gfp)
472 */ 472 */
473static int nfs_launder_page(struct page *page) 473static int nfs_launder_page(struct page *page)
474{ 474{
475 struct inode *inode = page->mapping->host; 475 struct inode *inode = page_file_mapping(page)->host;
476 struct nfs_inode *nfsi = NFS_I(inode); 476 struct nfs_inode *nfsi = NFS_I(inode);
477 477
478 dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n", 478 dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n",
@@ -521,7 +521,7 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
521 nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page); 521 nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page);
522 522
523 lock_page(page); 523 lock_page(page);
524 mapping = page->mapping; 524 mapping = page_file_mapping(page);
525 if (mapping != dentry->d_inode->i_mapping) 525 if (mapping != dentry->d_inode->i_mapping)
526 goto out_unlock; 526 goto out_unlock;
527 527
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index cfafd13b6fe9..4be14b3e0a18 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -546,13 +546,14 @@ void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
546static inline 546static inline
547unsigned int nfs_page_length(struct page *page) 547unsigned int nfs_page_length(struct page *page)
548{ 548{
549 loff_t i_size = i_size_read(page->mapping->host); 549 loff_t i_size = i_size_read(page_file_mapping(page)->host);
550 550
551 if (i_size > 0) { 551 if (i_size > 0) {
552 pgoff_t page_index = page_file_index(page);
552 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 553 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
553 if (page->index < end_index) 554 if (page_index < end_index)
554 return PAGE_CACHE_SIZE; 555 return PAGE_CACHE_SIZE;
555 if (page->index == end_index) 556 if (page_index == end_index)
556 return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1; 557 return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1;
557 } 558 }
558 return 0; 559 return 0;
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index aed913c833f4..9ef8b3cf7fc7 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -117,7 +117,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
117 * long write-back delay. This will be adjusted in 117 * long write-back delay. This will be adjusted in
118 * update_nfs_request below if the region is not locked. */ 118 * update_nfs_request below if the region is not locked. */
119 req->wb_page = page; 119 req->wb_page = page;
120 req->wb_index = page->index; 120 req->wb_index = page_file_index(page);
121 page_cache_get(page); 121 page_cache_get(page);
122 req->wb_offset = offset; 122 req->wb_offset = offset;
123 req->wb_pgbase = offset; 123 req->wb_pgbase = offset;
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6267b873bbcb..7cb020782687 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -522,11 +522,11 @@ static const struct rpc_call_ops nfs_read_common_ops = {
522int nfs_readpage(struct file *file, struct page *page) 522int nfs_readpage(struct file *file, struct page *page)
523{ 523{
524 struct nfs_open_context *ctx; 524 struct nfs_open_context *ctx;
525 struct inode *inode = page->mapping->host; 525 struct inode *inode = page_file_mapping(page)->host;
526 int error; 526 int error;
527 527
528 dprintk("NFS: nfs_readpage (%p %ld@%lu)\n", 528 dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
529 page, PAGE_CACHE_SIZE, page->index); 529 page, PAGE_CACHE_SIZE, page_file_index(page));
530 nfs_inc_stats(inode, NFSIOS_VFSREADPAGE); 530 nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
531 nfs_add_stats(inode, NFSIOS_READPAGES, 1); 531 nfs_add_stats(inode, NFSIOS_READPAGES, 1);
532 532
@@ -580,7 +580,7 @@ static int
580readpage_async_filler(void *data, struct page *page) 580readpage_async_filler(void *data, struct page *page)
581{ 581{
582 struct nfs_readdesc *desc = (struct nfs_readdesc *)data; 582 struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
583 struct inode *inode = page->mapping->host; 583 struct inode *inode = page_file_mapping(page)->host;
584 struct nfs_page *new; 584 struct nfs_page *new;
585 unsigned int len; 585 unsigned int len;
586 int error; 586 int error;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index f312860c15d0..d0feca32b4fe 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -153,7 +153,7 @@ static struct nfs_page *nfs_page_find_request_locked(struct page *page)
153 153
154static struct nfs_page *nfs_page_find_request(struct page *page) 154static struct nfs_page *nfs_page_find_request(struct page *page)
155{ 155{
156 struct inode *inode = page->mapping->host; 156 struct inode *inode = page_file_mapping(page)->host;
157 struct nfs_page *req = NULL; 157 struct nfs_page *req = NULL;
158 158
159 spin_lock(&inode->i_lock); 159 spin_lock(&inode->i_lock);
@@ -165,16 +165,16 @@ static struct nfs_page *nfs_page_find_request(struct page *page)
165/* Adjust the file length if we're writing beyond the end */ 165/* Adjust the file length if we're writing beyond the end */
166static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) 166static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count)
167{ 167{
168 struct inode *inode = page->mapping->host; 168 struct inode *inode = page_file_mapping(page)->host;
169 loff_t end, i_size; 169 loff_t end, i_size;
170 pgoff_t end_index; 170 pgoff_t end_index;
171 171
172 spin_lock(&inode->i_lock); 172 spin_lock(&inode->i_lock);
173 i_size = i_size_read(inode); 173 i_size = i_size_read(inode);
174 end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 174 end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
175 if (i_size > 0 && page->index < end_index) 175 if (i_size > 0 && page_file_index(page) < end_index)
176 goto out; 176 goto out;
177 end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); 177 end = page_file_offset(page) + ((loff_t)offset+count);
178 if (i_size >= end) 178 if (i_size >= end)
179 goto out; 179 goto out;
180 i_size_write(inode, end); 180 i_size_write(inode, end);
@@ -187,7 +187,7 @@ out:
187static void nfs_set_pageerror(struct page *page) 187static void nfs_set_pageerror(struct page *page)
188{ 188{
189 SetPageError(page); 189 SetPageError(page);
190 nfs_zap_mapping(page->mapping->host, page->mapping); 190 nfs_zap_mapping(page_file_mapping(page)->host, page_file_mapping(page));
191} 191}
192 192
193/* We can set the PG_uptodate flag if we see that a write request 193/* We can set the PG_uptodate flag if we see that a write request
@@ -228,7 +228,7 @@ static int nfs_set_page_writeback(struct page *page)
228 int ret = test_set_page_writeback(page); 228 int ret = test_set_page_writeback(page);
229 229
230 if (!ret) { 230 if (!ret) {
231 struct inode *inode = page->mapping->host; 231 struct inode *inode = page_file_mapping(page)->host;
232 struct nfs_server *nfss = NFS_SERVER(inode); 232 struct nfs_server *nfss = NFS_SERVER(inode);
233 233
234 if (atomic_long_inc_return(&nfss->writeback) > 234 if (atomic_long_inc_return(&nfss->writeback) >
@@ -242,7 +242,7 @@ static int nfs_set_page_writeback(struct page *page)
242 242
243static void nfs_end_page_writeback(struct page *page) 243static void nfs_end_page_writeback(struct page *page)
244{ 244{
245 struct inode *inode = page->mapping->host; 245 struct inode *inode = page_file_mapping(page)->host;
246 struct nfs_server *nfss = NFS_SERVER(inode); 246 struct nfs_server *nfss = NFS_SERVER(inode);
247 247
248 end_page_writeback(page); 248 end_page_writeback(page);
@@ -252,7 +252,7 @@ static void nfs_end_page_writeback(struct page *page)
252 252
253static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock) 253static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock)
254{ 254{
255 struct inode *inode = page->mapping->host; 255 struct inode *inode = page_file_mapping(page)->host;
256 struct nfs_page *req; 256 struct nfs_page *req;
257 int ret; 257 int ret;
258 258
@@ -313,13 +313,13 @@ out:
313 313
314static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio) 314static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
315{ 315{
316 struct inode *inode = page->mapping->host; 316 struct inode *inode = page_file_mapping(page)->host;
317 int ret; 317 int ret;
318 318
319 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE); 319 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
320 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1); 320 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
321 321
322 nfs_pageio_cond_complete(pgio, page->index); 322 nfs_pageio_cond_complete(pgio, page_file_index(page));
323 ret = nfs_page_async_flush(pgio, page, wbc->sync_mode == WB_SYNC_NONE); 323 ret = nfs_page_async_flush(pgio, page, wbc->sync_mode == WB_SYNC_NONE);
324 if (ret == -EAGAIN) { 324 if (ret == -EAGAIN) {
325 redirty_page_for_writepage(wbc, page); 325 redirty_page_for_writepage(wbc, page);
@@ -336,7 +336,7 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
336 struct nfs_pageio_descriptor pgio; 336 struct nfs_pageio_descriptor pgio;
337 int err; 337 int err;
338 338
339 NFS_PROTO(page->mapping->host)->write_pageio_init(&pgio, 339 NFS_PROTO(page_file_mapping(page)->host)->write_pageio_init(&pgio,
340 page->mapping->host, 340 page->mapping->host,
341 wb_priority(wbc), 341 wb_priority(wbc),
342 &nfs_async_write_completion_ops); 342 &nfs_async_write_completion_ops);
@@ -471,7 +471,7 @@ nfs_request_add_commit_list(struct nfs_page *req, struct list_head *dst,
471 spin_unlock(cinfo->lock); 471 spin_unlock(cinfo->lock);
472 if (!cinfo->dreq) { 472 if (!cinfo->dreq) {
473 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 473 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
474 inc_bdi_stat(req->wb_page->mapping->backing_dev_info, 474 inc_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info,
475 BDI_RECLAIMABLE); 475 BDI_RECLAIMABLE);
476 __mark_inode_dirty(req->wb_context->dentry->d_inode, 476 __mark_inode_dirty(req->wb_context->dentry->d_inode,
477 I_DIRTY_DATASYNC); 477 I_DIRTY_DATASYNC);
@@ -538,7 +538,7 @@ static void
538nfs_clear_page_commit(struct page *page) 538nfs_clear_page_commit(struct page *page)
539{ 539{
540 dec_zone_page_state(page, NR_UNSTABLE_NFS); 540 dec_zone_page_state(page, NR_UNSTABLE_NFS);
541 dec_bdi_stat(page->mapping->backing_dev_info, BDI_RECLAIMABLE); 541 dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE);
542} 542}
543 543
544static void 544static void
@@ -789,7 +789,7 @@ out_err:
789static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx, 789static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx,
790 struct page *page, unsigned int offset, unsigned int bytes) 790 struct page *page, unsigned int offset, unsigned int bytes)
791{ 791{
792 struct inode *inode = page->mapping->host; 792 struct inode *inode = page_file_mapping(page)->host;
793 struct nfs_page *req; 793 struct nfs_page *req;
794 794
795 req = nfs_try_to_update_request(inode, page, offset, bytes); 795 req = nfs_try_to_update_request(inode, page, offset, bytes);
@@ -842,7 +842,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
842 nfs_release_request(req); 842 nfs_release_request(req);
843 if (!do_flush) 843 if (!do_flush)
844 return 0; 844 return 0;
845 status = nfs_wb_page(page->mapping->host, page); 845 status = nfs_wb_page(page_file_mapping(page)->host, page);
846 } while (status == 0); 846 } while (status == 0);
847 return status; 847 return status;
848} 848}
@@ -872,7 +872,7 @@ int nfs_updatepage(struct file *file, struct page *page,
872 unsigned int offset, unsigned int count) 872 unsigned int offset, unsigned int count)
873{ 873{
874 struct nfs_open_context *ctx = nfs_file_open_context(file); 874 struct nfs_open_context *ctx = nfs_file_open_context(file);
875 struct inode *inode = page->mapping->host; 875 struct inode *inode = page_file_mapping(page)->host;
876 int status = 0; 876 int status = 0;
877 877
878 nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); 878 nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
@@ -880,7 +880,7 @@ int nfs_updatepage(struct file *file, struct page *page,
880 dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n", 880 dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n",
881 file->f_path.dentry->d_parent->d_name.name, 881 file->f_path.dentry->d_parent->d_name.name,
882 file->f_path.dentry->d_name.name, count, 882 file->f_path.dentry->d_name.name, count,
883 (long long)(page_offset(page) + offset)); 883 (long long)(page_file_offset(page) + offset));
884 884
885 /* If we're not using byte range locks, and we know the page 885 /* If we're not using byte range locks, and we know the page
886 * is up to date, it may be more efficient to extend the write 886 * is up to date, it may be more efficient to extend the write
@@ -1469,7 +1469,7 @@ void nfs_retry_commit(struct list_head *page_list,
1469 nfs_mark_request_commit(req, lseg, cinfo); 1469 nfs_mark_request_commit(req, lseg, cinfo);
1470 if (!cinfo->dreq) { 1470 if (!cinfo->dreq) {
1471 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 1471 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
1472 dec_bdi_stat(req->wb_page->mapping->backing_dev_info, 1472 dec_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info,
1473 BDI_RECLAIMABLE); 1473 BDI_RECLAIMABLE);
1474 } 1474 }
1475 nfs_unlock_and_release_request(req); 1475 nfs_unlock_and_release_request(req);