]> git.hungrycats.org Git - bees/commitdiff
roots: make the "idle" label useful
authorZygo Blaxell <bees@furryterror.org>
Thu, 19 Jun 2025 02:52:05 +0000 (22:52 -0400)
committerZygo Blaxell <bees@furryterror.org>
Thu, 19 Jun 2025 03:06:14 +0000 (23:06 -0400)
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 <bees@furryterror.org>
src/bees-roots.cc
src/bees.h

index 22753d0e698b9cc914621ccde7c5ed2d506aacd6..79e549aae30b17c9519ab958090eebf07ad082ae 100644 (file)
@@ -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<BeesContext> 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;
index 314cbe8e99cd154e59b5ff455ee86fa4b1e47bc4..2493e7675fdd9636cdbefaa0ca9fb6d3edb521f9 100644 (file)
@@ -588,8 +588,8 @@ class BeesRoots : public enable_shared_from_this<BeesRoots> {
        void current_state_set(const BeesCrawlState &bcs);
        bool crawl_batch(shared_ptr<BeesCrawl> crawl);
        void clear_caches();
-
        shared_ptr<BeesCrawl> insert_root(const BeesCrawlState &bcs);
+       bool up_to_date(const BeesCrawlState &bcs);
 
 friend class BeesCrawl;
 friend class BeesFdCache;