summaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2011-06-10 13:30:23 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-12 13:40:28 -0400
commit1751c3638f2a07a8c66a803a31791bab9bd3fced (patch)
tree5c1f39f879c0a0049c50b4f36a256ba1986d82b2 /fs/nfs/read.c
parentf062eb6ced3b297277b94b4da3113b1d3782e539 (diff)
NFS: Cleanup of the nfs_pageio code in preparation for a pnfs bugfix
We need to ensure that the layouts are set up before we can decide to coalesce requests. To do so, we want to further split up the struct nfs_pageio_descriptor operations into an initialisation callback, a coalescing test callback, and a 'do i/o' callback. This patch cleans up the existing callback methods before adding the 'initialisation' callback. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 20a7f952e244..b6d9ec9a208b 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -32,6 +32,7 @@
32 32
33static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc); 33static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc);
34static int nfs_pagein_one(struct nfs_pageio_descriptor *desc); 34static int nfs_pagein_one(struct nfs_pageio_descriptor *desc);
35static const struct nfs_pageio_ops nfs_pageio_read_ops;
35static const struct rpc_call_ops nfs_read_partial_ops; 36static const struct rpc_call_ops nfs_read_partial_ops;
36static const struct rpc_call_ops nfs_read_full_ops; 37static const struct rpc_call_ops nfs_read_full_ops;
37 38
@@ -113,6 +114,20 @@ static void nfs_readpage_truncate_uninitialised_page(struct nfs_read_data *data)
113 } 114 }
114} 115}
115 116
117static void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio,
118 struct inode *inode)
119{
120 nfs_pageio_init(pgio, inode, &nfs_pageio_read_ops,
121 NFS_SERVER(inode)->rsize, 0);
122}
123
124static void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
125 struct inode *inode)
126{
127 if (!pnfs_pageio_init_read(pgio, inode))
128 nfs_pageio_init_read_mds(pgio, inode);
129}
130
116int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, 131int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
117 struct page *page) 132 struct page *page)
118{ 133{
@@ -131,14 +146,11 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
131 if (len < PAGE_CACHE_SIZE) 146 if (len < PAGE_CACHE_SIZE)
132 zero_user_segment(page, len, PAGE_CACHE_SIZE); 147 zero_user_segment(page, len, PAGE_CACHE_SIZE);
133 148
134 nfs_pageio_init(&pgio, inode, NULL, 0, 0); 149 nfs_pageio_init_read(&pgio, inode);
135 nfs_list_add_request(new, &pgio.pg_list); 150 nfs_list_add_request(new, &pgio.pg_list);
136 pgio.pg_count = len; 151 pgio.pg_count = len;
137 152
138 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE) 153 nfs_pageio_complete(&pgio);
139 nfs_pagein_multi(&pgio);
140 else
141 nfs_pagein_one(&pgio);
142 return 0; 154 return 0;
143} 155}
144 156
@@ -365,6 +377,20 @@ out:
365 return ret; 377 return ret;
366} 378}
367 379
380int nfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
381{
382 if (desc->pg_bsize < PAGE_CACHE_SIZE)
383 return nfs_pagein_multi(desc);
384 return nfs_pagein_one(desc);
385}
386EXPORT_SYMBOL_GPL(nfs_generic_pg_readpages);
387
388
389static const struct nfs_pageio_ops nfs_pageio_read_ops = {
390 .pg_test = nfs_generic_pg_test,
391 .pg_doio = nfs_generic_pg_readpages,
392};
393
368/* 394/*
369 * This is the callback from RPC telling us whether a reply was 395 * This is the callback from RPC telling us whether a reply was
370 * received or some error occurred (timeout or socket shutdown). 396 * received or some error occurred (timeout or socket shutdown).
@@ -635,8 +661,6 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
635 .pgio = &pgio, 661 .pgio = &pgio,
636 }; 662 };
637 struct inode *inode = mapping->host; 663 struct inode *inode = mapping->host;
638 struct nfs_server *server = NFS_SERVER(inode);
639 size_t rsize = server->rsize;
640 unsigned long npages; 664 unsigned long npages;
641 int ret = -ESTALE; 665 int ret = -ESTALE;
642 666
@@ -664,10 +688,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
664 if (ret == 0) 688 if (ret == 0)
665 goto read_complete; /* all pages were read */ 689 goto read_complete; /* all pages were read */
666 690
667 if (rsize < PAGE_CACHE_SIZE) 691 nfs_pageio_init_read(&pgio, inode);
668 nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0);
669 else
670 nfs_pageio_init(&pgio, inode, nfs_pagein_one, rsize, 0);
671 692
672 ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); 693 ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
673 694