From bfc9d71aa41d6cfc32b60318222b3e65352b0776 Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Tue, 8 Jul 2025 16:32:33 +0100 Subject: [PATCH] btrfs: set EXTENT_NORESERVE before range unlock in btrfs_truncate_block() 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 Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Signed-off-by: David Sterba --- fs/btrfs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d79a95b3760cf..6aa1e66448fa5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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) { -- 2.47.2