There are currently a couple races in the seqid replay code: a
retransmission could come while we're still encoding the original reply,
or a new seqid-mutating call could come as we're encoding a replay.
So, extend the state lock over the encoding (both encoding of a replayed
reply and caching of the original encoded reply).
I really hate doing this, and previously added the stateowner
reference-counting code to avoid it (which was insufficient)--but I
don't see a less complicated alternative at the moment.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
if (open->op_stateowner) {
nfs4_get_stateowner(open->op_stateowner);
cstate->replay_owner = open->op_stateowner;
- }
- nfs4_unlock_state();
+ } else
+ nfs4_unlock_state();
return status;
}
be32_to_cpu(status));
if (cstate->replay_owner) {
+ nfs4_unlock_state();
nfs4_put_stateowner(cstate->replay_owner);
cstate->replay_owner = NULL;
}
nfsd4_create_clid_dir(sop->so_client);
out:
- nfs4_unlock_state();
+ if (!cstate->replay_owner)
+ nfs4_unlock_state();
return status;
}
memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t));
status = nfs_ok;
out:
- nfs4_unlock_state();
+ if (!cstate->replay_owner)
+ nfs4_unlock_state();
return status;
}
if (list_empty(&so->so_stateids))
move_to_close_lru(so);
out:
- nfs4_unlock_state();
+ if (!cstate->replay_owner)
+ nfs4_unlock_state();
return status;
}
out:
if (status && lock->lk_is_new && lock_sop)
release_lockowner(lock_sop);
- nfs4_unlock_state();
+ if (!cstate->replay_owner)
+ nfs4_unlock_state();
return status;
}