]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/db/db_filesnapshot.cc
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / db / db_filesnapshot.cc
index 010f9fbe8ff888edfe9b7967e885449fbab21eaf..ace0befb6d5806b3f80e4542b847895b0bf65e86 100644 (file)
@@ -44,7 +44,7 @@ Status DBImpl::EnableFileDeletions(bool force) {
   // Job id == 0 means that this is not our background process, but rather
   // user thread
   JobContext job_context(0);
-  bool should_purge_files = false;
+  bool file_deletion_enabled = false;
   {
     InstrumentedMutexLock l(&mutex_);
     if (force) {
@@ -54,19 +54,18 @@ Status DBImpl::EnableFileDeletions(bool force) {
       --disable_delete_obsolete_files_;
     }
     if (disable_delete_obsolete_files_ == 0)  {
-      ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled");
-      should_purge_files = true;
+      file_deletion_enabled = true;
       FindObsoleteFiles(&job_context, true);
       bg_cv_.SignalAll();
-    } else {
-      ROCKS_LOG_WARN(
-          immutable_db_options_.info_log,
-          "File Deletions Enable, but not really enabled. Counter: %d",
-          disable_delete_obsolete_files_);
     }
   }
-  if (should_purge_files)  {
+  if (file_deletion_enabled) {
+    ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled");
     PurgeObsoleteFiles(job_context);
+  } else {
+    ROCKS_LOG_WARN(immutable_db_options_.info_log,
+                   "File Deletions Enable, but not really enabled. Counter: %d",
+                   disable_delete_obsolete_files_);
   }
   job_context.Clean();
   LogFlush(immutable_db_options_.info_log);
@@ -87,19 +86,28 @@ Status DBImpl::GetLiveFiles(std::vector<std::string>& ret,
   if (flush_memtable) {
     // flush all dirty data to disk.
     Status status;
-    for (auto cfd : *versions_->GetColumnFamilySet()) {
-      if (cfd->IsDropped()) {
-        continue;
-      }
-      cfd->Ref();
+    if (immutable_db_options_.atomic_flush) {
+      autovector<ColumnFamilyData*> cfds;
+      SelectColumnFamiliesForAtomicFlush(&cfds);
       mutex_.Unlock();
-      status = FlushMemTable(cfd, FlushOptions(), FlushReason::kGetLiveFiles);
-      TEST_SYNC_POINT("DBImpl::GetLiveFiles:1");
-      TEST_SYNC_POINT("DBImpl::GetLiveFiles:2");
+      status = AtomicFlushMemTables(cfds, FlushOptions(),
+                                    FlushReason::kGetLiveFiles);
       mutex_.Lock();
-      cfd->Unref();
-      if (!status.ok()) {
-        break;
+    } else {
+      for (auto cfd : *versions_->GetColumnFamilySet()) {
+        if (cfd->IsDropped()) {
+          continue;
+        }
+        cfd->Ref();
+        mutex_.Unlock();
+        status = FlushMemTable(cfd, FlushOptions(), FlushReason::kGetLiveFiles);
+        TEST_SYNC_POINT("DBImpl::GetLiveFiles:1");
+        TEST_SYNC_POINT("DBImpl::GetLiveFiles:2");
+        mutex_.Lock();
+        cfd->Unref();
+        if (!status.ok()) {
+          break;
+        }
       }
     }
     versions_->GetColumnFamilySet()->FreeDeadColumnFamilies();
@@ -126,7 +134,7 @@ Status DBImpl::GetLiveFiles(std::vector<std::string>& ret,
 
   // create names of the live files. The names are not absolute
   // paths, instead they are relative to dbname_;
-  for (auto live_file : live) {
+  for (const auto& live_file : live) {
     ret.push_back(MakeTableFileName("", live_file.GetNumber()));
   }