]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/file/delete_scheduler.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / file / delete_scheduler.h
index 60948480af9ab7b38031f2e43f295a1af7a47d04..b2d17a73e12dbe524dbec69fb1bfe6db1d1591f7 100644 (file)
@@ -45,6 +45,7 @@ class DeleteScheduler {
   // Set delete rate limit in bytes per second
   void SetRateBytesPerSecond(int64_t bytes_per_sec) {
     rate_bytes_per_sec_.store(bytes_per_sec);
+    MaybeCreateBackgroundThread();
   }
 
   // Mark file as trash directory and schedule it's deletion. If force_bg is
@@ -82,6 +83,11 @@ class DeleteScheduler {
   static Status CleanupDirectory(Env* env, SstFileManagerImpl* sfm,
                                  const std::string& path);
 
+  void SetStatisticsPtr(const std::shared_ptr<Statistics>& stats) {
+    InstrumentedMutexLock l(&mu_);
+    stats_ = stats;
+  }
+
  private:
   Status MarkAsTrash(const std::string& file_path, std::string* path_in_trash);
 
@@ -91,6 +97,8 @@ class DeleteScheduler {
 
   void BackgroundEmptyTrash();
 
+  void MaybeCreateBackgroundThread();
+
   Env* env_;
   FileSystem* fs_;
 
@@ -98,7 +106,7 @@ class DeleteScheduler {
   std::atomic<uint64_t> total_trash_size_;
   // Maximum number of bytes that should be deleted per second
   std::atomic<int64_t> rate_bytes_per_sec_;
-  // Mutex to protect queue_, pending_files_, bg_errors_, closing_
+  // Mutex to protect queue_, pending_files_, bg_errors_, closing_, stats_
   InstrumentedMutex mu_;
 
   struct FileAndDir {
@@ -134,6 +142,7 @@ class DeleteScheduler {
   // immediately
   std::atomic<double> max_trash_db_ratio_;
   static const uint64_t kMicrosInSecond = 1000 * 1000LL;
+  std::shared_ptr<Statistics> stats_;
 };
 
 }  // namespace ROCKSDB_NAMESPACE