]> git.hungrycats.org Git - bees/commitdiff
bees-roots: fix off-by-one objectid in subvol scanner crawl_one_inode
authorZygo Blaxell <bees@furryterror.org>
Sun, 15 Mar 2026 03:21:54 +0000 (23:21 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 2 May 2026 03:48:58 +0000 (23:48 -0400)
peek_front() -> fetch_extents() advances m_state.m_objectid to
found_inode + scale_size before crawl_one_inode() calls get_state_end().
The resulting this_state.m_objectid is one past the actual inode, but
BeesFileCrawl uses it with BtrfsExtentDataFetcher which requires an
exact objectid match.  The net effect: every inode is scanned with the
objectid of the *next* inode, finding nothing.

Fix: derive bfc_state from this_state but override m_objectid with the
actual inode extracted from this_range.fid().ino().  The crawl's own
set_state() call at the end of crawl_one_inode() still uses this_state
(objectid = found_inode + 1), correctly positioning the next search.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
src/bees-roots.cc

index 2bbd16067f6f42db91feb8c3f01742f910c9f86c..b3025d08dd15373a8dc9acec94d565e575510c07 100644 (file)
@@ -200,12 +200,17 @@ BeesScanModeSubvol::crawl_one_inode(const shared_ptr<BeesCrawl>& this_crawl)
                ostringstream oss;
                oss << "crawl_" << subvol << "_" << inode;
                const auto task_title = oss.str();
+               // this_state.m_objectid was advanced to inode+1 by peek_front()->fetch_extents().
+               // Fix: use the actual inode from this_range so BtrfsExtentDataFetcher finds
+               // the correct inode (exact-match search).
+               auto bfc_state = this_state;
+               bfc_state.m_objectid = inode;
                const auto bfc = make_shared<BeesFileCrawl>((BeesFileCrawl) {
                        .m_ctx = m_ctx,
                        .m_crawl = this_crawl,
                        .m_roots = m_roots,
                        .m_hold = this_crawl->hold_state(this_state),
-                       .m_state = this_state,
+                       .m_state = bfc_state,
                        .m_offset = this_range.begin(),
                });
                BEESNOTE("Starting task " << this_range);