From: Igor Fedotov Date: Wed, 7 Jul 2021 13:17:52 +0000 (+0300) Subject: os/bluestore: compact db after bulk omap naming upgrade. X-Git-Tag: v15.2.14~9^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F42375%2Fhead;p=ceph.git os/bluestore: compact db after bulk omap naming upgrade. 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 (cherry picked from commit 0e5c140b79a0b1809a8044696dce1eb7a36b1d41) --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 2be41f018334..1fd385860d4f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8213,6 +8213,7 @@ void BlueStore::_fsck_check_object_omap(FSCKDepth depth, } db->submit_transaction_sync(txn); repairer->inc_repaired(); + repairer->request_compaction(); } } } @@ -16267,6 +16268,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; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 2c1171d1bf9a..218e59da862b 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -3538,10 +3538,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) @@ -3574,6 +3579,7 @@ public: private: std::atomic to_repair_cnt = { 0 }; + std::atomic need_compact = { false }; KeyValueDB::Transaction fix_per_pool_omap_txn; KeyValueDB::Transaction fix_fm_leaked_txn; KeyValueDB::Transaction fix_fm_false_free_txn;