Skip to content

Commit d51f91d

Browse files
author
Trond Myklebust
committed
NFSv4: Revoke the delegation on success in nfs4_delegreturn_done()
If the delegation was successfully returned, then mark it as revoked. Signed-off-by: Trond Myklebust <[email protected]>
1 parent f2d47b5 commit d51f91d

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

fs/nfs/delegation.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,42 @@ void nfs_remove_bad_delegation(struct inode *inode,
806806
}
807807
EXPORT_SYMBOL_GPL(nfs_remove_bad_delegation);
808808

809+
void nfs_delegation_mark_returned(struct inode *inode,
810+
const nfs4_stateid *stateid)
811+
{
812+
struct nfs_delegation *delegation;
813+
814+
if (!inode)
815+
return;
816+
817+
rcu_read_lock();
818+
delegation = rcu_dereference(NFS_I(inode)->delegation);
819+
if (!delegation)
820+
goto out_rcu_unlock;
821+
822+
spin_lock(&delegation->lock);
823+
if (!nfs4_stateid_match_other(stateid, &delegation->stateid))
824+
goto out_spin_unlock;
825+
if (stateid->seqid) {
826+
/* If delegation->stateid is newer, dont mark as returned */
827+
if (nfs4_stateid_is_newer(&delegation->stateid, stateid))
828+
goto out_clear_returning;
829+
if (delegation->stateid.seqid != stateid->seqid)
830+
delegation->stateid.seqid = stateid->seqid;
831+
}
832+
833+
set_bit(NFS_DELEGATION_REVOKED, &delegation->flags);
834+
835+
out_clear_returning:
836+
clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags);
837+
out_spin_unlock:
838+
spin_unlock(&delegation->lock);
839+
out_rcu_unlock:
840+
rcu_read_unlock();
841+
842+
nfs_inode_find_state_and_recover(inode, stateid);
843+
}
844+
809845
/**
810846
* nfs_expire_unused_delegation_types
811847
* @clp: client to process

fs/nfs/delegation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp);
5353
int nfs_client_return_marked_delegations(struct nfs_client *clp);
5454
int nfs_delegations_present(struct nfs_client *clp);
5555
void nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid);
56+
void nfs_delegation_mark_returned(struct inode *inode, const nfs4_stateid *stateid);
5657

5758
void nfs_delegation_mark_reclaim(struct nfs_client *clp);
5859
void nfs_delegation_reap_unclaimed(struct nfs_client *clp);

fs/nfs/nfs4proc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6214,6 +6214,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
62146214
if (exception.retry)
62156215
goto out_restart;
62166216
}
6217+
nfs_delegation_mark_returned(data->inode, data->args.stateid);
62176218
data->rpc_status = task->tk_status;
62186219
return;
62196220
out_restart:

0 commit comments

Comments
 (0)