]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os: add GC operation to Seastore
authorRonen Friedman <rfriedma@redhat.com>
Thu, 16 Apr 2026 17:55:22 +0000 (17:55 +0000)
committerRonen Friedman <rfriedma@redhat.com>
Tue, 28 Apr 2026 05:09:00 +0000 (05:09 +0000)
Will be used to force immediate GC cycles in Seastore during testing, to
reduce segment pressure and avoid missing-OOL-segments conditions.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/crimson/os/futurized_store.h
src/crimson/os/seastore/extent_placement_manager.cc
src/crimson/os/seastore/extent_placement_manager.h
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h

index 3dccd9509fddba2f25b4a737b552d9036f42cca2..b8e11de515ffc1aae5a6c8d669dfd8305a09bcd5 100644 (file)
@@ -258,6 +258,10 @@ public:
   virtual seastar::future<std::vector<coll_core_t>> list_collections() = 0;
 
   virtual seastar::future<std::string> get_default_device_class() = 0;
+
+  /// Run garbage collection on all shards until space ratios are acceptable.
+  /// Default implementation is a no-op (for stores that don't need GC).
+  virtual seastar::future<> do_gc() { return seastar::now(); }
 protected:
   const core_id_t primary_core;
 };
index 838c9a18b19182d46ff62c9dfb1dc88a199b1d60..bfb0a3232a2eb504e94f80036082f8ddf628caaa 100644 (file)
@@ -698,6 +698,30 @@ ExtentPlacementManager::BackgroundProcess::run_until_halt()
   });
 }
 
+seastar::future<>
+ExtentPlacementManager::BackgroundProcess::run_cleaner_until_done()
+{
+  LOG_PREFIX(BackgroundProcess::run_cleaner_until_done);
+  ceph_assert(state == state_t::HALT);
+  assert(!is_running());
+  INFO("started...");
+  return seastar::do_until(
+    [this] {
+      return !main_cleaner->should_clean_space();
+    },
+    [this] {
+      return main_cleaner->clean_space(
+      ).handle_error(
+        crimson::ct_error::assert_all{
+          "run_cleaner_until_done encountered error in clean_space"
+        }
+      );
+    }
+  ).finally([FNAME] {
+    INFO("finished");
+  });
+}
+
 seastar::future<>
 ExtentPlacementManager::BackgroundProcess::reserve_projected_usage(
     io_usage_t usage)
index 33bc3381879d1ff15d34c27272e1b15c6f56df1c..af823f8c209102dbfc3ffd77c5d740ec9c2f7330 100644 (file)
@@ -594,6 +594,10 @@ public:
     return background_process.run_until_halt();
   }
 
+  seastar::future<> run_cleaner_until_done() {
+    return background_process.run_cleaner_until_done();
+  }
+
   bool get_checksum_needed(paddr_t addr) {
     // checksum offloading only for blocks physically stored in the device
 #ifdef UNIT_TESTS_BUILT
@@ -878,7 +882,8 @@ private:
     }
 
     seastar::future<> run_until_halt();
-    
+    seastar::future<> run_cleaner_until_done();
+
     bool is_no_background() const {
       return !trimmer || !main_cleaner;
     }
index 773d7f7153cd0b7617c1d869c407ff3a8d724938..5096aa818263c374458b8ad5e28619fce0e892b9 100644 (file)
@@ -413,6 +413,31 @@ base_ertr::future<> SeaStore::Shard::umount()
   onode_manager.reset();
 }
 
+seastar::future<> SeaStore::Shard::do_gc()
+{
+  LOG_PREFIX(SeaStore::Shard::do_gc);
+  if (!store_active || !transaction_manager) {
+    co_return;
+  }
+  auto *epm = transaction_manager->get_epm();
+  INFO("stopping background and running cleaner...");
+  co_await epm->stop_background();
+  co_await epm->run_cleaner_until_done();
+  INFO("done");
+}
+
+seastar::future<> SeaStore::do_gc()
+{
+  LOG_PREFIX(SeaStore::do_gc);
+  INFO("...");
+  co_await shard_stores.invoke_on_all([](auto &local_store) {
+    return seastar::do_for_each(local_store.mshard_stores, [](auto& mshard_store) {
+      return mshard_store->do_gc();
+    });
+  });
+  INFO("done");
+}
+
 seastar::future<> SeaStore::write_fsid(uuid_d new_osd_fsid)
 {
   ceph_assert(seastar::this_shard_id() == primary_core);
index 73e98ed8e936c0aa097a7dbc165796f55487bfb1..f49e52709da539ccad7e9b9ae3025caadde6e323 100644 (file)
@@ -190,6 +190,7 @@ public:
   // only exposed to SeaStore
   public:
     base_ertr::future<> umount();
+    seastar::future<> do_gc();
     // init managers and mount transaction_manager
     seastar::future<> mount_managers();
 
@@ -593,6 +594,8 @@ public:
 
   seastar::future<std::string> get_default_device_class() final;
 
+  seastar::future<> do_gc() override;
+
   BackendStore get_backend_store(store_index_t store_index) override {
     assert(!shard_stores.local().mshard_stores.empty());
     if (store_index != NULL_STORE_INDEX) {