aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-30 03:54:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-30 03:54:24 -0500
commit85004cc367abc000aa36c0d0e270ab609a68b0cb (patch)
tree5739aae778d67b6d119fe5c668313fc2823e9836 /fs/nfs/read.c
parent149a051f82d2b3860fe32fa182dbc83a66274894 (diff)
parent3fbd67ad61f6d5a09ea717b56c50bc5c3d8042a8 (diff)
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
* git://git.linux-nfs.org/pub/linux/nfs-2.6: (118 commits) NFSv4: Iterate through all nfs_clients when the server recalls a delegation NFSv4: Deal more correctly with duplicate delegations NFS: Fix a potential race between umount and nfs_access_cache_shrinker() NFS: Add an asynchronous delegreturn operation for use in nfs_clear_inode nfs: convert NFS_*(inode) helpers to static inline nfs: obliterate NFS_FLAGS macro NFS: Address memory leaks in the NFS client mount option parser nfs4: allow nfsv4 acls on non-regular-files NFS: Optimise away the sigmask code in aio/dio reads and writes SUNRPC: Don't bother changing the sigmask for asynchronous RPC calls SUNRPC: rpcb_getport_sync() passes incorrect address size to rpc_create() SUNRPC: Clean up block comment preceding rpcb_getport_sync() SUNRPC: Use appropriate argument types in rpcb client SUNRPC: rpcb_getport_sync() should use built-in hostname generator SUNRPC: Clean up functions that free address_strings array NFS: NFS version number is unsigned NLM: Fix a bogus 'return' in nlmclnt_rpc_release NLM: Introduce an arguments structure for nlmclnt_init() NLM/NFS: Use cached nlm_host when calling nlmclnt_proc() NFS: Invoke nlmclnt_init during NFS mount processing ...
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 4587a86adaac..8fd6dfbe1bc3 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -160,12 +160,26 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
160 const struct rpc_call_ops *call_ops, 160 const struct rpc_call_ops *call_ops,
161 unsigned int count, unsigned int offset) 161 unsigned int count, unsigned int offset)
162{ 162{
163 struct inode *inode; 163 struct inode *inode = req->wb_context->path.dentry->d_inode;
164 int flags; 164 int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;
165 struct rpc_task *task;
166 struct rpc_message msg = {
167 .rpc_argp = &data->args,
168 .rpc_resp = &data->res,
169 .rpc_cred = req->wb_context->cred,
170 };
171 struct rpc_task_setup task_setup_data = {
172 .task = &data->task,
173 .rpc_client = NFS_CLIENT(inode),
174 .rpc_message = &msg,
175 .callback_ops = call_ops,
176 .callback_data = data,
177 .flags = RPC_TASK_ASYNC | swap_flags,
178 };
165 179
166 data->req = req; 180 data->req = req;
167 data->inode = inode = req->wb_context->path.dentry->d_inode; 181 data->inode = inode;
168 data->cred = req->wb_context->cred; 182 data->cred = msg.rpc_cred;
169 183
170 data->args.fh = NFS_FH(inode); 184 data->args.fh = NFS_FH(inode);
171 data->args.offset = req_offset(req) + offset; 185 data->args.offset = req_offset(req) + offset;
@@ -180,11 +194,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
180 nfs_fattr_init(&data->fattr); 194 nfs_fattr_init(&data->fattr);
181 195
182 /* Set up the initial task struct. */ 196 /* Set up the initial task struct. */
183 flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0); 197 NFS_PROTO(inode)->read_setup(data, &msg);
184 rpc_init_task(&data->task, NFS_CLIENT(inode), flags, call_ops, data);
185 NFS_PROTO(inode)->read_setup(data);
186
187 data->task.tk_cookie = (unsigned long)inode;
188 198
189 dprintk("NFS: %5u initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n", 199 dprintk("NFS: %5u initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
190 data->task.tk_pid, 200 data->task.tk_pid,
@@ -192,6 +202,10 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
192 (long long)NFS_FILEID(inode), 202 (long long)NFS_FILEID(inode),
193 count, 203 count,
194 (unsigned long long)data->args.offset); 204 (unsigned long long)data->args.offset);
205
206 task = rpc_run_task(&task_setup_data);
207 if (!IS_ERR(task))
208 rpc_put_task(task);
195} 209}
196 210
197static void 211static void
@@ -208,19 +222,6 @@ nfs_async_read_error(struct list_head *head)
208} 222}
209 223
210/* 224/*
211 * Start an async read operation
212 */
213static void nfs_execute_read(struct nfs_read_data *data)
214{
215 struct rpc_clnt *clnt = NFS_CLIENT(data->inode);
216 sigset_t oldset;
217
218 rpc_clnt_sigmask(clnt, &oldset);
219 rpc_execute(&data->task);
220 rpc_clnt_sigunmask(clnt, &oldset);
221}
222
223/*
224 * Generate multiple requests to fill a single page. 225 * Generate multiple requests to fill a single page.
225 * 226 *
226 * We optimize to reduce the number of read operations on the wire. If we 227 * We optimize to reduce the number of read operations on the wire. If we
@@ -274,7 +275,6 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
274 rsize, offset); 275 rsize, offset);
275 offset += rsize; 276 offset += rsize;
276 nbytes -= rsize; 277 nbytes -= rsize;
277 nfs_execute_read(data);
278 } while (nbytes != 0); 278 } while (nbytes != 0);
279 279
280 return 0; 280 return 0;
@@ -312,8 +312,6 @@ static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned
312 req = nfs_list_entry(data->pages.next); 312 req = nfs_list_entry(data->pages.next);
313 313
314 nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0); 314 nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0);
315
316 nfs_execute_read(data);
317 return 0; 315 return 0;
318out_bad: 316out_bad:
319 nfs_async_read_error(head); 317 nfs_async_read_error(head);
@@ -338,7 +336,7 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
338 nfs_add_stats(data->inode, NFSIOS_SERVERREADBYTES, data->res.count); 336 nfs_add_stats(data->inode, NFSIOS_SERVERREADBYTES, data->res.count);
339 337
340 if (task->tk_status == -ESTALE) { 338 if (task->tk_status == -ESTALE) {
341 set_bit(NFS_INO_STALE, &NFS_FLAGS(data->inode)); 339 set_bit(NFS_INO_STALE, &NFS_I(data->inode)->flags);
342 nfs_mark_for_revalidate(data->inode); 340 nfs_mark_for_revalidate(data->inode);
343 } 341 }
344 return 0; 342 return 0;