]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: use cached state when falling back from NOCoW write to CoW write
authorFilipe Manana <fdmanana@suse.com>
Fri, 11 Jul 2025 08:23:09 +0000 (09:23 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:09:22 +0000 (00:09 +0200)
We have a cached extent state record from the previous extent locking so
we can use when setting the EXTENT_NORESERVE in the range, allowing the
operation to be faster if the extent io tree is relatively large.

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 6aa1e66448fa5f66c61ca7b77979c47ff28f427c..6781956197c7015bc4cc59ad9f550153e8fc6c14 100644 (file)
@@ -1754,7 +1754,8 @@ static int fallback_to_cow(struct btrfs_inode *inode,
                spin_unlock(&sinfo->lock);
 
                if (count > 0)
-                       btrfs_clear_extent_bits(io_tree, start, end, EXTENT_NORESERVE);
+                       btrfs_clear_extent_bit(io_tree, start, end, EXTENT_NORESERVE,
+                                              &cached_state);
        }
        btrfs_unlock_extent(io_tree, start, end, &cached_state);