]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: decouple prepare_record() from segment_provider
authorYingxin Cheng <yingxin.cheng@intel.com>
Sun, 7 Aug 2022 13:34:24 +0000 (21:34 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 11 Aug 2022 01:16:58 +0000 (09:16 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/transaction_manager.cc
src/test/crimson/seastore/test_btree_lba_manager.cc
src/test/crimson/seastore/test_seastore_cache.cc

index 107574cb7d1c88242dd45a317704e1893d233dc2..c119260e45efabbf437584e82785c4ddf18e569e 100644 (file)
@@ -1018,7 +1018,8 @@ CachedExtentRef Cache::duplicate_for_write(
 
 record_t Cache::prepare_record(
   Transaction &t,
-  SegmentProvider *cleaner)
+  const journal_seq_t &journal_head,
+  const journal_seq_t &journal_dirty_tail)
 {
   LOG_PREFIX(Cache::prepare_record);
   SUBTRACET(seastore_t, "enter", t);
@@ -1251,15 +1252,16 @@ record_t Cache::prepare_record(
   }
 
   if (is_cleaner_transaction(trans_src)) {
-    assert(cleaner != nullptr);
+    assert(journal_head != JOURNAL_SEQ_NULL);
+    assert(journal_dirty_tail != JOURNAL_SEQ_NULL);
     journal_seq_t dirty_tail;
     auto maybe_dirty_tail = get_oldest_dirty_from();
     if (!maybe_dirty_tail.has_value()) {
-      dirty_tail = cleaner->get_journal_head();
+      dirty_tail = journal_head;
       SUBINFOT(seastore_t, "dirty_tail all trimmed, set to head {}, src={}",
                t, dirty_tail, trans_src);
     } else if (*maybe_dirty_tail == JOURNAL_SEQ_NULL) {
-      dirty_tail = cleaner->get_dirty_tail();
+      dirty_tail = journal_dirty_tail;
       SUBINFOT(seastore_t, "dirty_tail is pending, set to {}, src={}",
                t, dirty_tail, trans_src);
     } else {
@@ -1272,7 +1274,7 @@ record_t Cache::prepare_record(
       // FIXME: the replay point of the allocations requires to be accurate.
       // Setting the alloc_tail to get_journal_head() cannot skip replaying the
       // last unnecessary record.
-      alloc_tail = cleaner->get_journal_head();
+      alloc_tail = journal_head;
       SUBINFOT(seastore_t, "alloc_tail all trimmed, set to head {}, src={}",
                t, alloc_tail, trans_src);
     } else if (*maybe_alloc_tail == JOURNAL_SEQ_NULL) {
index c57a0b8e96c341b88fb4e35ee071221387f50541..126012d78c91c89b2f8edabac36ff432953fadc6 100644 (file)
@@ -699,7 +699,8 @@ public:
    */
   record_t prepare_record(
     Transaction &t, ///< [in, out] current transaction
-    SegmentProvider *cleaner
+    const journal_seq_t &journal_head,
+    const journal_seq_t &journal_dirty_tail
   );
 
   /**
index d97c30a45395154c0a385a9244b92f4c0009544f..52623def9ed368907d4009d8191e0f12a804c921 100644 (file)
@@ -335,7 +335,10 @@ TransactionManager::submit_transaction_direct(
       cache->trim_backref_bufs(*trim_alloc_to);
     }
 
-    auto record = cache->prepare_record(tref, async_cleaner.get());
+    auto record = cache->prepare_record(
+      tref,
+      async_cleaner->get_journal_head(),
+      async_cleaner->get_dirty_tail());
 
     tref.get_handle().maybe_release_collection_lock();
 
index 441f0d1135356093aa58c289679b766bcbf21927..92719d83aa272b9f6bb92b711e2503752305cfba 100644 (file)
@@ -94,7 +94,7 @@ struct btree_test_base :
   virtual void complete_commit(Transaction &t) {}
   seastar::future<> submit_transaction(TransactionRef t)
   {
-    auto record = cache->prepare_record(*t, this);
+    auto record = cache->prepare_record(*t, JOURNAL_SEQ_NULL, JOURNAL_SEQ_NULL);
     return journal->submit_record(std::move(record), t->get_handle()).safe_then(
       [this, t=std::move(t)](auto submit_result) mutable {
        cache->complete_commit(
index b9af8b2ccd91c06254bd46b0aa33a24553328648..1785b551111b0ff8de071426ae3bd330d3361b30 100644 (file)
@@ -30,7 +30,7 @@ struct cache_test_t : public seastar_test_suite_t {
 
   seastar::future<paddr_t> submit_transaction(
     TransactionRef t) {
-    auto record = cache->prepare_record(*t, nullptr);
+    auto record = cache->prepare_record(*t, JOURNAL_SEQ_NULL, JOURNAL_SEQ_NULL);
 
     bufferlist bl;
     for (auto &&block : record.extents) {