]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: add lockdep assertion to remaining delalloc callbacks
authorFilipe Manana <fdmanana@suse.com>
Fri, 9 Feb 2024 12:19:55 +0000 (12:19 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:50 +0000 (16:24 +0100)
The merge and split callbacks for an inode's io tree are supposed to be
called while the io tree's spinlock is being held, so that the given
extent_state records are stable, not modified or freed while the callbacks
are using them. So add lockdep assertions in the callbacks.

Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
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/inode.c

index a0d2051fc8541c077a46e97966b1aee46235ad61..3874edefe9a73459a572c21d2d53791c55e64bd7 100644 (file)
@@ -2300,6 +2300,8 @@ void btrfs_split_delalloc_extent(struct btrfs_inode *inode,
        struct btrfs_fs_info *fs_info = inode->root->fs_info;
        u64 size;
 
+       lockdep_assert_held(&inode->io_tree.lock);
+
        /* not delalloc, ignore it */
        if (!(orig->state & EXTENT_DELALLOC))
                return;
@@ -2338,6 +2340,8 @@ void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state
        u64 new_size, old_size;
        u32 num_extents;
 
+       lockdep_assert_held(&inode->io_tree.lock);
+
        /* not delalloc, ignore it */
        if (!(other->state & EXTENT_DELALLOC))
                return;