Skip to content

Commit 9f0c512

Browse files
trondmyamschuma-ntap
authored andcommitted
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>
1 parent 994b15b commit 9f0c512

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

fs/nfs/nfs4proc.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,14 @@ static void nfs_state_set_delegation(struct nfs4_state *state,
16371637
write_sequnlock(&state->seqlock);
16381638
}
16391639

1640+
static 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+
16401648
static int update_open_stateid(struct nfs4_state *state,
16411649
const nfs4_stateid *open_stateid,
16421650
const nfs4_stateid *delegation,
@@ -2145,10 +2153,7 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx,
21452153
if (IS_ERR(opendata))
21462154
return PTR_ERR(opendata);
21472155
nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid);
2148-
write_seqlock(&state->seqlock);
2149-
nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2150-
write_sequnlock(&state->seqlock);
2151-
clear_bit(NFS_DELEGATED_STATE, &state->flags);
2156+
nfs_state_clear_delegation(state);
21522157
switch (type & (FMODE_READ|FMODE_WRITE)) {
21532158
case FMODE_READ|FMODE_WRITE:
21542159
case FMODE_WRITE:
@@ -2601,10 +2606,7 @@ static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
26012606
const nfs4_stateid *stateid)
26022607
{
26032608
nfs_remove_bad_delegation(state->inode, stateid);
2604-
write_seqlock(&state->seqlock);
2605-
nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2606-
write_sequnlock(&state->seqlock);
2607-
clear_bit(NFS_DELEGATED_STATE, &state->flags);
2609+
nfs_state_clear_delegation(state);
26082610
}
26092611

26102612
static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
@@ -2672,13 +2674,14 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)
26722674
delegation = rcu_dereference(NFS_I(state->inode)->delegation);
26732675
if (delegation == NULL) {
26742676
rcu_read_unlock();
2677+
nfs_state_clear_delegation(state);
26752678
return;
26762679
}
26772680

26782681
nfs4_stateid_copy(&stateid, &delegation->stateid);
26792682
if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) {
26802683
rcu_read_unlock();
2681-
nfs_finish_clear_delegation_stateid(state, &stateid);
2684+
nfs_state_clear_delegation(state);
26822685
return;
26832686
}
26842687

0 commit comments

Comments
 (0)