]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: add comment for optimization in free_extent_buffer()
authorFilipe Manana <fdmanana@suse.com>
Tue, 19 Aug 2025 01:15:29 +0000 (21:15 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:33 +0000 (16:34 +0200)
[ Upstream commit 2697b6159744e5afae0f7715da9f830ba6f9e45a ]

There's this special atomic compare and exchange logic which serves to
avoid locking the extent buffers refs_lock spinlock and therefore reduce
lock contention, so add a comment to make it more obvious.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad580dfa388f ("btrfs: fix subpage deadlock in try_release_subpage_extent_buffer()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent_io.c

index 8590f8a4a1393f31b37feeb39dc4d3e70a72757b..9cf37693d6091adc748b7e1e9e5f56d1d578659a 100644 (file)
@@ -3493,6 +3493,7 @@ void free_extent_buffer(struct extent_buffer *eb)
                        break;
                }
 
+               /* Optimization to avoid locking eb->refs_lock. */
                if (atomic_try_cmpxchg(&eb->refs, &refs, refs - 1))
                        return;
        }