]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: use a whole large backref buffer in cache instead of several... 46256/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 10 Mar 2022 02:55:38 +0000 (10:55 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Fri, 13 May 2022 04:44:53 +0000 (12:44 +0800)
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/os/seastore/backref/btree_backref_manager.cc
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/transaction_manager.cc

index 18ee1a6a628cbd86a7f7f474a497c4370af90e75..18e289823b974667909fdfecac05f053a09ac0a3 100644 (file)
@@ -213,60 +213,24 @@ BtreeBackrefManager::batch_insert_from_cache(
   DEBUGT("insert up to {}", t, limit);
   return seastar::do_with(
     limit,
-    cache.get_backref_bufs_to_flush().begin(),
     JOURNAL_SEQ_NULL,
-    [this, &t, max](auto &limit, auto &iter, auto &inserted_to) {
-    return trans_intr::repeat(
-      [&iter, this, &limit, &t, max, &inserted_to]()
-      -> batch_insert_iertr::future<seastar::stop_iteration> {
-      if (iter == cache.get_backref_bufs_to_flush().end())
-       return seastar::make_ready_future<seastar::stop_iteration>(
-         seastar::stop_iteration::yes);
-      auto &bbr = *iter;
-      LOG_PREFIX(BtreeBackrefManager::batch_insert_from_cache);
-      DEBUGT("backref buffer starting seq: {}", t, bbr->backrefs.begin()->first);
-      if (bbr->backrefs.begin()->first <= limit) {
-       return batch_insert(
-         t,
-         bbr,
-         limit,
-         max
-       ).si_then([max, &iter, &inserted_to, &t](auto new_inserted_to) {
-         assert(inserted_to == JOURNAL_SEQ_NULL
-           || new_inserted_to >= inserted_to);
-         inserted_to = new_inserted_to;
-         if (t.get_num_fresh_backref() * BACKREF_NODE_SIZE < max) {
-           iter++;
-           return seastar::make_ready_future<seastar::stop_iteration>(
-             seastar::stop_iteration::no);
-         } else {
-           return seastar::make_ready_future<seastar::stop_iteration>(
-             seastar::stop_iteration::yes);
-         }
-       });
-      } else {
-       return seastar::make_ready_future<seastar::stop_iteration>(
-         seastar::stop_iteration::yes);
-      }
-    }).si_then([&inserted_to, this, &iter, &limit, &t, max] {
-      auto &backref_buffer = cache.get_newest_backref_buffer();
-      if (iter == cache.get_backref_bufs_to_flush().end()
-         && backref_buffer) {
-       return batch_insert(
-         t,
-         backref_buffer,
-         limit,
-         max
-       ).si_then([&inserted_to](auto new_inserted_to) {
-         assert(inserted_to == JOURNAL_SEQ_NULL
-           || new_inserted_to >= inserted_to);
-         return seastar::make_ready_future<journal_seq_t>(
-           std::move(new_inserted_to));
-       });
-      }
-      return batch_insert_iertr::make_ready_future<journal_seq_t>(
-       std::move(inserted_to));
-    });
+    [this, &t, max](auto &limit, auto &inserted_to) {
+    auto &backref_buffer = cache.get_backref_buffer();
+    if (backref_buffer) {
+      return batch_insert(
+       t,
+       backref_buffer,
+       limit,
+       max
+      ).si_then([&inserted_to](auto new_inserted_to) {
+       assert(inserted_to == JOURNAL_SEQ_NULL
+         || new_inserted_to >= inserted_to);
+       return seastar::make_ready_future<journal_seq_t>(
+         std::move(new_inserted_to));
+      });
+    }
+    return batch_insert_iertr::make_ready_future<journal_seq_t>(
+      std::move(inserted_to));
   });
 }
 
index 7bf9ba776f77683f96384b977f8cb84f2e59e797..bc89747115b9e2f8672b2591a6b9b2c54fde5a5f 100644 (file)
@@ -1257,8 +1257,6 @@ void Cache::complete_commit(
   SUBTRACET(seastore_t, "final_block_start={}, seq={}",
             t, final_block_start, seq);
 
-  may_roll_backref_buffer(final_block_start);
-
   std::vector<backref_buf_entry_ref> backref_list;
   t.for_each_fresh_block([&](const CachedExtentRef &i) {
     bool is_inline = false;
@@ -1412,7 +1410,6 @@ Cache::close_ertr::future<> Cache::close()
     dirty.erase(i++);
     intrusive_ptr_release(ptr);
   }
-  backref_bufs_to_flush.clear();
   backref_extents.clear();
   backref_buffer.reset();
   assert(stats.dirty_bytes == 0);
@@ -1448,7 +1445,6 @@ Cache::replay_delta(
        journal_seq, alloc_replay_from, delta);
       return replay_delta_ertr::now();
     }
-    may_roll_backref_buffer(journal_seq.offset);
     alloc_delta_t alloc_delta;
     decode(alloc_delta, delta.bl);
     std::vector<backref_buf_entry_ref> backref_list;
index b16bdaff7b9a8ed1fe125ec002e2655037f92f49..ba6999e5f82e14ef75ba0189de022dc9c16a92ca 100644 (file)
@@ -527,7 +527,6 @@ private:
   }
 
   backref_buffer_ref backref_buffer;
-  std::list<backref_buffer_ref> backref_bufs_to_flush;
   // backrefs that needs to be inserted into the backref tree
   backref_buf_entry_t::set_t backref_inserted_set;
   backref_buf_entry_t::set_t backref_remove_set; // backrefs needs to be removed
@@ -629,38 +628,14 @@ public:
     return backref_remove_set;
   }
 
-  backref_buffer_ref& get_newest_backref_buffer() {
+  backref_buffer_ref& get_backref_buffer() {
     return backref_buffer;
   }
 
-  std::list<backref_buffer_ref>& get_backref_bufs_to_flush() {
-    return backref_bufs_to_flush;
-  }
-
   void trim_backref_bufs(const journal_seq_t &trim_to) {
     LOG_PREFIX(Cache::trim_backref_bufs);
     SUBDEBUG(seastore_cache, "trimming to {}", trim_to);
-    auto &backref_bufs = get_backref_bufs_to_flush();
-    for (auto iter = backref_bufs.begin();
-        iter != backref_bufs.end();) {
-      auto &backref_buf = *iter;
-      assert(backref_buf);
-      if (!backref_buf->backrefs.empty()
-         && backref_buf->backrefs.rbegin()->first > trim_to) {
-       auto iter2 = backref_buf->backrefs.upper_bound(trim_to);
-       SUBDEBUG(seastore_cache, "trim backref up to {}", iter2->first);
-       backref_buf->backrefs.erase(
-         backref_buf->backrefs.begin(), iter2);
-       break;
-      } else {
-       if (!backref_buf->backrefs.empty()) {
-         SUBDEBUG(seastore_cache, "trim backref buf {}",
-           backref_buf->backrefs.rbegin()->first);
-       }
-       iter = backref_bufs.erase(iter);
-      }
-    }
-    if (backref_bufs.empty() && backref_buffer) {
+    if (backref_buffer) {
       assert(backref_buffer->backrefs.rbegin()->first >= trim_to);
       auto iter = backref_buffer->backrefs.upper_bound(trim_to);
       SUBDEBUG(seastore_cache, "trim backref buffer up to {}", iter->first);
@@ -911,13 +886,8 @@ public:
   std::optional<journal_seq_t> get_oldest_backref_dirty_from() const {
     LOG_PREFIX(Cache::get_oldest_backref_dirty_from);
     journal_seq_t backref_oldest = JOURNAL_SEQ_NULL;
-    if (backref_bufs_to_flush.empty()) {
-      if (backref_buffer && !backref_buffer->backrefs.empty()) {
-       backref_oldest = backref_buffer->backrefs.begin()->first;
-      }
-    } else {
-      auto &oldest_buf = backref_bufs_to_flush.front();
-      backref_oldest = oldest_buf->backrefs.begin()->first;
+    if (backref_buffer && !backref_buffer->backrefs.empty()) {
+      backref_oldest = backref_buffer->backrefs.begin()->first;
     }
     if (backref_oldest == JOURNAL_SEQ_NULL) {
       SUBDEBUG(seastore_cache, "backref_oldest: null");
@@ -950,31 +920,6 @@ public:
   /// Dump live extents
   void dump_contents();
 
-  void force_roll_backref_buffer() {
-    may_roll_backref_buffer(P_ADDR_NULL, true);
-  }
-  void may_roll_backref_buffer(
-    const paddr_t &final_block_start,
-    bool force_roll = false) {
-    if (force_roll) {
-      if (backref_buffer) {
-       backref_bufs_to_flush.emplace_back(std::move(backref_buffer));
-      }
-      return;
-    }
-    if (backref_buffer && !backref_buffer->backrefs.empty()) {
-      auto &[seq, backref_list] = *backref_buffer->backrefs.rbegin();
-      if (backref_list.empty())
-       return;
-      auto &last_seg_paddr = seq.offset.as_seg_paddr();
-      if (last_seg_paddr.get_segment_id() !=
-         final_block_start.as_seg_paddr().get_segment_id()) {
-       // journal segment rolled
-       backref_bufs_to_flush.emplace_back(std::move(backref_buffer));
-      }
-    }
-  }
-
   struct backref_extent_buf_entry_t {
     backref_extent_buf_entry_t(
       paddr_t paddr,
index 308a76e51cdd59edd796da0bcef0bb6ddde8b672..dcbbe014b94a2b7f4a29e4b9dc0889239e3277f8 100644 (file)
@@ -176,7 +176,6 @@ TransactionManager::mount_ertr::future<> TransactionManager::mount()
          });
       });
   }).safe_then([this] {
-    cache->force_roll_backref_buffer();
     return epm->open();
   }).safe_then([FNAME, this] {
     segment_cleaner->complete_init();