aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-13 15:23:44 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-02-03 18:35:06 -0500
commit8e0969f0451eaf7cf32f2ec3946196d8d0b1cb2c (patch)
tree66f3e1ca0761d77e21ac3d24bacc1574189cfc64 /fs/nfs/read.c
parentc228fd3aeef55637354167faead74c579d5da28b (diff)
NFS: Remove nfs_readpage_sync()
It makes no sense to maintain 2 parallel systems for reading in pages. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c105
1 files changed, 2 insertions, 103 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index a9c26521a9e2..4affb536ada3 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -5,14 +5,6 @@
5 * 5 *
6 * Partial copy of Linus' read cache modifications to fs/nfs/file.c 6 * Partial copy of Linus' read cache modifications to fs/nfs/file.c
7 * modified for async RPC by okir@monad.swb.de 7 * modified for async RPC by okir@monad.swb.de
8 *
9 * We do an ugly hack here in order to return proper error codes to the
10 * user program when a read request failed: since generic_file_read
11 * only checks the return value of inode->i_op->readpage() which is always 0
12 * for async RPC, we set the error bit of the page to 1 when an error occurs,
13 * and make nfs_readpage transmit requests synchronously when encountering this.
14 * This is only a small problem, though, since we now retry all operations
15 * within the RPC code when root squashing is suspected.
16 */ 8 */
17 9
18#include <linux/time.h> 10#include <linux/time.h>
@@ -122,93 +114,6 @@ static void nfs_readpage_truncate_uninitialised_page(struct nfs_read_data *data)
122 } 114 }
123} 115}
124 116
125/*
126 * Read a page synchronously.
127 */
128static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode,
129 struct page *page)
130{
131 unsigned int rsize = NFS_SERVER(inode)->rsize;
132 unsigned int count = PAGE_CACHE_SIZE;
133 int result = -ENOMEM;
134 struct nfs_read_data *rdata;
135
136 rdata = nfs_readdata_alloc(count);
137 if (!rdata)
138 goto out_unlock;
139
140 memset(rdata, 0, sizeof(*rdata));
141 rdata->flags = (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
142 rdata->cred = ctx->cred;
143 rdata->inode = inode;
144 INIT_LIST_HEAD(&rdata->pages);
145 rdata->args.fh = NFS_FH(inode);
146 rdata->args.context = ctx;
147 rdata->args.pages = &page;
148 rdata->args.pgbase = 0UL;
149 rdata->args.count = rsize;
150 rdata->res.fattr = &rdata->fattr;
151
152 dprintk("NFS: nfs_readpage_sync(%p)\n", page);
153
154 /*
155 * This works now because the socket layer never tries to DMA
156 * into this buffer directly.
157 */
158 do {
159 if (count < rsize)
160 rdata->args.count = count;
161 rdata->res.count = rdata->args.count;
162 rdata->args.offset = page_offset(page) + rdata->args.pgbase;
163
164 dprintk("NFS: nfs_proc_read(%s, (%s/%Ld), %Lu, %u)\n",
165 NFS_SERVER(inode)->nfs_client->cl_hostname,
166 inode->i_sb->s_id,
167 (long long)NFS_FILEID(inode),
168 (unsigned long long)rdata->args.pgbase,
169 rdata->args.count);
170
171 lock_kernel();
172 result = NFS_PROTO(inode)->read(rdata);
173 unlock_kernel();
174
175 /*
176 * Even if we had a partial success we can't mark the page
177 * cache valid.
178 */
179 if (result < 0) {
180 if (result == -EISDIR)
181 result = -EINVAL;
182 goto io_error;
183 }
184 count -= result;
185 rdata->args.pgbase += result;
186 nfs_add_stats(inode, NFSIOS_SERVERREADBYTES, result);
187
188 /* Note: result == 0 should only happen if we're caching
189 * a write that extends the file and punches a hole.
190 */
191 if (rdata->res.eof != 0 || result == 0)
192 break;
193 } while (count);
194 spin_lock(&inode->i_lock);
195 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
196 spin_unlock(&inode->i_lock);
197
198 if (rdata->res.eof || rdata->res.count == rdata->args.count) {
199 SetPageUptodate(page);
200 if (rdata->res.eof && count != 0)
201 memclear_highpage_flush(page, rdata->args.pgbase, count);
202 }
203 result = 0;
204
205io_error:
206 nfs_readdata_free(rdata);
207out_unlock:
208 unlock_page(page);
209 return result;
210}
211
212static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, 117static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
213 struct page *page) 118 struct page *page)
214{ 119{
@@ -621,15 +526,9 @@ int nfs_readpage(struct file *file, struct page *page)
621 } else 526 } else
622 ctx = get_nfs_open_context((struct nfs_open_context *) 527 ctx = get_nfs_open_context((struct nfs_open_context *)
623 file->private_data); 528 file->private_data);
624 if (!IS_SYNC(inode)) {
625 error = nfs_readpage_async(ctx, inode, page);
626 goto out;
627 }
628 529
629 error = nfs_readpage_sync(ctx, inode, page); 530 error = nfs_readpage_async(ctx, inode, page);
630 if (error < 0 && IS_SWAPFILE(inode)) 531
631 printk("Aiee.. nfs swap-in of page failed!\n");
632out:
633 put_nfs_open_context(ctx); 532 put_nfs_open_context(ctx);
634 return error; 533 return error;
635 534