btrfs: use assertion helpers for spinning readers
[sfrench/cifs-2.6.git] / fs / btrfs / locking.c
index 2dd3ae524aa31fd9e2bdf0057978fc1ab9265f21..47bcd288977de78bd41697254106704907d90734 100644 (file)
@@ -62,8 +62,7 @@ void btrfs_set_lock_blocking_read(struct extent_buffer *eb)
                return;
        btrfs_assert_tree_read_locked(eb);
        atomic_inc(&eb->blocking_readers);
-       WARN_ON(atomic_read(&eb->spinning_readers) == 0);
-       atomic_dec(&eb->spinning_readers);
+       btrfs_assert_spinning_readers_put(eb);
        read_unlock(&eb->lock);
 }
 
@@ -95,7 +94,7 @@ void btrfs_clear_lock_blocking_read(struct extent_buffer *eb)
                return;
        BUG_ON(atomic_read(&eb->blocking_readers) == 0);
        read_lock(&eb->lock);
-       atomic_inc(&eb->spinning_readers);
+       btrfs_assert_spinning_readers_get(eb);
        /* atomic_dec_and_test implies a barrier */
        if (atomic_dec_and_test(&eb->blocking_readers))
                cond_wake_up_nomb(&eb->read_lock_wq);
@@ -150,7 +149,7 @@ again:
                goto again;
        }
        atomic_inc(&eb->read_locks);
-       atomic_inc(&eb->spinning_readers);
+       btrfs_assert_spinning_readers_get(eb);
 }
 
 /*
@@ -169,7 +168,7 @@ int btrfs_tree_read_lock_atomic(struct extent_buffer *eb)
                return 0;
        }
        atomic_inc(&eb->read_locks);
-       atomic_inc(&eb->spinning_readers);
+       btrfs_assert_spinning_readers_get(eb);
        return 1;
 }
 
@@ -190,7 +189,7 @@ int btrfs_try_tree_read_lock(struct extent_buffer *eb)
                return 0;
        }
        atomic_inc(&eb->read_locks);
-       atomic_inc(&eb->spinning_readers);
+       btrfs_assert_spinning_readers_get(eb);
        return 1;
 }
 
@@ -232,8 +231,7 @@ void btrfs_tree_read_unlock(struct extent_buffer *eb)
                return;
        }
        btrfs_assert_tree_read_locked(eb);
-       WARN_ON(atomic_read(&eb->spinning_readers) == 0);
-       atomic_dec(&eb->spinning_readers);
+       btrfs_assert_spinning_readers_put(eb);
        atomic_dec(&eb->read_locks);
        read_unlock(&eb->lock);
 }