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

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 6c49db9bfcf1c46a24a4898cb84a7cd2d353c25b..fef346c63203a54bbc6c21d0167126c0468e7378 100644 (file)
@@ -4876,7 +4876,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start,
        BUG_ON(len > MAX_INLINE_EXTENT_BUFFER_SIZE);
 
 #ifdef CONFIG_BTRFS_DEBUG
-       atomic_set(&eb->spinning_writers, 0);
+       eb->spinning_writers = 0;
        atomic_set(&eb->spinning_readers, 0);
        atomic_set(&eb->read_locks, 0);
        atomic_set(&eb->write_locks, 0);
index 201da61dfc21d9ccb117c801a8066e93416b8101..5616b96c365de1ef482b6a4844013280bc4e2037 100644 (file)
@@ -187,7 +187,7 @@ struct extent_buffer {
        wait_queue_head_t read_lock_wq;
        struct page *pages[INLINE_EXTENT_BUFFER_PAGES];
 #ifdef CONFIG_BTRFS_DEBUG
-       atomic_t spinning_writers;
+       int spinning_writers;
        atomic_t spinning_readers;
        atomic_t read_locks;
        atomic_t write_locks;
index 5feb01147e199f18824cb6129d2849e094bbe625..2706676279770d3f5aed49296aefa9e982d32eaf 100644 (file)
 #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);
+       WARN_ON(eb->spinning_writers);
+       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);
+       WARN_ON(eb->spinning_writers != 1);
+       eb->spinning_writers--;
 }
 
 static void btrfs_assert_no_spinning_writers(struct extent_buffer *eb)
 {
-       WARN_ON(atomic_read(&eb->spinning_writers));
+       WARN_ON(eb->spinning_writers);
 }
 
 static void btrfs_assert_spinning_readers_get(struct extent_buffer *eb)
index 7cb4f1fbe0435425a0096ecd54a874b8b6ec0ce4..c5cc435ed39a9cf098219bfa4eda6332cbbab754 100644 (file)
@@ -157,7 +157,7 @@ static void print_eb_refs_lock(struct extent_buffer *eb)
                   atomic_read(&eb->read_locks),
                   eb->blocking_writers,
                   atomic_read(&eb->blocking_readers),
-                  atomic_read(&eb->spinning_writers),
+                  eb->spinning_writers,
                   atomic_read(&eb->spinning_readers),
                   eb->lock_owner, current->pid);
 #endif