]> git.hungrycats.org Git - bees/commit
btrfs-free: fix rlower_bound failing to find items at offset zero
authorZygo Blaxell <bees@furryterror.org>
Mon, 23 Mar 2026 07:43:26 +0000 (03:43 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 2 May 2026 03:48:57 +0000 (23:48 -0400)
commitb0638951ee13f780ca5b06b63c31eb93b9f2ef85
tree3b3886dd3aebc8d4ce8a3e2009117adc97b05858
parentac4516a9e508b0f9a9b5d42bf1e7c0b2cad7f373
btrfs-free: fix rlower_bound failing to find items at offset zero

rlower_bound initialized closest_logical to 0, so a matching item at
offset 0 never passed the `this_logical > closest_logical` check.
Add a `have_closest` flag so the first match is always accepted.

This caused ref_backward to return null when the previous extent was
at offset 0 in the file, which is the common case for the first
extent of any inode.

This has been subtly breaking subvol scans since the extent scan rework
exposed the bug; however, fixing this still doesn't help subvol scans
work at scale, so they're still deprecated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
lib/btrfs-tree.cc