Skip to content

Commit

Permalink
afs: Fix lock-wait/callback-break double locking
Browse files Browse the repository at this point in the history
__afs_break_callback() holds vnode->lock around its call of
afs_lock_may_be_available() - which also takes that lock.

Fix this by not taking the lock in __afs_break_callback().

Also, there's no point checking the granted_locks and pending_locks queues;
it's sufficient to check lock_state, so move that check out of
afs_lock_may_be_available() into __afs_break_callback() to replace the
queue checks.

Fixes: e8d6c55 ("AFS: implement file locking")
Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed May 16, 2019
1 parent d9052dd commit c7226e4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
8 changes: 1 addition & 7 deletions fs/afs/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,8 @@ void __afs_break_callback(struct afs_vnode *vnode)
vnode->cb_break++;
afs_clear_permits(vnode);

spin_lock(&vnode->lock);

_debug("break callback");

if (list_empty(&vnode->granted_locks) &&
!list_empty(&vnode->pending_locks))
if (vnode->lock_state == AFS_VNODE_LOCK_WAITING_FOR_CB)
afs_lock_may_be_available(vnode);
spin_unlock(&vnode->lock);
}
}

Expand Down
3 changes: 0 additions & 3 deletions fs/afs/flock.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ void afs_lock_may_be_available(struct afs_vnode *vnode)
{
_enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode);

if (vnode->lock_state != AFS_VNODE_LOCK_WAITING_FOR_CB)
return;

spin_lock(&vnode->lock);
if (vnode->lock_state == AFS_VNODE_LOCK_WAITING_FOR_CB)
afs_next_locker(vnode, 0);
Expand Down

0 comments on commit c7226e4

Please sign in to comment.