Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 229241
b: refs/heads/master
c: dda4b22
h: refs/heads/master
i:
  229239: 5002dee
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Jan 6, 2011
1 parent 51a921e commit bfc3000
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 24d292b894273495f9664bb495e575f8cb7e8cac
refs/heads/master: dda4b225623f316335052828c24a16e2da313f8f
41 changes: 20 additions & 21 deletions trunk/fs/nfs/delegation.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,32 +175,39 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation
return inode;
}

static struct nfs_delegation *nfs_detach_delegation_locked(struct nfs_inode *nfsi,
const nfs4_stateid *stateid,
struct nfs_client *clp)
static struct nfs_delegation *
nfs_detach_delegation_locked(struct nfs_inode *nfsi,
struct nfs_client *clp)
{
struct nfs_delegation *delegation =
rcu_dereference_protected(nfsi->delegation,
lockdep_is_held(&clp->cl_lock));

if (delegation == NULL)
goto nomatch;

spin_lock(&delegation->lock);
if (stateid != NULL && memcmp(delegation->stateid.data, stateid->data,
sizeof(delegation->stateid.data)) != 0)
goto nomatch_unlock;
list_del_rcu(&delegation->super_list);
delegation->inode = NULL;
nfsi->delegation_state = 0;
rcu_assign_pointer(nfsi->delegation, NULL);
spin_unlock(&delegation->lock);
return delegation;
nomatch_unlock:
spin_unlock(&delegation->lock);
nomatch:
return NULL;
}

static struct nfs_delegation *nfs_detach_delegation(struct nfs_inode *nfsi,
struct nfs_client *clp)
{
struct nfs_delegation *delegation;

spin_lock(&clp->cl_lock);
delegation = nfs_detach_delegation_locked(nfsi, clp);
spin_unlock(&clp->cl_lock);
return delegation;
}

/*
* Set up a delegation on an inode
*/
Expand Down Expand Up @@ -246,7 +253,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
delegation = NULL;
goto out;
}
freeme = nfs_detach_delegation_locked(nfsi, NULL, clp);
freeme = nfs_detach_delegation_locked(nfsi, clp);
}
list_add_rcu(&delegation->super_list, &clp->cl_delegations);
nfsi->delegation_state = delegation->type;
Expand Down Expand Up @@ -307,9 +314,7 @@ int nfs_client_return_marked_delegations(struct nfs_client *clp)
inode = nfs_delegation_grab_inode(delegation);
if (inode == NULL)
continue;
spin_lock(&clp->cl_lock);
delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL, clp);
spin_unlock(&clp->cl_lock);
delegation = nfs_detach_delegation(NFS_I(inode), clp);
rcu_read_unlock();
if (delegation != NULL) {
filemap_flush(inode->i_mapping);
Expand Down Expand Up @@ -338,9 +343,7 @@ void nfs_inode_return_delegation_noreclaim(struct inode *inode)
struct nfs_delegation *delegation;

if (rcu_access_pointer(nfsi->delegation) != NULL) {
spin_lock(&clp->cl_lock);
delegation = nfs_detach_delegation_locked(nfsi, NULL, clp);
spin_unlock(&clp->cl_lock);
delegation = nfs_detach_delegation(nfsi, clp);
if (delegation != NULL)
nfs_do_return_delegation(inode, delegation, 0);
}
Expand All @@ -354,9 +357,7 @@ int nfs_inode_return_delegation(struct inode *inode)
int err = 0;

if (rcu_access_pointer(nfsi->delegation) != NULL) {
spin_lock(&clp->cl_lock);
delegation = nfs_detach_delegation_locked(nfsi, NULL, clp);
spin_unlock(&clp->cl_lock);
delegation = nfs_detach_delegation(nfsi, clp);
if (delegation != NULL) {
nfs_wb_all(inode);
err = __nfs_inode_return_delegation(inode, delegation, 1);
Expand Down Expand Up @@ -530,9 +531,7 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
inode = nfs_delegation_grab_inode(delegation);
if (inode == NULL)
continue;
spin_lock(&clp->cl_lock);
delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL, clp);
spin_unlock(&clp->cl_lock);
delegation = nfs_detach_delegation(NFS_I(inode), clp);
rcu_read_unlock();
if (delegation != NULL)
nfs_free_delegation(delegation);
Expand Down

0 comments on commit bfc3000

Please sign in to comment.