diff options
author | David Sterba <dsterba@suse.com> | 2018-08-24 16:20:02 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-04-29 19:02:21 +0200 |
commit | e3f153886702302482918a3788ba3bb24a37a4aa (patch) | |
tree | e14a716a1f40cfe67d09eacc37018dea15aec259 /fs | |
parent | btrfs: use assertion helpers for extent buffer read lock counters (diff) | |
download | linux-e3f153886702302482918a3788ba3bb24a37a4aa.tar.xz linux-e3f153886702302482918a3788ba3bb24a37a4aa.zip |
btrfs: add assertion helpers for extent buffer write lock counters
The write_locks are a simple counter to track locking balance and used
to assert tree locks. Add helpers to make it conditionally work only in
DEBUG builds. Will be used in followup patches.
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/locking.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c index 1088cf322fdd..1c9bb0620e4b 100644 --- a/fs/btrfs/locking.c +++ b/fs/btrfs/locking.c @@ -56,6 +56,21 @@ static void btrfs_assert_tree_read_locked(struct extent_buffer *eb) BUG_ON(!atomic_read(&eb->read_locks)); } +static void btrfs_assert_tree_write_locks_get(struct extent_buffer *eb) +{ + atomic_inc(&eb->write_locks); +} + +static void btrfs_assert_tree_write_locks_put(struct extent_buffer *eb) +{ + atomic_dec(&eb->write_locks); +} + +void btrfs_assert_tree_locked(struct extent_buffer *eb) +{ + BUG_ON(!atomic_read(&eb->write_locks)); +} + #else static void btrfs_assert_spinning_writers_get(struct extent_buffer *eb) { } static void btrfs_assert_spinning_writers_put(struct extent_buffer *eb) { } @@ -65,6 +80,9 @@ static void btrfs_assert_spinning_readers_get(struct extent_buffer *eb) { } static void btrfs_assert_tree_read_locked(struct extent_buffer *eb) { } static void btrfs_assert_tree_read_locks_get(struct extent_buffer *eb) { } static void btrfs_assert_tree_read_locks_put(struct extent_buffer *eb) { } +void btrfs_assert_tree_locked(struct extent_buffer *eb) { } +static void btrfs_assert_tree_write_locks_get(struct extent_buffer *eb) { } +static void btrfs_assert_tree_write_locks_put(struct extent_buffer *eb) { } #endif void btrfs_set_lock_blocking_read(struct extent_buffer *eb) @@ -320,8 +338,3 @@ void btrfs_tree_unlock(struct extent_buffer *eb) write_unlock(&eb->lock); } } - -void btrfs_assert_tree_locked(struct extent_buffer *eb) -{ - BUG_ON(!atomic_read(&eb->write_locks)); -} |