]> git.baikalelectronics.ru Git - kernel.git/commitdiff
afs: Fix lock-wait/callback-break double locking
authorDavid Howells <dhowells@redhat.com>
Fri, 10 May 2019 22:03:31 +0000 (23:03 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 16 May 2019 15:25:21 +0000 (16:25 +0100)
__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: 98233ada0b32 ("AFS: implement file locking")
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/callback.c
fs/afs/flock.c

index 128f2dbe256a4eb0f6124294f883b29d8a57e10e..4876079aa6437c8f706d4d2628b8dd62f46a1734 100644 (file)
@@ -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);
        }
 }
 
index 3501ef7ddbb462aeb1e81fac619a86d8a09e70cc..c91cd201013f6c6b633e7e8a1cf5b479b1a4ab0b 100644 (file)
@@ -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);