Use the helpers where open coded. On non-debug builds, the warnings will
not trigger and extent_buffer::spining_readers become unused and can be
moved to the appropriate section, saving a few bytes.

Signed-off-by: David Sterba <[email protected]>
---
 fs/btrfs/extent_io.c |  2 +-
 fs/btrfs/extent_io.h |  2 +-
 fs/btrfs/locking.c   | 12 +++++-------
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 11a95919bb3e..30363cb97625 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4672,7 +4672,6 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 
start,
        atomic_set(&eb->read_locks, 0);
        atomic_set(&eb->blocking_readers, 0);
        atomic_set(&eb->blocking_writers, 0);
-       atomic_set(&eb->spinning_readers, 0);
        eb->lock_nested = 0;
        init_waitqueue_head(&eb->write_lock_wq);
        init_waitqueue_head(&eb->read_lock_wq);
@@ -4692,6 +4691,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 
start,
 
 #ifdef CONFIG_BTRFS_DEBUG
        atomic_set(&eb->spinning_writers, 0);
+       atomic_set(&eb->spinning_readers, 0);
 #endif
 
        return eb;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index c5eb261c1ea9..e49310d2caf4 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -151,7 +151,6 @@ struct extent_buffer {
        atomic_t read_locks;
        atomic_t blocking_writers;
        atomic_t blocking_readers;
-       atomic_t spinning_readers;
        short lock_nested;
        /* >= 0 if eb belongs to a log tree, -1 otherwise */
        short log_index;
@@ -171,6 +170,7 @@ struct extent_buffer {
        struct page *pages[INLINE_EXTENT_BUFFER_PAGES];
 #ifdef CONFIG_BTRFS_DEBUG
        atomic_t spinning_writers;
+       atomic_t spinning_readers;
        struct list_head leak_list;
 #endif
 };
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 2dd3ae524aa3..ce9dc985ce05 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -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);
 }
 
@@ -150,7 +149,7 @@ void btrfs_tree_read_lock(struct extent_buffer *eb)
                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);
 }
-- 
2.20.1

Reply via email to