btrfs: use assertion helpers for extent buffer write lock counters
authorDavid Sterba <dsterba@suse.com>
Fri, 24 Aug 2018 14:24:26 +0000 (16:24 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:21 +0000 (19:02 +0200)
Use the helpers where open coded. On non-debug builds, the warnings will
not trigger and extent_buffer::write_locks become unused and can be
moved to the appropriate section, saving a few bytes.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/locking.c

index c189b018ed693e25f6e9d54d65d4d58a9ba6d367..97d32b80060ddda1900b0631d344e760e5d53174 100644 (file)
@@ -4677,7 +4677,6 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start,
        eb->fs_info = fs_info;
        eb->bflags = 0;
        rwlock_init(&eb->lock);
-       atomic_set(&eb->write_locks, 0);
        atomic_set(&eb->blocking_readers, 0);
        atomic_set(&eb->blocking_writers, 0);
        eb->lock_nested = 0;
@@ -4701,6 +4700,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start,
        atomic_set(&eb->spinning_writers, 0);
        atomic_set(&eb->spinning_readers, 0);
        atomic_set(&eb->read_locks, 0);
+       atomic_set(&eb->write_locks, 0);
 #endif
 
        return eb;
index 41c5d0e9dc7567620ee69d4e9c392d6f9460e8dd..43a9530279db57fcb2499e9310258e129d659020 100644 (file)
@@ -160,8 +160,6 @@ struct extent_buffer {
        struct rcu_head rcu_head;
        pid_t lock_owner;
 
-       /* count of read lock holders on the extent buffer */
-       atomic_t write_locks;
        atomic_t blocking_writers;
        atomic_t blocking_readers;
        short lock_nested;
@@ -185,6 +183,7 @@ struct extent_buffer {
        atomic_t spinning_writers;
        atomic_t spinning_readers;
        atomic_t read_locks;
+       atomic_t write_locks;
        struct list_head leak_list;
 #endif
 };
index 1c9bb0620e4b710b3ed416e285d760436064d3d2..3f7b5989e31e21b690fa9f203122e523fcd459a4 100644 (file)
@@ -243,7 +243,7 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
                write_unlock(&eb->lock);
                return 0;
        }
-       atomic_inc(&eb->write_locks);
+       btrfs_assert_tree_write_locks_get(eb);
        btrfs_assert_spinning_writers_get(eb);
        eb->lock_owner = current->pid;
        return 1;
@@ -310,7 +310,7 @@ again:
                goto again;
        }
        btrfs_assert_spinning_writers_get(eb);
-       atomic_inc(&eb->write_locks);
+       btrfs_assert_tree_write_locks_get(eb);
        eb->lock_owner = current->pid;
 }
 
@@ -325,7 +325,7 @@ void btrfs_tree_unlock(struct extent_buffer *eb)
 
        btrfs_assert_tree_locked(eb);
        eb->lock_owner = 0;
-       atomic_dec(&eb->write_locks);
+       btrfs_assert_tree_write_locks_put(eb);
 
        if (blockers) {
                btrfs_assert_no_spinning_writers(eb);