]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: set EXTENT_NORESERVE before range unlock in btrfs_truncate_block()
authorFilipe Manana <fdmanana@suse.com>
Tue, 8 Jul 2025 15:32:33 +0000 (16:32 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:09:22 +0000 (00:09 +0200)
Set the EXTENT_NORESERVE bit in the io tree before unlocking the range so
that we can use the cached state and speedup the operation, since the
unlock operation releases the cached state.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index d79a95b3760cf74d4989a29a30286e95b0f097ed..6aa1e66448fa5f66c61ca7b77979c47ff28f427c 100644 (file)
@@ -5002,11 +5002,12 @@ again:
                                  block_end + 1 - block_start);
        btrfs_folio_set_dirty(fs_info, folio, block_start,
                              block_end + 1 - block_start);
-       btrfs_unlock_extent(io_tree, block_start, block_end, &cached_state);
 
        if (only_release_metadata)
                btrfs_set_extent_bit(&inode->io_tree, block_start, block_end,
-                                    EXTENT_NORESERVE, NULL);
+                                    EXTENT_NORESERVE, &cached_state);
+
+       btrfs_unlock_extent(io_tree, block_start, block_end, &cached_state);
 
 out_unlock:
        if (ret) {