aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
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 /fs/nfs/write.c
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>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c36
1 files changed, 18 insertions, 18 deletions
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);