]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: rename enode -> bnode
authorSage Weil <sage@redhat.com>
Fri, 6 May 2016 18:41:54 +0000 (14:41 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:38:43 +0000 (11:38 -0400)
We're not refcounting extents anymore; we're storing shared blobs.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index ba914139907db4cf01e9c2455874ea94d06f3c1d..4d160e4d418d5b1f6e107e2aed7f326ec3d110f3 100644 (file)
@@ -249,14 +249,14 @@ static void get_coll_key_range(const coll_t& cid, int bits,
   }
 }
 
-static bool is_enode_key(const string& key)
+static bool is_bnode_key(const string& key)
 {
   if (key.size() == 2 + 8 + 4)
     return true;
   return false;
 }
 
-static void get_enode_key(shard_id_t shard, int64_t pool, uint32_t hash,
+static void get_bnode_key(shard_id_t shard, int64_t pool, uint32_t hash,
                          string *key)
 {
   key->clear();
@@ -265,7 +265,7 @@ static void get_enode_key(shard_id_t shard, int64_t pool, uint32_t hash,
   _key_encode_u32(hobject_t::_reverse_bits(hash), key);
 }
 
-static int get_key_enode(const string& key, shard_id_t *shard,
+static int get_key_bnode(const string& key, shard_id_t *shard,
                         int64_t *pool, uint32_t *hash)
 {
   const char *p = key.c_str();
@@ -436,16 +436,16 @@ static void get_wal_key(uint64_t seq, string *out)
   _key_encode_u64(seq, out);
 }
 
-// Enode
+// Bnode
 
 #undef dout_prefix
-#define dout_prefix *_dout << "bluestore.enode(" << this << ") "
+#define dout_prefix *_dout << "bluestore.bnode(" << this << ") "
 
-void BlueStore::Enode::put()
+void BlueStore::Bnode::put()
 {
   if (--nref == 0) {
-    dout(20) << __func__ << " removing self from set " << enode_set << dendl;
-    enode_set->uset.erase(*this);
+    dout(20) << __func__ << " removing self from set " << bnode_set << dendl;
+    bnode_set->uset.erase(*this);
     delete this;
   }
 }
@@ -626,24 +626,24 @@ BlueStore::Collection::Collection(BlueStore *ns, coll_t c)
     cid(c),
     lock("BlueStore::Collection::lock", true, false),
     exists(true),
-    enode_set(g_conf->bluestore_onode_map_size),
+    bnode_set(g_conf->bluestore_onode_map_size),
     onode_map(g_conf->bluestore_onode_map_size)
 {
 }
 
-BlueStore::EnodeRef BlueStore::Collection::get_enode(
+BlueStore::BnodeRef BlueStore::Collection::get_bnode(
   uint32_t hash
   )
 {
-  Enode dummy(hash, string(), NULL);
-  auto p = enode_set.uset.find(dummy);
-  if (p == enode_set.uset.end()) {
+  Bnode dummy(hash, string(), NULL);
+  auto p = bnode_set.uset.find(dummy);
+  if (p == bnode_set.uset.end()) {
     spg_t pgid;
     if (!cid.is_pg(&pgid))
       pgid = spg_t();  // meta
     string key;
-    get_enode_key(pgid.shard, pgid.pool(), hash, &key);
-    EnodeRef e = new Enode(hash, key, &enode_set);
+    get_bnode_key(pgid.shard, pgid.pool(), hash, &key);
+    BnodeRef e = new Bnode(hash, key, &bnode_set);
     dout(10) << __func__ << " hash " << std::hex << hash << std::dec
             << " created " << e << dendl;
 
@@ -659,7 +659,7 @@ BlueStore::EnodeRef BlueStore::Collection::get_enode(
       dout(10) << __func__ << " hash " <<std::hex << hash << std::dec
               << " missed, new ref_map" << dendl;
     }
-    enode_set.uset.insert(*e);
+    bnode_set.uset.insert(*e);
     return e;
   } else {
     dout(10) << __func__ << " hash " << std::hex << hash << std::dec
@@ -2031,17 +2031,17 @@ int BlueStore::umount()
   return 0;
 }
 
-int BlueStore::_verify_enode_shared(
-  EnodeRef enode,
+int BlueStore::_verify_bnode_shared(
+  BnodeRef bnode,
   map<int64_t,vector<bluestore_pextent_t>>& v,
   interval_set<uint64_t> &used_blocks)
 {
   int errors = 0;
-  dout(10) << __func__ << " hash " << enode->hash << " v " << v << dendl;
-  for (auto& b : enode->blob_map) {
+  dout(10) << __func__ << " hash " << bnode->hash << " v " << v << dendl;
+  for (auto& b : bnode->blob_map) {
     auto pv = v.find(b.first);
     if (pv == v.end()) {
-      derr << " hash " << enode->hash << " blob " << b.first
+      derr << " hash " << bnode->hash << " blob " << b.first
           << " exists in bnode but has no refs" << dendl;
       ++errors;
     }
@@ -2063,7 +2063,7 @@ int BlueStore::_verify_enode_shared(
       span.insert(t);
     }
     if (b.second.ref_map != ref_map) {
-      derr << " hash " << enode->hash << " blob " << b.first
+      derr << " hash " << bnode->hash << " blob " << b.first
           << " ref_map " << b.second.ref_map
           << " != expected " << ref_map << dendl;
       ++errors;
@@ -2073,7 +2073,7 @@ int BlueStore::_verify_enode_shared(
       e.insert(p.offset, p.length);
       i.intersection_of(e, used_blocks);
       if (!i.empty()) {
-       derr << " hash " << enode->hash << " extent(s) " << i
+       derr << " hash " << bnode->hash << " extent(s) " << i
             << " already allocated" << dendl;
        ++errors;
       } else {
@@ -2083,7 +2083,7 @@ int BlueStore::_verify_enode_shared(
     v.erase(b.first);
   }
   for (auto& p : v) {
-    derr << " hash " << enode->hash << " blob " << p.first
+    derr << " hash " << bnode->hash << " blob " << p.first
         << " dne, has extent refs "
         << p.second << dendl;
     ++errors;
@@ -2099,7 +2099,7 @@ int BlueStore::fsck()
   set<uint64_t> used_omap_head;
   interval_set<uint64_t> used_blocks;
   KeyValueDB::Iterator it;
-  EnodeRef enode;
+  BnodeRef bnode;
   map<int64_t,vector<bluestore_pextent_t>> hash_shared;
 
   int r = _open_path();
@@ -2179,10 +2179,10 @@ int BlueStore::fsck()
          ++errors;
          continue; // go for next object
        }
-       if (!enode || enode->hash != o->oid.hobj.get_hash()) {
-         if (enode)
-           errors += _verify_enode_shared(enode, hash_shared, used_blocks);
-         enode = c->get_enode(o->oid.hobj.get_hash());
+       if (!bnode || bnode->hash != o->oid.hobj.get_hash()) {
+         if (bnode)
+           errors += _verify_bnode_shared(bnode, hash_shared, used_blocks);
+         bnode = c->get_bnode(o->oid.hobj.get_hash());
          hash_shared.clear();
        }
        if (o->onode.nid) {
@@ -2339,13 +2339,13 @@ int BlueStore::fsck()
       }
     }
   }
-  if (enode) {
-    errors += _verify_enode_shared(enode, hash_shared, used_blocks);
+  if (bnode) {
+    errors += _verify_bnode_shared(bnode, hash_shared, used_blocks);
     hash_shared.clear();
-    enode.reset();
+    bnode.reset();
   }
 
-  dout(1) << __func__ << " checking for stray enodes and onodes" << dendl;
+  dout(1) << __func__ << " checking for stray bnodes and onodes" << dendl;
   it = db->get_iterator(PREFIX_OBJ);
   if (it) {
     CollectionRef c;
@@ -2355,13 +2355,13 @@ int BlueStore::fsck()
     uint32_t expecting_hash;
     for (it->lower_bound(string()); it->valid(); it->next()) {
       ghobject_t oid;
-      if (is_enode_key(it->key())) {
+      if (is_bnode_key(it->key())) {
        if (expecting_objects) {
-         dout(30) << __func__ << "  had enode but no objects for "
+         dout(30) << __func__ << "  had bnode but no objects for "
                   << std::hex << expecting_hash << std::dec << dendl;
          ++errors;
        }
-       get_key_enode(it->key(), &expecting_shard, &expecting_pool,
+       get_key_bnode(it->key(), &expecting_shard, &expecting_pool,
                      &expecting_hash);
        continue;
       }
@@ -2374,7 +2374,7 @@ int BlueStore::fsck()
       }
       if (expecting_objects) {
        if (oid.hobj.get_bitwise_key_u32() != expecting_hash) {
-         dout(30) << __func__ << "  had enode but no objects for "
+         dout(30) << __func__ << "  had bnode but no objects for "
                   << std::hex << expecting_hash << std::dec << dendl;
          ++errors;
        }
@@ -2400,7 +2400,7 @@ int BlueStore::fsck()
       }
     }
     if (expecting_objects) {
-      dout(30) << __func__ << "  had enode but no objects for "
+      dout(30) << __func__ << "  had bnode but no objects for "
               << std::hex << expecting_hash << std::dec << dendl;
       ++errors;
       expecting_objects = false;
@@ -2727,7 +2727,7 @@ int BlueStore::_do_read(
   uint64_t block_size = bdev->get_block_size();
   int r = 0;
   IOContext ioc(NULL);   // FIXME?
-  EnodeRef enode;
+  BnodeRef bnode;
 
   // generally, don't buffer anything, unless the client explicitly requests
   // it.
@@ -3220,10 +3220,10 @@ int BlueStore::collection_list(
       }
       break;
     }
-    if (is_enode_key(it->key())) {
+    if (is_bnode_key(it->key())) {
       dout(20) << __func__ << " key "
               << pretty_binary_string(it->key())
-              << " (enode, skipping)" << dendl;
+              << " (bnode, skipping)" << dendl;
       it->next();
       continue;
     }
@@ -3731,13 +3731,13 @@ void BlueStore::_txc_release(
 {
   if (shared) {
     vector<bluestore_pextent_t> release;
-    if (!o->enode)
-      o->enode = c->get_enode(o->oid.hobj.get_hash());
-    o->enode->ref_map.put(offset, length, &release);
+    if (!o->bnode)
+      o->bnode = c->get_bnode(o->oid.hobj.get_hash());
+    o->bnode->ref_map.put(offset, length, &release);
     dout(10) << __func__ << " 0x" << std::hex << offset << "~0x" << length
-            << std::dec << " shared: ref_map now " << o->enode->ref_map
+            << std::dec << " shared: ref_map now " << o->bnode->ref_map
             << " releasing " << release << dendl;
-    txc->write_enode(o->enode);
+    txc->write_bnode(o->bnode);
     for (auto& p : release) {
       txc->released.insert(p.offset, p.length);
     }
@@ -3892,18 +3892,18 @@ void BlueStore::_txc_finalize(OpSequencer *osr, TransContext *txc)
     (*p)->flush_txns.insert(txc);
   }
 
-  // finalize enodes
-  for (set<EnodeRef>::iterator p = txc->enodes.begin();
-       p != txc->enodes.end();
+  // finalize bnodes
+  for (set<BnodeRef>::iterator p = txc->bnodes.begin();
+       p != txc->bnodes.end();
        ++p) {
     if ((*p)->ref_map.empty()) {
-      dout(20) << "  enode " << std::hex << (*p)->hash << std::dec
+      dout(20) << "  bnode " << std::hex << (*p)->hash << std::dec
               << " ref_map is empty" << dendl;
       txc->t->rmkey(PREFIX_OBJ, (*p)->key);
     } else {
       bufferlist bl;
       ::encode((*p)->ref_map, bl);
-      dout(20) << "  enode " << std::hex << (*p)->hash << std::dec
+      dout(20) << "  bnode " << std::hex << (*p)->hash << std::dec
               << " ref_map is " << bl.length() << dendl;
       txc->t->set(PREFIX_OBJ, (*p)->key, bl);
     }
@@ -5303,8 +5303,8 @@ int BlueStore::_do_allocate(
   // COW head and/or tail?
   bluestore_wal_op_t *cow_head_op = nullptr;
   bluestore_wal_op_t *cow_tail_op = nullptr;
-  if ((shared_head || shared_tail) && !o->enode)
-    o->enode = c->get_enode(o->oid.hobj.get_hash());
+  if ((shared_head || shared_tail) && !o->bnode)
+    o->bnode = c->get_bnode(o->oid.hobj.get_hash());
   if (shared_head) {
     uint64_t cow_offset = offset;
     uint64_t cow_end = MIN(orig_offset & block_mask,
@@ -5467,7 +5467,7 @@ int BlueStore::_do_allocate(
            if (bp->second.blob >= 0)
              o->onode.blob_map.erase(bp->second.blob);
            else
-             o->enode->blob_map.erase(bp->second.blob);
+             o->bnode->blob_map.erase(bp->second.blob);
          }
          hint = bp->first + bp->second.length;
          o->onode.extent_map.erase(bp++);
@@ -6038,7 +6038,7 @@ int BlueStore::_do_zero(TransContext *txc,
        if (bp->second.blob >= 0)
          o->onode.blob_map.erase(bp->second.blob);
        else
-         o->enode->blob_map.erase(-bp->second.blob);
+         o->bnode->blob_map.erase(-bp->second.blob);
       }
       o->onode.extent_map.erase(bp++);
       continue;
@@ -6144,7 +6144,7 @@ int BlueStore::_do_truncate(
        if (bp->second.blob >= 0)
          o->onode.blob_map.erase(bp->second.blob);
        else
-         o->enode->blob_map.erase(-bp->second.blob);
+         o->bnode->blob_map.erase(-bp->second.blob);
       }
       if (bp != o->onode.extent_map.begin()) {
        o->onode.extent_map.erase(bp--);
@@ -6569,7 +6569,7 @@ int BlueStore::_clone(TransContext *txc,
 
   if (g_conf->bluestore_clone_cow) {
     if (!oldo->onode.extent_map.empty()) {
-      EnodeRef e = c->get_enode(newo->oid.hobj.get_hash());
+      BnodeRef e = c->get_bnode(newo->oid.hobj.get_hash());
       map<int64_t,int64_t> moved_blobs;
       for (auto& p : oldo->onode.extent_map) {
        if (p.second.is_shared()) {
@@ -6592,10 +6592,10 @@ int BlueStore::_clone(TransContext *txc,
        }
       }
       newo->onode.extent_map = oldo->onode.extent_map;
-      newo->enode = e;
+      newo->bnode = e;
       dout(20) << __func__ << " extent_map " << newo->onode.extent_map << dendl;
       dout(20) << __func__ << " blob_map " << e->blob_map << dendl;
-      txc->write_enode(e);
+      txc->write_bnode(e);
       if (!moved_blobs.empty())
        txc->write_onode(oldo);
     }
index e5c86bcb97f7850bf7bf539f56377d4572031c20..e28e103ceaeb485d92338e5541e5f2e64e0acadb 100644 (file)
@@ -65,22 +65,22 @@ public:
   class TransContext;
 
   /// an in-memory extent-map, shared by a group of objects (w/ same hash value)
-  struct EnodeSet;
+  struct BnodeSet;
 
-  struct Enode : public boost::intrusive::unordered_set_base_hook<> {
+  struct Bnode : public boost::intrusive::unordered_set_base_hook<> {
     std::atomic_int nref;        ///< reference count
     uint32_t hash;
     string key;           ///< key under PREFIX_OBJ where we are stored
-    EnodeSet *enode_set;  ///< reference to the containing set
+    BnodeSet *bnode_set;  ///< reference to the containing set
 
     bluestore_extent_ref_map_t ref_map;
     bluestore_blob_map_t blob_map;
 
-    Enode(uint32_t h, const string& k, EnodeSet *s)
+    Bnode(uint32_t h, const string& k, BnodeSet *s)
       : nref(0),
        hash(h),
        key(k),
-       enode_set(s) {}
+       bnode_set(s) {}
 
     void get() {
       ++nref;
@@ -98,35 +98,35 @@ public:
       return blob_map.empty() ? 1 : blob_map.rbegin()->first + 1;
     }
 
-    friend void intrusive_ptr_add_ref(Enode *e) { e->get(); }
-    friend void intrusive_ptr_release(Enode *e) { e->put(); }
+    friend void intrusive_ptr_add_ref(Bnode *e) { e->get(); }
+    friend void intrusive_ptr_release(Bnode *e) { e->put(); }
 
-    friend bool operator==(const Enode &l, const Enode &r) {
+    friend bool operator==(const Bnode &l, const Bnode &r) {
       return l.hash == r.hash;
     }
-    friend std::size_t hash_value(const Enode &e) {
+    friend std::size_t hash_value(const Bnode &e) {
       return e.hash;
     }
   };
-  typedef boost::intrusive_ptr<Enode> EnodeRef;
+  typedef boost::intrusive_ptr<Bnode> BnodeRef;
 
-  /// hash of Enodes, by (object) hash value
-  struct EnodeSet {
-    typedef boost::intrusive::unordered_set<Enode>::bucket_type bucket_type;
-    typedef boost::intrusive::unordered_set<Enode>::bucket_traits bucket_traits;
+  /// hash of Bnodes, by (object) hash value
+  struct BnodeSet {
+    typedef boost::intrusive::unordered_set<Bnode>::bucket_type bucket_type;
+    typedef boost::intrusive::unordered_set<Bnode>::bucket_traits bucket_traits;
 
     unsigned num_buckets;
     vector<bucket_type> buckets;
 
-    boost::intrusive::unordered_set<Enode> uset;
+    boost::intrusive::unordered_set<Bnode> uset;
 
-    explicit EnodeSet(unsigned n)
+    explicit BnodeSet(unsigned n)
       : num_buckets(n),
        buckets(n),
        uset(bucket_traits(buckets.data(), num_buckets)) {
       assert(n > 0);
     }
-    ~EnodeSet() {
+    ~BnodeSet() {
       assert(uset.empty());
     }
   };
@@ -139,7 +139,7 @@ public:
     string key;     ///< key under PREFIX_OBJ where we are stored
     boost::intrusive::list_member_hook<> lru_item;
 
-    EnodeRef enode;  ///< ref to Enode [optional]
+    BnodeRef bnode;  ///< ref to Bnode [optional]
 
     bluestore_onode_t onode;  ///< metadata stored as value in kv store
     bool exists;
@@ -161,8 +161,8 @@ public:
 
     bluestore_blob_t *get_blob_ptr(int64_t id) {
       if (id < 0) {
-       assert(enode);
-       return enode->get_blob_ptr(-id);
+       assert(bnode);
+       return bnode->get_blob_ptr(-id);
       } else {
        return onode.get_blob_ptr(id);
       }
@@ -217,18 +217,18 @@ public:
 
     bool exists;
 
-    EnodeSet enode_set;      ///< open Enodes
+    BnodeSet bnode_set;      ///< open Bnodes
 
     // cache onodes on a per-collection basis to avoid lock
     // contention.
     OnodeHashLRU onode_map;
 
     OnodeRef get_onode(const ghobject_t& oid, bool create);
-    EnodeRef get_enode(uint32_t hash);
+    BnodeRef get_bnode(uint32_t hash);
 
     bluestore_blob_t *get_blob_ptr(OnodeRef& o, int64_t blob) {
-      if (blob < 0 && !o->enode)
-       o->enode = get_enode(o->oid.hobj.get_hash());
+      if (blob < 0 && !o->bnode)
+       o->bnode = get_bnode(o->oid.hobj.get_hash());
       return o->get_blob_ptr(blob);
     }
 
@@ -324,7 +324,7 @@ public:
     uint64_t ops, bytes;
 
     set<OnodeRef> onodes;     ///< these onodes need to be updated/written
-    set<EnodeRef> enodes;     ///< these enodes need to be updated/written
+    set<BnodeRef> bnodes;     ///< these bnodes need to be updated/written
     KeyValueDB::Transaction t; ///< then we will commit this
     Context *oncommit;         ///< signal on commit
     Context *onreadable;         ///< signal on readable
@@ -366,8 +366,8 @@ public:
     void write_onode(OnodeRef &o) {
       onodes.insert(o);
     }
-    void write_enode(EnodeRef &e) {
-      enodes.insert(e);
+    void write_bnode(BnodeRef &e) {
+      bnodes.insert(e);
     }
   };
 
@@ -670,7 +670,7 @@ private:
   int _wal_replay();
 
   // for fsck
-  int _verify_enode_shared(EnodeRef enode,
+  int _verify_bnode_shared(BnodeRef bnode,
                           map<int64_t,vector<bluestore_pextent_t>>& v,
                           interval_set<uint64_t> &used_blocks);