From: Igor Fedotov Date: Thu, 5 Sep 2019 12:18:53 +0000 (+0300) Subject: os/bluestore: do not collect onodes when doing fsck. X-Git-Tag: v14.2.5~17^2~14 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=59b4c683847fa65d85c09c52e1a5b3cd99903b93;p=ceph.git os/bluestore: do not collect onodes when doing fsck. This both saves RAM and cpu cycles making fsck process faster. Signed-off-by: Igor Fedotov (cherry picked from commit 4b23bae6a2412ad752543d2aa5e0f7bf053306d2) Conflicts: src/os/bluestore/BlueStore.cc std::shared_lock vs. RWLock::RLocker mismatch --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 9335507e7f693..542693489122a 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3133,6 +3133,34 @@ BlueStore::BlobRef BlueStore::ExtentMap::split_blob( #undef dout_prefix #define dout_prefix *_dout << "bluestore.onode(" << this << ")." << __func__ << " " +BlueStore::Onode* BlueStore::Onode::decode( + CollectionRef c, + const ghobject_t& oid, + const string& key, + const bufferlist& v) +{ + Onode* on = new Onode(c.get(), oid, key); + on->exists = true; + auto p = v.front().begin_deep(); + on->onode.decode(p); + for (auto& i : on->onode.attrs) { + i.second.reassign_to_mempool(mempool::mempool_bluestore_cache_other); + } + + // initialize extent_map + on->extent_map.decode_spanning_blobs(p); + if (on->onode.extent_map_shards.empty()) { + denc(on->extent_map.inline_bl, p); + on->extent_map.decode_some(on->extent_map.inline_bl); + on->extent_map.inline_bl.reassign_to_mempool( + mempool::mempool_bluestore_cache_other); + } + else { + on->extent_map.init_shards(false, false); + } + return on; +} + void BlueStore::Onode::flush() { if (flushing_count.load()) { @@ -3414,7 +3442,7 @@ BlueStore::OnodeRef BlueStore::Collection::get_onode( if (o) return o; - mempool::bluestore_cache_other::string key; + string key; get_object_key(store->cct, oid, &key); ldout(store->cct, 20) << __func__ << " oid " << oid << " key " @@ -3435,24 +3463,7 @@ BlueStore::OnodeRef BlueStore::Collection::get_onode( } else { // loaded ceph_assert(r >= 0); - on = new Onode(this, oid, key); - on->exists = true; - auto p = v.front().begin_deep(); - on->onode.decode(p); - for (auto& i : on->onode.attrs) { - i.second.reassign_to_mempool(mempool::mempool_bluestore_cache_other); - } - - // initialize extent_map - on->extent_map.decode_spanning_blobs(p); - if (on->onode.extent_map_shards.empty()) { - denc(on->extent_map.inline_bl, p); - on->extent_map.decode_some(on->extent_map.inline_bl); - on->extent_map.inline_bl.reassign_to_mempool( - mempool::mempool_bluestore_cache_other); - } else { - on->extent_map.init_shards(false, false); - } + on = Onode::decode(this, oid, key, v); } o.reset(on); return onode_map.add(oid, o); @@ -7118,8 +7129,8 @@ int BlueStore::_fsck(bool deep, bool repair) dout(10) << __func__ << " " << oid << dendl; store_statfs_t onode_statfs; - RWLock::RLocker l(c->lock); - OnodeRef o = c->get_onode(oid, false); + OnodeRef o; + o.reset(Onode::decode(c, oid, it->key(), it->value())); if (o->onode.nid) { if (o->onode.nid > nid_max) { derr << "fsck error: " << oid << " nid " << o->onode.nid @@ -7468,8 +7479,8 @@ int BlueStore::_fsck(bool deep, bool repair) dout(20) << __func__ << " check misreference for col:" << c->cid << " obj:" << oid << dendl; - RWLock::RLocker l(c->lock); - OnodeRef o = c->get_onode(oid, false); + OnodeRef o; + o.reset(Onode::decode(c, oid, it->key(), it->value())); o->extent_map.fault_range(db, 0, OBJECT_MAX_SIZE); mempool::bluestore_fsck::set blobs; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 08e8a00d6c700..2284b97f01d39 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1063,6 +1063,30 @@ public: exists(false), extent_map(this) { } + Onode(Collection* c, const ghobject_t& o, + const string& k) + : nref(0), + c(c), + oid(o), + key(k), + exists(false), + extent_map(this) { + } + Onode(Collection* c, const ghobject_t& o, + const char* k) + : nref(0), + c(c), + oid(o), + key(k), + exists(false), + extent_map(this) { + } + + static Onode* decode( + CollectionRef c, + const ghobject_t& oid, + const string& key, + const bufferlist& v); void flush(); void get() {