btrfs: switch extent_buffer write_locks from atomic to int
authorDavid Sterba <dsterba@suse.com>
Thu, 2 May 2019 14:53:47 +0000 (16:53 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 2 Jul 2019 10:30:47 +0000 (12:30 +0200)
The write_locks is either 0 or 1 and always updated under the lock,
so we don't need the atomic_t semantics.

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

index fef346c63203a54bbc6c21d0167126c0468e7378..464e6b761a9c9fb078080ab0718e98bb501db936 100644 (file)
@@ -4879,7 +4879,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start,
        eb->spinning_writers = 0;
        atomic_set(&eb->spinning_readers, 0);
        atomic_set(&eb->read_locks, 0);
-       atomic_set(&eb->write_locks, 0);
+       eb->write_locks = 0;
 #endif
 
        return eb;
index 5616b96c365de1ef482b6a4844013280bc4e2037..844e595cde5bd881f4dc7389664afab32a241cfc 100644 (file)
@@ -190,7 +190,7 @@ struct extent_buffer {
        int spinning_writers;
        atomic_t spinning_readers;
        atomic_t read_locks;
-       atomic_t write_locks;
+       int write_locks;
        struct list_head leak_list;
 #endif
 };
index 2706676279770d3f5aed49296aefa9e982d32eaf..98fccce4208ca2d22e823253298d605f4545c337 100644 (file)
@@ -58,17 +58,17 @@ static void btrfs_assert_tree_read_locked(struct extent_buffer *eb)
 
 static void btrfs_assert_tree_write_locks_get(struct extent_buffer *eb)
 {
-       atomic_inc(&eb->write_locks);
+       eb->write_locks++;
 }
 
 static void btrfs_assert_tree_write_locks_put(struct extent_buffer *eb)
 {
-       atomic_dec(&eb->write_locks);
+       eb->write_locks--;
 }
 
 void btrfs_assert_tree_locked(struct extent_buffer *eb)
 {
-       BUG_ON(!atomic_read(&eb->write_locks));
+       BUG_ON(!eb->write_locks);
 }
 
 #else
index c5cc435ed39a9cf098219bfa4eda6332cbbab754..9cb50577d9823900307681426c510d75aa5f793c 100644 (file)
@@ -153,7 +153,7 @@ static void print_eb_refs_lock(struct extent_buffer *eb)
 #ifdef CONFIG_BTRFS_DEBUG
        btrfs_info(eb->fs_info,
 "refs %u lock (w:%d r:%d bw:%d br:%d sw:%d sr:%d) lock_owner %u current %u",
-                  atomic_read(&eb->refs), atomic_read(&eb->write_locks),
+                  atomic_read(&eb->refs), eb->write_locks,
                   atomic_read(&eb->read_locks),
                   eb->blocking_writers,
                   atomic_read(&eb->blocking_readers),