aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
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
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')
-rw-r--r--fs/nfs/nfs3proc.c24
-rw-r--r--fs/nfs/nfs4proc.c39
-rw-r--r--fs/nfs/proc.c30
-rw-r--r--fs/nfs/read.c105
4 files changed, 2 insertions, 196 deletions
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index acd8fe9762d3..7d0371e2bad5 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -253,29 +253,6 @@ static int nfs3_proc_readlink(struct inode *inode, struct page *page,
253 return status; 253 return status;
254} 254}
255 255
256static int nfs3_proc_read(struct nfs_read_data *rdata)
257{
258 int flags = rdata->flags;
259 struct inode * inode = rdata->inode;
260 struct nfs_fattr * fattr = rdata->res.fattr;
261 struct rpc_message msg = {
262 .rpc_proc = &nfs3_procedures[NFS3PROC_READ],
263 .rpc_argp = &rdata->args,
264 .rpc_resp = &rdata->res,
265 .rpc_cred = rdata->cred,
266 };
267 int status;
268
269 dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
270 (long long) rdata->args.offset);
271 nfs_fattr_init(fattr);
272 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
273 if (status >= 0)
274 nfs_refresh_inode(inode, fattr);
275 dprintk("NFS reply read: %d\n", status);
276 return status;
277}
278
279/* 256/*
280 * Create a regular file. 257 * Create a regular file.
281 * For now, we don't implement O_EXCL. 258 * For now, we don't implement O_EXCL.
@@ -855,7 +832,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
855 .lookup = nfs3_proc_lookup, 832 .lookup = nfs3_proc_lookup,
856 .access = nfs3_proc_access, 833 .access = nfs3_proc_access,
857 .readlink = nfs3_proc_readlink, 834 .readlink = nfs3_proc_readlink,
858 .read = nfs3_proc_read,
859 .create = nfs3_proc_create, 835 .create = nfs3_proc_create,
860 .remove = nfs3_proc_remove, 836 .remove = nfs3_proc_remove,
861 .unlink_setup = nfs3_proc_unlink_setup, 837 .unlink_setup = nfs3_proc_unlink_setup,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 665859214fa2..5b2446173dd8 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1734,44 +1734,6 @@ static int nfs4_proc_readlink(struct inode *inode, struct page *page,
1734 return err; 1734 return err;
1735} 1735}
1736 1736
1737static int _nfs4_proc_read(struct nfs_read_data *rdata)
1738{
1739 int flags = rdata->flags;
1740 struct inode *inode = rdata->inode;
1741 struct nfs_fattr *fattr = rdata->res.fattr;
1742 struct nfs_server *server = NFS_SERVER(inode);
1743 struct rpc_message msg = {
1744 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ],
1745 .rpc_argp = &rdata->args,
1746 .rpc_resp = &rdata->res,
1747 .rpc_cred = rdata->cred,
1748 };
1749 unsigned long timestamp = jiffies;
1750 int status;
1751
1752 dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
1753 (long long) rdata->args.offset);
1754
1755 nfs_fattr_init(fattr);
1756 status = rpc_call_sync(server->client, &msg, flags);
1757 if (!status)
1758 renew_lease(server, timestamp);
1759 dprintk("NFS reply read: %d\n", status);
1760 return status;
1761}
1762
1763static int nfs4_proc_read(struct nfs_read_data *rdata)
1764{
1765 struct nfs4_exception exception = { };
1766 int err;
1767 do {
1768 err = nfs4_handle_exception(NFS_SERVER(rdata->inode),
1769 _nfs4_proc_read(rdata),
1770 &exception);
1771 } while (exception.retry);
1772 return err;
1773}
1774
1775/* 1737/*
1776 * Got race? 1738 * Got race?
1777 * We will need to arrange for the VFS layer to provide an atomic open. 1739 * We will need to arrange for the VFS layer to provide an atomic open.
@@ -3643,7 +3605,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
3643 .lookup = nfs4_proc_lookup, 3605 .lookup = nfs4_proc_lookup,
3644 .access = nfs4_proc_access, 3606 .access = nfs4_proc_access,
3645 .readlink = nfs4_proc_readlink, 3607 .readlink = nfs4_proc_readlink,
3646 .read = nfs4_proc_read,
3647 .create = nfs4_proc_create, 3608 .create = nfs4_proc_create,
3648 .remove = nfs4_proc_remove, 3609 .remove = nfs4_proc_remove,
3649 .unlink_setup = nfs4_proc_unlink_setup, 3610 .unlink_setup = nfs4_proc_unlink_setup,
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 560536ad74a4..1dcf56de9482 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -186,35 +186,6 @@ static int nfs_proc_readlink(struct inode *inode, struct page *page,
186 return status; 186 return status;
187} 187}
188 188
189static int nfs_proc_read(struct nfs_read_data *rdata)
190{
191 int flags = rdata->flags;
192 struct inode * inode = rdata->inode;
193 struct nfs_fattr * fattr = rdata->res.fattr;
194 struct rpc_message msg = {
195 .rpc_proc = &nfs_procedures[NFSPROC_READ],
196 .rpc_argp = &rdata->args,
197 .rpc_resp = &rdata->res,
198 .rpc_cred = rdata->cred,
199 };
200 int status;
201
202 dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
203 (long long) rdata->args.offset);
204 nfs_fattr_init(fattr);
205 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
206 if (status >= 0) {
207 nfs_refresh_inode(inode, fattr);
208 /* Emulate the eof flag, which isn't normally needed in NFSv2
209 * as it is guaranteed to always return the file attributes
210 */
211 if (rdata->args.offset + rdata->args.count >= fattr->size)
212 rdata->res.eof = 1;
213 }
214 dprintk("NFS reply read: %d\n", status);
215 return status;
216}
217
218static int 189static int
219nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 190nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
220 int flags, struct nameidata *nd) 191 int flags, struct nameidata *nd)
@@ -666,7 +637,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
666 .lookup = nfs_proc_lookup, 637 .lookup = nfs_proc_lookup,
667 .access = NULL, /* access */ 638 .access = NULL, /* access */
668 .readlink = nfs_proc_readlink, 639 .readlink = nfs_proc_readlink,
669 .read = nfs_proc_read,
670 .create = nfs_proc_create, 640 .create = nfs_proc_create,
671 .remove = nfs_proc_remove, 641 .remove = nfs_proc_remove,
672 .unlink_setup = nfs_proc_unlink_setup, 642 .unlink_setup = nfs_proc_unlink_setup,
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