aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c65
1 files changed, 40 insertions, 25 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6dc9eaf00e5c..4127a1c0eec6 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -18,6 +18,8 @@
18#include <linux/sunrpc/clnt.h> 18#include <linux/sunrpc/clnt.h>
19#include <linux/nfs_fs.h> 19#include <linux/nfs_fs.h>
20#include <linux/nfs_page.h> 20#include <linux/nfs_page.h>
21#include <linux/smp_lock.h>
22#include <linux/module.h>
21 23
22#include <asm/system.h> 24#include <asm/system.h>
23#include "pnfs.h" 25#include "pnfs.h"
@@ -155,25 +157,20 @@ static void nfs_readpage_release(struct nfs_page *req)
155 nfs_release_request(req); 157 nfs_release_request(req);
156} 158}
157 159
158/* 160static int nfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt,
159 * Set up the NFS read request struct 161 const struct rpc_call_ops *call_ops)
160 */
161static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
162 const struct rpc_call_ops *call_ops,
163 unsigned int count, unsigned int offset,
164 struct pnfs_layout_segment *lseg)
165{ 162{
166 struct inode *inode = req->wb_context->path.dentry->d_inode; 163 struct inode *inode = data->inode;
167 int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0; 164 int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;
168 struct rpc_task *task; 165 struct rpc_task *task;
169 struct rpc_message msg = { 166 struct rpc_message msg = {
170 .rpc_argp = &data->args, 167 .rpc_argp = &data->args,
171 .rpc_resp = &data->res, 168 .rpc_resp = &data->res,
172 .rpc_cred = req->wb_context->cred, 169 .rpc_cred = data->cred,
173 }; 170 };
174 struct rpc_task_setup task_setup_data = { 171 struct rpc_task_setup task_setup_data = {
175 .task = &data->task, 172 .task = &data->task,
176 .rpc_client = NFS_CLIENT(inode), 173 .rpc_client = clnt,
177 .rpc_message = &msg, 174 .rpc_message = &msg,
178 .callback_ops = call_ops, 175 .callback_ops = call_ops,
179 .callback_data = data, 176 .callback_data = data,
@@ -181,9 +178,37 @@ static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
181 .flags = RPC_TASK_ASYNC | swap_flags, 178 .flags = RPC_TASK_ASYNC | swap_flags,
182 }; 179 };
183 180
181 /* Set up the initial task struct. */
182 NFS_PROTO(inode)->read_setup(data, &msg);
183
184 dprintk("NFS: %5u initiated read call (req %s/%lld, %u bytes @ "
185 "offset %llu)\n",
186 data->task.tk_pid,
187 inode->i_sb->s_id,
188 (long long)NFS_FILEID(inode),
189 data->args.count,
190 (unsigned long long)data->args.offset);
191
192 task = rpc_run_task(&task_setup_data);
193 if (IS_ERR(task))
194 return PTR_ERR(task);
195 rpc_put_task(task);
196 return 0;
197}
198
199/*
200 * Set up the NFS read request struct
201 */
202static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
203 const struct rpc_call_ops *call_ops,
204 unsigned int count, unsigned int offset,
205 struct pnfs_layout_segment *lseg)
206{
207 struct inode *inode = req->wb_context->path.dentry->d_inode;
208
184 data->req = req; 209 data->req = req;
185 data->inode = inode; 210 data->inode = inode;
186 data->cred = msg.rpc_cred; 211 data->cred = req->wb_context->cred;
187 data->lseg = get_lseg(lseg); 212 data->lseg = get_lseg(lseg);
188 213
189 data->args.fh = NFS_FH(inode); 214 data->args.fh = NFS_FH(inode);
@@ -199,21 +224,11 @@ static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
199 data->res.eof = 0; 224 data->res.eof = 0;
200 nfs_fattr_init(&data->fattr); 225 nfs_fattr_init(&data->fattr);
201 226
202 /* Set up the initial task struct. */ 227 if (data->lseg &&
203 NFS_PROTO(inode)->read_setup(data, &msg); 228 (pnfs_try_to_read_data(data, call_ops) == PNFS_ATTEMPTED))
204 229 return 0;
205 dprintk("NFS: %5u initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
206 data->task.tk_pid,
207 inode->i_sb->s_id,
208 (long long)NFS_FILEID(inode),
209 count,
210 (unsigned long long)data->args.offset);
211 230
212 task = rpc_run_task(&task_setup_data); 231 return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops);
213 if (IS_ERR(task))
214 return PTR_ERR(task);
215 rpc_put_task(task);
216 return 0;
217} 232}
218 233
219static void 234static void