Btrfs: save us a read_lock
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 27 Dec 2012 09:01:22 +0000 (09:01 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Wed, 20 Feb 2013 14:37:17 +0000 (09:37 -0500)
This does not change the logic of code, but can save us a read_lock.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/locking.c

index 2a1762c660416c662d32f95060046ba2557ab903..e95df435d8976606730bb04faa3e7ceb2a87917c 100644 (file)
@@ -113,11 +113,10 @@ again:
                read_unlock(&eb->lock);
                return;
        }
-       read_unlock(&eb->lock);
-       wait_event(eb->write_lock_wq, atomic_read(&eb->blocking_writers) == 0);
-       read_lock(&eb->lock);
        if (atomic_read(&eb->blocking_writers)) {
                read_unlock(&eb->lock);
+               wait_event(eb->write_lock_wq,
+                          atomic_read(&eb->blocking_writers) == 0);
                goto again;
        }
        atomic_inc(&eb->read_locks);