diff options
author | David Sterba <dsterba@suse.com> | 2018-08-24 14:45:20 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-04-29 19:02:20 +0200 |
commit | e4e9fd0f326212ee3971418334c255a26c8a2735 (patch) | |
tree | 85adca2f3c207cb4ed06d1c46e8a11eb350fc0b5 | |
parent | 8882679ea50b9ceb8b86cbceb061322a97876534 (diff) | |
download | linux-e4e9fd0f326212ee3971418334c255a26c8a2735.tar.gz linux-e4e9fd0f326212ee3971418334c255a26c8a2735.tar.bz2 linux-e4e9fd0f326212ee3971418334c255a26c8a2735.zip |
btrfs: add assertion helpers for spinning writers
Add helpers for conditional DEBUG build to assert that the extent buffer
spinning_writers constraints are met. 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>
-rw-r--r-- | fs/btrfs/locking.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c index 82b84e4daad1..13ef1decdea6 100644 --- a/fs/btrfs/locking.c +++ b/fs/btrfs/locking.c @@ -14,6 +14,30 @@ static void btrfs_assert_tree_read_locked(struct extent_buffer *eb); +#ifdef CONFIG_BTRFS_DEBUG +static void btrfs_assert_spinning_writers_get(struct extent_buffer *eb) +{ + WARN_ON(atomic_read(&eb->spinning_writers)); + atomic_inc(&eb->spinning_writers); +} + +static void btrfs_assert_spinning_writers_put(struct extent_buffer *eb) +{ + WARN_ON(atomic_read(&eb->spinning_writers) != 1); + atomic_dec(&eb->spinning_writers); +} + +static void btrfs_assert_no_spinning_writers(struct extent_buffer *eb) +{ + WARN_ON(atomic_read(&eb->spinning_writers)); +} + +#else +static void btrfs_assert_spinning_writers_get(struct extent_buffer *eb) { } +static void btrfs_assert_spinning_writers_put(struct extent_buffer *eb) { } +static void btrfs_assert_no_spinning_writers(struct extent_buffer *eb) { } +#endif + void btrfs_set_lock_blocking_read(struct extent_buffer *eb) { /* |