NFSv4: Ensure correct locking when accessing the 'lock_states' list
There are currently 2 places in the state recovery code, where we do not take sufficient precautions before accessing the state->lock_states. In both cases, we should be holding the state->state_lock. Reported-by: Pascal Bouchareine <pascal@gandi.net> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
111d489f0f
commit
4b44b40e04
1 changed files with 4 additions and 0 deletions
|
@ -1156,11 +1156,13 @@ restart:
|
||||||
if (status >= 0) {
|
if (status >= 0) {
|
||||||
status = nfs4_reclaim_locks(state, ops);
|
status = nfs4_reclaim_locks(state, ops);
|
||||||
if (status >= 0) {
|
if (status >= 0) {
|
||||||
|
spin_lock(&state->state_lock);
|
||||||
list_for_each_entry(lock, &state->lock_states, ls_locks) {
|
list_for_each_entry(lock, &state->lock_states, ls_locks) {
|
||||||
if (!(lock->ls_flags & NFS_LOCK_INITIALIZED))
|
if (!(lock->ls_flags & NFS_LOCK_INITIALIZED))
|
||||||
printk("%s: Lock reclaim failed!\n",
|
printk("%s: Lock reclaim failed!\n",
|
||||||
__func__);
|
__func__);
|
||||||
}
|
}
|
||||||
|
spin_unlock(&state->state_lock);
|
||||||
nfs4_put_open_state(state);
|
nfs4_put_open_state(state);
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
@ -1224,10 +1226,12 @@ static void nfs4_clear_open_state(struct nfs4_state *state)
|
||||||
clear_bit(NFS_O_RDONLY_STATE, &state->flags);
|
clear_bit(NFS_O_RDONLY_STATE, &state->flags);
|
||||||
clear_bit(NFS_O_WRONLY_STATE, &state->flags);
|
clear_bit(NFS_O_WRONLY_STATE, &state->flags);
|
||||||
clear_bit(NFS_O_RDWR_STATE, &state->flags);
|
clear_bit(NFS_O_RDWR_STATE, &state->flags);
|
||||||
|
spin_lock(&state->state_lock);
|
||||||
list_for_each_entry(lock, &state->lock_states, ls_locks) {
|
list_for_each_entry(lock, &state->lock_states, ls_locks) {
|
||||||
lock->ls_seqid.flags = 0;
|
lock->ls_seqid.flags = 0;
|
||||||
lock->ls_flags &= ~NFS_LOCK_INITIALIZED;
|
lock->ls_flags &= ~NFS_LOCK_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
spin_unlock(&state->state_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nfs4_reset_seqids(struct nfs_server *server,
|
static void nfs4_reset_seqids(struct nfs_server *server,
|
||||||
|
|
Loading…
Reference in a new issue