aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-03 16:42:45 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:40 -0400
commit549d6ed5e85003370fe858e70864a71882491d28 (patch)
treea5094cbce64f07560f0e3511279260e40c0ae669 /fs/nfs/nfs4proc.c
parent1c816efa245111c52858fbe55d99474f3c149dd3 (diff)
NFSv4: set the delegation in nfs4_opendata_to_nfs4_state
This ensures that nfs4_open_release() and nfs4_open_confirm_release() can now handle an eventual delegation that was returned with out open. As such, it fixes a delegation "leak" when the user breaks out of an open call. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 69aab8db4947..4f0b06d549fa 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -356,6 +356,21 @@ static struct nfs4_state *nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data
356 if (state == NULL) 356 if (state == NULL)
357 goto put_inode; 357 goto put_inode;
358 update_open_stateid(state, &data->o_res.stateid, data->o_arg.open_flags); 358 update_open_stateid(state, &data->o_res.stateid, data->o_arg.open_flags);
359 if (data->o_res.delegation_type != 0) {
360 struct nfs_inode *nfsi = NFS_I(inode);
361 int delegation_flags = 0;
362
363 if (nfsi->delegation)
364 delegation_flags = nfsi->delegation->flags;
365 if (!(delegation_flags & NFS_DELEGATION_NEED_RECLAIM))
366 nfs_inode_set_delegation(state->inode,
367 data->owner->so_cred,
368 &data->o_res);
369 else
370 nfs_inode_reclaim_delegation(state->inode,
371 data->owner->so_cred,
372 &data->o_res);
373 }
359put_inode: 374put_inode:
360 iput(inode); 375 iput(inode);
361out: 376out:
@@ -433,23 +448,8 @@ static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *
433 opendata->o_res.delegation_type = delegation; 448 opendata->o_res.delegation_type = delegation;
434 opendata->o_arg.open_flags |= mode; 449 opendata->o_arg.open_flags |= mode;
435 newstate = nfs4_opendata_to_nfs4_state(opendata); 450 newstate = nfs4_opendata_to_nfs4_state(opendata);
436 if (newstate != NULL) { 451 if (newstate != NULL)
437 if (opendata->o_res.delegation_type != 0) {
438 struct nfs_inode *nfsi = NFS_I(newstate->inode);
439 int delegation_flags = 0;
440 if (nfsi->delegation)
441 delegation_flags = nfsi->delegation->flags;
442 if (!(delegation_flags & NFS_DELEGATION_NEED_RECLAIM))
443 nfs_inode_set_delegation(newstate->inode,
444 opendata->owner->so_cred,
445 &opendata->o_res);
446 else
447 nfs_inode_reclaim_delegation(newstate->inode,
448 opendata->owner->so_cred,
449 &opendata->o_res);
450 }
451 nfs4_close_state(&opendata->path, newstate, opendata->o_arg.open_flags); 452 nfs4_close_state(&opendata->path, newstate, opendata->o_arg.open_flags);
452 }
453 if (newstate != state) 453 if (newstate != state)
454 return -ESTALE; 454 return -ESTALE;
455 return 0; 455 return 0;
@@ -1005,8 +1005,6 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, int flags, struct
1005 state = nfs4_opendata_to_nfs4_state(opendata); 1005 state = nfs4_opendata_to_nfs4_state(opendata);
1006 if (state == NULL) 1006 if (state == NULL)
1007 goto err_opendata_put; 1007 goto err_opendata_put;
1008 if (opendata->o_res.delegation_type != 0)
1009 nfs_inode_set_delegation(state->inode, cred, &opendata->o_res);
1010 nfs4_opendata_put(opendata); 1008 nfs4_opendata_put(opendata);
1011 nfs4_put_state_owner(sp); 1009 nfs4_put_state_owner(sp);
1012 up_read(&clp->cl_sem); 1010 up_read(&clp->cl_sem);