aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trondmy@gmail.com>2018-09-05 14:07:15 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-09-14 16:24:27 -0400
commit9f0c5124f4a82503ee5d55c60b0b9c6afc3af68b (patch)
treef6a1bd75871599cc37f9f116fd954b15d26b9c72
parent994b15b983a72e1148a173b61e5b279219bb45ae (diff)
NFS: Don't open code clearing of delegation state
Add a helper for the case when the nfs4 open state has been set to use a delegation stateid, and we want to revert to using the open stateid. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--fs/nfs/nfs4proc.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 094c3c09ff00..481787cac4c2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1637,6 +1637,14 @@ static void nfs_state_set_delegation(struct nfs4_state *state,
1637 write_sequnlock(&state->seqlock); 1637 write_sequnlock(&state->seqlock);
1638} 1638}
1639 1639
1640static void nfs_state_clear_delegation(struct nfs4_state *state)
1641{
1642 write_seqlock(&state->seqlock);
1643 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
1644 clear_bit(NFS_DELEGATED_STATE, &state->flags);
1645 write_sequnlock(&state->seqlock);
1646}
1647
1640static int update_open_stateid(struct nfs4_state *state, 1648static int update_open_stateid(struct nfs4_state *state,
1641 const nfs4_stateid *open_stateid, 1649 const nfs4_stateid *open_stateid,
1642 const nfs4_stateid *delegation, 1650 const nfs4_stateid *delegation,
@@ -2145,10 +2153,7 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx,
2145 if (IS_ERR(opendata)) 2153 if (IS_ERR(opendata))
2146 return PTR_ERR(opendata); 2154 return PTR_ERR(opendata);
2147 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid); 2155 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid);
2148 write_seqlock(&state->seqlock); 2156 nfs_state_clear_delegation(state);
2149 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2150 write_sequnlock(&state->seqlock);
2151 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2152 switch (type & (FMODE_READ|FMODE_WRITE)) { 2157 switch (type & (FMODE_READ|FMODE_WRITE)) {
2153 case FMODE_READ|FMODE_WRITE: 2158 case FMODE_READ|FMODE_WRITE:
2154 case FMODE_WRITE: 2159 case FMODE_WRITE:
@@ -2601,10 +2606,7 @@ static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
2601 const nfs4_stateid *stateid) 2606 const nfs4_stateid *stateid)
2602{ 2607{
2603 nfs_remove_bad_delegation(state->inode, stateid); 2608 nfs_remove_bad_delegation(state->inode, stateid);
2604 write_seqlock(&state->seqlock); 2609 nfs_state_clear_delegation(state);
2605 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2606 write_sequnlock(&state->seqlock);
2607 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2608} 2610}
2609 2611
2610static void nfs40_clear_delegation_stateid(struct nfs4_state *state) 2612static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
@@ -2672,13 +2674,14 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)
2672 delegation = rcu_dereference(NFS_I(state->inode)->delegation); 2674 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
2673 if (delegation == NULL) { 2675 if (delegation == NULL) {
2674 rcu_read_unlock(); 2676 rcu_read_unlock();
2677 nfs_state_clear_delegation(state);
2675 return; 2678 return;
2676 } 2679 }
2677 2680
2678 nfs4_stateid_copy(&stateid, &delegation->stateid); 2681 nfs4_stateid_copy(&stateid, &delegation->stateid);
2679 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { 2682 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) {
2680 rcu_read_unlock(); 2683 rcu_read_unlock();
2681 nfs_finish_clear_delegation_stateid(state, &stateid); 2684 nfs_state_clear_delegation(state);
2682 return; 2685 return;
2683 } 2686 }
2684 2687