btrfs: simplify waiting loop in btrfs_tree_lock
[sfrench/cifs-2.6.git] / fs / btrfs / locking.c
index 7f89ca6f1fbc57462a435efb9da60f27af78c47c..82b84e4daad1f336fc8b6de895d445682308f3ef 100644 (file)
@@ -237,16 +237,9 @@ again:
        wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0);
        wait_event(eb->write_lock_wq, atomic_read(&eb->blocking_writers) == 0);
        write_lock(&eb->lock);
        wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0);
        wait_event(eb->write_lock_wq, atomic_read(&eb->blocking_writers) == 0);
        write_lock(&eb->lock);
-       if (atomic_read(&eb->blocking_readers)) {
+       if (atomic_read(&eb->blocking_readers) ||
+           atomic_read(&eb->blocking_writers)) {
                write_unlock(&eb->lock);
                write_unlock(&eb->lock);
-               wait_event(eb->read_lock_wq,
-                          atomic_read(&eb->blocking_readers) == 0);
-               goto again;
-       }
-       if (atomic_read(&eb->blocking_writers)) {
-               write_unlock(&eb->lock);
-               wait_event(eb->write_lock_wq,
-                          atomic_read(&eb->blocking_writers) == 0);
                goto again;
        }
        WARN_ON(atomic_read(&eb->spinning_writers));
                goto again;
        }
        WARN_ON(atomic_read(&eb->spinning_writers));