]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: compact db after bulk omap naming upgrade. 42426/head
authorIgor Fedotov <ifed@suse.com>
Wed, 7 Jul 2021 13:17:52 +0000 (16:17 +0300)
committerIgor Fedotov <ifed@suse.com>
Tue, 20 Jul 2021 17:04:39 +0000 (20:04 +0300)
Omap naming scheme upgrade introduced recently might perform bulk data
removal and hence leave DB in a "degraded" state. Let's compact it.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 0e5c140b79a0b1809a8044696dce1eb7a36b1d41)

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index d95eb8c19a1275548b04fc7f21e817ce0651d353..a922b9924952c0e2538377836371ff5995fd40fb 100644 (file)
@@ -7856,6 +7856,7 @@ void BlueStore::_fsck_check_object_omap(FSCKDepth depth,
       }
       db->submit_transaction_sync(txn);
       repairer->inc_repaired();
+      repairer->request_compaction();
     }
   }
 }
@@ -16351,6 +16352,10 @@ unsigned BlueStoreRepairer::apply(KeyValueDB* db)
     db->submit_transaction_sync(fix_statfs_txn);
     fix_statfs_txn = nullptr;
   }
+  if (need_compact) {
+    db->compact();
+    need_compact = false;
+  }
   unsigned repaired = to_repair_cnt;
   to_repair_cnt = 0;
   return repaired;
index 9603f7151a6720df9d1644c77f8dad0da32511f8..d30a74bed82548c161d43c0ee90fe31b790f6abd 100644 (file)
@@ -3650,10 +3650,15 @@ public:
       ++to_repair_cnt;
     }
   }
-  // In fact this is the only repairer's method which is thread-safe!!
+  //////////////////////
+  //In fact two methods below are the only ones in this class which are thread-safe!!
   void inc_repaired() {
     ++to_repair_cnt;
   }
+  void request_compaction() {
+    need_compact = true;
+  }
+  //////////////////////
 
   void init_space_usage_tracker(
     uint64_t total_space, uint64_t lres_tracking_unit_size)
@@ -3686,6 +3691,7 @@ public:
 
 private:
   std::atomic<unsigned> to_repair_cnt = { 0 };
+  std::atomic<bool> need_compact = { false };
   KeyValueDB::Transaction fix_per_pool_omap_txn;
   KeyValueDB::Transaction fix_fm_leaked_txn;
   KeyValueDB::Transaction fix_fm_false_free_txn;