]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: free cached state outside critical section in wait_extent_bit()
authorFilipe Manana <fdmanana@suse.com>
Mon, 16 Mar 2026 11:38:36 +0000 (11:38 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:56:04 +0000 (18:56 +0200)
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 <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-io-tree.c

index 0d9437e72bd4f4acb6fa9cdbeb61c20c74f50263..29fcd08b9ca9b64722dc5eedcb8f06da06068f60 100644 (file)
@@ -877,13 +877,13 @@ process_node:
                }
        }
 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,