From: Filipe Manana Date: Wed, 9 Apr 2025 17:15:03 +0000 (+0100) Subject: btrfs: simplify last record detection at btrfs_clear_extent_bit_changeset() X-Git-Tag: v6.16-rc1~214^2~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2a24bef553891d91d3ae1745b748cdf5cc58145;p=thirdparty%2Flinux.git btrfs: simplify last record detection at btrfs_clear_extent_bit_changeset() Instead of checking for an end offset of (u64)-1 (U64_MAX) for the current extent state's end, and then checking after updating the current start offset if it's now beyond the range's end offset, we can simply stop if the current extent state's end is greater than or equals to our range's end offset. This helps remove one comparison under the 'next' label and allows to remove the if statement that checks if the start offset is greater than the end offset under the 'search_again' label. Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c index 7a5c59b89173d..55334c616d6dc 100644 --- a/fs/btrfs/extent-io-tree.c +++ b/fs/btrfs/extent-io-tree.c @@ -734,15 +734,13 @@ hit_next: state = clear_state_bit(tree, state, bits, wake, changeset); next: - if (last_end == (u64)-1) + if (last_end >= end) goto out; start = last_end + 1; - if (start <= end && state && !need_resched()) + if (state && !need_resched()) goto hit_next; search_again: - if (start > end) - goto out; spin_unlock(&tree->lock); if (gfpflags_allow_blocking(mask)) cond_resched();