From: Filipe Manana Date: Wed, 16 Apr 2025 15:18:10 +0000 (+0100) Subject: btrfs: simplify last record detection at btrfs_convert_extent_bit() X-Git-Tag: v6.16-rc1~214^2~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0edc1a5c543c024934e7418aa76d2e8309e0303f;p=thirdparty%2Flinux.git btrfs: simplify last record detection at btrfs_convert_extent_bit() There's no need to compare the current extent state's end offset to (u64)-1 to check if we have the last possible record and to check as as well if after updating the start offset to the end offset of the current record plus one we are still inside the target range. Instead we can simplify and exit if the current extent state ends at or after the target range and then remove the check for the (u64)-1 as well as the check to see if the updated start offset (to last_end + 1) is still inside the target range. 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 1458c33061611..bf2152ff8efa1 100644 --- a/fs/btrfs/extent-io-tree.c +++ b/fs/btrfs/extent-io-tree.c @@ -1371,11 +1371,10 @@ hit_next: set_state_bits(tree, state, bits, NULL); cache_state(state, cached_state); state = clear_state_bit(tree, state, clear_bits, 0, end, NULL); - if (last_end == (u64)-1) + if (last_end >= end) goto out; start = last_end + 1; - if (start < end && state && state->start == start && - !need_resched()) + if (state && state->start == start && !need_resched()) goto hit_next; goto search_again; } @@ -1411,11 +1410,10 @@ hit_next: set_state_bits(tree, state, bits, NULL); cache_state(state, cached_state); state = clear_state_bit(tree, state, clear_bits, 0, end, NULL); - if (last_end == (u64)-1) + if (last_end >= end) goto out; start = last_end + 1; - if (start < end && state && state->start == start && - !need_resched()) + if (state && state->start == start && !need_resched()) goto hit_next; } goto search_again;