]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
btrfs: push extent lock into run_delalloc_nocow
authorJosef Bacik <josef@toxicpanda.com>
Mon, 12 Feb 2024 21:21:19 +0000 (16:21 -0500)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 May 2024 19:31:09 +0000 (21:31 +0200)
run_delalloc_nocow is a bit special as it walks through the file extents
for the inode and determines what it can nocow and what it can't.  This
is the more complicated area for extent locking, so start with this
function.

Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 347de4e3a33144a532c42e8eb5b165e41794ba84..d8037775ab75114be712b1ed4a78c57cb37dcfce 100644 (file)
@@ -1977,6 +1977,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
         */
        ASSERT(!btrfs_is_zoned(fs_info) || btrfs_is_data_reloc_root(root));
 
+       lock_extent(&inode->io_tree, start, end, NULL);
+
        path = btrfs_alloc_path();
        if (!path) {
                ret = -ENOMEM;
@@ -2249,11 +2251,6 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
        const bool zoned = btrfs_is_zoned(inode->root->fs_info);
        int ret;
 
-       /*
-        * We're unlocked by the different fill functions below.
-        */
-       lock_extent(&inode->io_tree, start, end, NULL);
-
        /*
         * The range must cover part of the @locked_page, or a return of 1
         * can confuse the caller.
@@ -2266,6 +2263,11 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
                goto out;
        }
 
+       /*
+        * We're unlocked by the different fill functions below.
+        */
+       lock_extent(&inode->io_tree, start, end, NULL);
+
        if (btrfs_inode_can_compress(inode) &&
            inode_need_compress(inode, start, end) &&
            run_delalloc_compressed(inode, locked_page, start, end, wbc))