From 0611e2ad02b3a6ede4f1e26b792a80261e63a28e Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Mon, 16 Mar 2026 11:38:36 +0000 Subject: [PATCH] btrfs: free cached state outside critical section in wait_extent_bit() There's no need to free the cached extent state record while holding the io tree's spinlock, it's just making the critical section longer than it needs to be. So just do it after unlocking the io tree. Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/extent-io-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c index 0d9437e72bd4..29fcd08b9ca9 100644 --- a/fs/btrfs/extent-io-tree.c +++ b/fs/btrfs/extent-io-tree.c @@ -877,13 +877,13 @@ static void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, } } out: + spin_unlock(&tree->lock); /* This state is no longer useful, clear it and free it up. */ if (cached_state && *cached_state) { state = *cached_state; *cached_state = NULL; btrfs_free_extent_state(state); } - spin_unlock(&tree->lock); } static void cache_state_if_flags(struct extent_state *state,