]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: simplify last record detection at set_extent_bit()
authorFilipe Manana <fdmanana@suse.com>
Wed, 16 Apr 2025 16:05:11 +0000 (17:05 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:52 +0000 (14:30 +0200)
commit8faab454c59efbe13707b74963a4bc9a8a55fb49
tree61136202ca8a2ff59dac55f8d6e93bcd87112b8c
parent41d69d4d78d8b179bf3bcdfc56d28a12b3a608d2
btrfs: simplify last record detection at set_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. Besides the simplification, this also avoids
seaching for the next extent state record (through next_state()) when the
current extent state record ends at the same offset as our target range,
which is pointless and only wastes times iterating through the rb tree.

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