Skip to content

Commit c7226e4

Browse files
committed
afs: Fix lock-wait/callback-break double locking
__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 <dhowells@redhat.com>
1 parent d9052dd commit c7226e4

2 files changed

Lines changed: 1 addition & 10 deletions

File tree

‎fs/afs/callback.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,8 @@ void __afs_break_callback(struct afs_vnode *vnode)
218218
vnode->cb_break++;
219219
afs_clear_permits(vnode);
220220

221-
spin_lock(&vnode->lock);
222-
223-
_debug("break callback");
224-
225-
if (list_empty(&vnode->granted_locks) &&
226-
!list_empty(&vnode->pending_locks))
221+
if (vnode->lock_state == AFS_VNODE_LOCK_WAITING_FOR_CB)
227222
afs_lock_may_be_available(vnode);
228-
spin_unlock(&vnode->lock);
229223
}
230224
}
231225

‎fs/afs/flock.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ void afs_lock_may_be_available(struct afs_vnode *vnode)
4141
{
4242
_enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode);
4343

44-
if (vnode->lock_state != AFS_VNODE_LOCK_WAITING_FOR_CB)
45-
return;
46-
4744
spin_lock(&vnode->lock);
4845
if (vnode->lock_state == AFS_VNODE_LOCK_WAITING_FOR_CB)
4946
afs_next_locker(vnode, 0);

0 commit comments

Comments
 (0)