From e9d4aa4586654dffd53af53a21c5687c5dc51aea Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Wed, 18 Jun 2025 22:52:05 -0400 Subject: [PATCH] roots: make the "idle" label useful Apply the "idle" label only when the crawl is finished _and_ its transid_max is up to date. This makes the keyword "idle" better reflect when bees is not only finished crawling, but also scanning the crawled extents in the queue. Signed-off-by: Zygo Blaxell --- src/bees-roots.cc | 16 ++++++++++------ src/bees.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bees-roots.cc b/src/bees-roots.cc index 22753d0..79e549a 100644 --- a/src/bees-roots.cc +++ b/src/bees-roots.cc @@ -1336,7 +1336,7 @@ BeesScanModeExtent::next_transid() string eta_pretty = "-"; const auto &deferred_finished = deferred_map.at(subvol); const bool finished = deferred_finished.second; - if (finished) { + if (finished && m_roots->up_to_date(this_state)) { eta_stamp = "idle"; } else if (time_so_far > 10 && bytenr_offset > 1024 * 1024 * 1024) { const time_t eta_duration = time_so_far / bytenr_norm; @@ -2311,16 +2311,20 @@ BeesCrawl::BeesCrawl(shared_ptr ctx, BeesCrawlState initial_state) } } +bool +BeesRoots::up_to_date(const BeesCrawlState &bcs) +{ + // If we are already at transid_max then we are up to date + return bcs.m_max_transid >= transid_max(); +} + bool BeesCrawl::restart_crawl_unlocked() { const auto roots = m_ctx->roots(); - const auto next_transid = roots->transid_max(); - auto crawl_state = get_state_end(); - // If we are already at transid_max then we are still finished - m_finished = crawl_state.m_max_transid >= next_transid; + m_finished = roots->up_to_date(crawl_state); if (m_finished) { m_deferred = true; @@ -2331,7 +2335,7 @@ BeesCrawl::restart_crawl_unlocked() // Start new crawl crawl_state.m_min_transid = crawl_state.m_max_transid; - crawl_state.m_max_transid = next_transid; + crawl_state.m_max_transid = roots->transid_max(); crawl_state.m_objectid = 0; crawl_state.m_offset = 0; crawl_state.m_started = current_time; diff --git a/src/bees.h b/src/bees.h index 314cbe8..2493e76 100644 --- a/src/bees.h +++ b/src/bees.h @@ -588,8 +588,8 @@ class BeesRoots : public enable_shared_from_this { void current_state_set(const BeesCrawlState &bcs); bool crawl_batch(shared_ptr crawl); void clear_caches(); - shared_ptr insert_root(const BeesCrawlState &bcs); + bool up_to_date(const BeesCrawlState &bcs); friend class BeesCrawl; friend class BeesFdCache;