]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: simplify last record detection at btrfs_convert_extent_bit()
authorFilipe Manana <fdmanana@suse.com>
Wed, 16 Apr 2025 15:18:10 +0000 (16:18 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:51 +0000 (14:30 +0200)
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 <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-io-tree.c

index 1458c3306161129b4a88c19b2925f95c78c224c9..bf2152ff8efa1b7538b776e858659cc1ab4ef55f 100644 (file)
@@ -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;