]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/async_cleaner: clarify invariants
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 22 Jul 2022 09:18:52 +0000 (17:18 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 22 Jul 2022 09:32:20 +0000 (17:32 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/async_cleaner.cc
src/crimson/os/seastore/async_cleaner.h

index c564e131ae82c2e12d4e5d106e9730e46bbb343d..938267066c8c3ecc735a9929f37faa7c24e8d76c 100644 (file)
@@ -1034,6 +1034,7 @@ AsyncCleaner::mount_ret AsyncCleaner::mount()
   INFO("{} segment managers", sms.size());
   init_complete = false;
   stats = {};
+  journal_head = JOURNAL_SEQ_NULL;
   journal_alloc_tail = JOURNAL_SEQ_NULL;
   journal_dirty_tail = JOURNAL_SEQ_NULL;
   
@@ -1218,6 +1219,8 @@ void AsyncCleaner::complete_init()
   INFO("done, start GC, time_bound={}",
        sea_time_point_printer_t{segments.get_time_bound()});
   ceph_assert(journal_head != JOURNAL_SEQ_NULL);
+  ceph_assert(journal_alloc_tail != JOURNAL_SEQ_NULL);
+  ceph_assert(journal_dirty_tail != JOURNAL_SEQ_NULL);
   init_complete = true;
   gc_process.start();
 }
index 81b328d41c62c5168e3923d92c2d91c8d763230d..9af774e908c84db950f4d4a8a8ee6f87c13d1c6c 100644 (file)
@@ -1126,14 +1126,11 @@ private:
    * Segments calculations
    */
   std::size_t get_segments_in_journal() const {
-    if (!init_complete) {
-      return 0;
-    }
     auto journal_tail = get_journal_tail();
-    if (journal_tail == JOURNAL_SEQ_NULL) {
-      return segments.get_num_type_journal();
+    if (journal_tail == JOURNAL_SEQ_NULL ||
+        journal_head == JOURNAL_SEQ_NULL) {
+      return 0;
     }
-    assert(journal_head != JOURNAL_SEQ_NULL);
     assert(journal_head.segment_seq >= journal_tail.segment_seq);
     return journal_head.segment_seq + 1 - journal_tail.segment_seq;
   }