From afd495a8264fb25cef49834b5c3559b8aaa612ee Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 24 Aug 2018 15:57:38 +0200 Subject: btrfs: use assertion helpers for spinning readers 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. Reviewed-by: Nikolay Borisov Reviewed-by: Johannes Thumshirn Signed-off-by: David Sterba --- fs/btrfs/locking.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'fs/btrfs/locking.c') diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c index 2dd3ae524aa3..47bcd288977d 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); } @@ -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); } -- cgit v1.2.3-73-gaa49b