]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add ability to disable compaction
authorAdam Kupczyk <akupczyk@redhat.com>
Fri, 26 Jun 2020 16:04:57 +0000 (18:04 +0200)
committerAdam Kupczyk <akupczyk@redhat.com>
Wed, 15 Jul 2020 20:14:52 +0000 (22:14 +0200)
This ability only makes sense as a step that allows to perform fsck before commiting recovered bluefs log.

Fixes: https://tracker.ceph.com/issues/46552
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry-picked from commit 7b01af4d95bfa789b3b3247d016431fdbfd844a4)

Conflicts:
src/os/bluestore/BlueFS.cc

src/common/legacy_config_opts.h
src/common/options.cc
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index cf1ba8c0a5e31df2b3ca3c6b80143e08bede7a04..e19404723afa970a80b291880b1493b1c92be517 100644 (file)
@@ -915,6 +915,7 @@ OPTION(bluefs_allocator, OPT_STR)     // stupid | bitmap
 OPTION(bluefs_preextend_wal_files, OPT_BOOL)  // this *requires* that rocksdb has recycling enabled
 OPTION(bluefs_log_replay_check_allocations, OPT_BOOL)
 OPTION(bluefs_replay_recovery, OPT_BOOL)
+OPTION(bluefs_replay_recovery_disable_compact, OPT_BOOL)
 
 OPTION(bluestore_bluefs, OPT_BOOL)
 OPTION(bluestore_bluefs_env_mirror, OPT_BOOL) // mirror to normal Env for debug
index 87a708c9ba45588361339b16944441d7de9c62f1..af26972e22a2321afac8a8212f8534edcbf99834 100644 (file)
@@ -4029,6 +4029,10 @@ std::vector<Option> get_global_options() {
                          "This options enables heuristics that scans devices for missing data. "
                          "DO NOT ENABLE BY DEFAULT"),
 
+    Option("bluefs_replay_recovery_disable_compact", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
+    .set_default(false)
+    .set_description(""),
+
     Option("bluestore_bluefs", Option::TYPE_BOOL, Option::LEVEL_DEV)
     .set_default(true)
     .set_flag(Option::FLAG_CREATE)
index 1c21d443aa341cdb4b5d1592eb0b6f1528be1ae3..b3dc9360981605f993d45882c9dc418486503c3f 100644 (file)
@@ -2112,11 +2112,13 @@ uint64_t BlueFS::_estimate_log_size()
 
 void BlueFS::compact_log()
 {
-  std::unique_lock l(lock);
-  if (cct->_conf->bluefs_compact_log_sync) {
-     _compact_log_sync();
-  } else {
-    _compact_log_async(l);
+  std::unique_lock<ceph::mutex> l(lock);
+  if (!cct->_conf->bluefs_replay_recovery_disable_compact) {
+    if (cct->_conf->bluefs_compact_log_sync) {
+      _compact_log_sync();
+    } else {
+      _compact_log_async(l);
+    }
   }
 }
 
@@ -3197,7 +3199,7 @@ int BlueFS::_preallocate(FileRef f, uint64_t off, uint64_t len)
 
 void BlueFS::sync_metadata(bool avoid_compact)
 {
-  std::unique_lock l(lock);
+  std::unique_lock<ceph::mutex> l(lock);
   if (log_t.empty() && dirty_files.empty()) {
     dout(10) << __func__ << " - no pending log events" << dendl;
   } else {
@@ -3208,7 +3210,15 @@ void BlueFS::sync_metadata(bool avoid_compact)
     dout(10) << __func__ << " done in " << (ceph_clock_now() - start) << dendl;
   }
 
-  if (!avoid_compact && _should_compact_log()) {
+  if (!avoid_compact) {
+    _maybe_compact_log(l);
+  }
+}
+
+void BlueFS::_maybe_compact_log(std::unique_lock<ceph::mutex>& l)
+{
+  if (!cct->_conf->bluefs_replay_recovery_disable_compact &&
+      _should_compact_log()) {
     if (cct->_conf->bluefs_compact_log_sync) {
       _compact_log_sync();
     } else {
index e8ef684602d6e920c200615ae216ab5492a4f998..9e635bd8bde753a88372f3a94585f9435af134c1 100644 (file)
@@ -365,6 +365,7 @@ private:
                          uint64_t jump_to = 0);
   uint64_t _estimate_log_size();
   bool _should_compact_log();
+  void _maybe_compact_log(std::unique_lock<ceph::mutex>& l);
 
   enum {
     REMOVE_DB = 1,