aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-04-15 16:33:58 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-04-19 16:53:01 -0400
commitfdd1e74c89fe39259a29c494209abad63ff76f82 (patch)
tree7ec3708b7b7badeb20f705cf865afbb9c63b5406 /fs/nfs/direct.c
parent73e3302f60c0e11a0db0b34b903f591139c4f937 (diff)
NFS: Ensure that the read code cleans up properly when rpc_run_task() fails
In the case of readpage() we need to ensure that the pages get unlocked, and that the error is flagged. In the case of O_DIRECT, we need to ensure that the pages are all released. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index e44200579c8d..9d9085b93a32 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -229,14 +229,20 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq)
229static void nfs_direct_read_result(struct rpc_task *task, void *calldata) 229static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
230{ 230{
231 struct nfs_read_data *data = calldata; 231 struct nfs_read_data *data = calldata;
232 struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
233 232
234 if (nfs_readpage_result(task, data) != 0) 233 nfs_readpage_result(task, data);
235 return; 234}
235
236static void nfs_direct_read_release(void *calldata)
237{
238
239 struct nfs_read_data *data = calldata;
240 struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
241 int status = data->task.tk_status;
236 242
237 spin_lock(&dreq->lock); 243 spin_lock(&dreq->lock);
238 if (unlikely(task->tk_status < 0)) { 244 if (unlikely(status < 0)) {
239 dreq->error = task->tk_status; 245 dreq->error = status;
240 spin_unlock(&dreq->lock); 246 spin_unlock(&dreq->lock);
241 } else { 247 } else {
242 dreq->count += data->res.count; 248 dreq->count += data->res.count;
@@ -249,11 +255,12 @@ static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
249 255
250 if (put_dreq(dreq)) 256 if (put_dreq(dreq))
251 nfs_direct_complete(dreq); 257 nfs_direct_complete(dreq);
258 nfs_readdata_release(calldata);
252} 259}
253 260
254static const struct rpc_call_ops nfs_read_direct_ops = { 261static const struct rpc_call_ops nfs_read_direct_ops = {
255 .rpc_call_done = nfs_direct_read_result, 262 .rpc_call_done = nfs_direct_read_result,
256 .rpc_release = nfs_readdata_release, 263 .rpc_release = nfs_direct_read_release,
257}; 264};
258 265
259/* 266/*