From: Filipe Manana Date: Tue, 8 Jul 2025 15:32:33 +0000 (+0100) Subject: btrfs: set EXTENT_NORESERVE before range unlock in btrfs_truncate_block() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc9d71aa41d6cfc32b60318222b3e65352b0776;p=thirdparty%2Flinux.git 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 --- 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) {