]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: do not collect onodes when doing fsck.
authorIgor Fedotov <ifedotov@suse.com>
Thu, 5 Sep 2019 12:18:53 +0000 (15:18 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Wed, 11 Sep 2019 15:15:28 +0000 (18:15 +0300)
This both saves RAM and cpu cycles making fsck process faster.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 605b5b9bea8d4371b071ad3a499d83d56111c6ae..1bd583e07c891906a42009d7c79c6e393a8225a9 100644 (file)
@@ -3252,6 +3252,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()) {
@@ -3602,7 +3630,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 "
@@ -3626,24 +3654,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);
@@ -7381,8 +7392,8 @@ int BlueStore::_fsck(bool deep, bool repair)
 
       dout(10) << __func__ << "  " << oid << dendl;
       store_statfs_t onode_statfs;
-      std::shared_lock 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
@@ -7799,8 +7810,8 @@ int BlueStore::_fsck(bool deep, bool repair)
        dout(20) << __func__ << " check misreference for col:" << c->cid
                  << " obj:" << oid << dendl;
 
-       std::shared_lock 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<BlobRef> blobs;
 
index 7b2b77a69dd02a51d53cefa94fd31d54248d1ad8..76540a1cdb01365f1fd5f17341c363f66b171479 100644 (file)
@@ -1079,6 +1079,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 dump(Formatter* f) const;