]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: move blob_map out of onode_t
authorSage Weil <sage@redhat.com>
Tue, 7 Jun 2016 17:24:17 +0000 (13:24 -0400)
committerSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 19:58:23 +0000 (15:58 -0400)
Move the blob_map index out of the onode_t proper.  None of the (important)
onode_t methods use the blob_map, which is expected since blobs may exist
in the onode or bnode map.  Instead, move it into Onode, parallel the
Bnode counterpart.

This will allow us to create a blob map that includes the buffer cache
with an encode/decode and lifecycle independent of the onode_t.

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

index d9ee9aef470af1393859d6bd74aefa604cd7f263..686b38e2481fba60f6518ae200a7ee9b1f19ec80 100644 (file)
@@ -2623,7 +2623,7 @@ int BlueStore::fsck()
        // blobs
        errors += _fsck_verify_blob_map(
          "object " + stringify(oid),
-         o->onode.blob_map,
+         o->blob_map,
          local_blobs,
          used_blocks,
          expected_statfs);
@@ -4416,6 +4416,7 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t)
        ++p) {
     bufferlist bl;
     ::encode((*p)->onode, bl);
+    ::encode((*p)->blob_map, bl);
     dout(20) << "  onode " << (*p)->oid << " is " << bl.length() << dendl;
     t->set(PREFIX_OBJ, (*p)->key, bl);
 
@@ -5441,18 +5442,6 @@ void BlueStore::_dump_onode(OnodeRef o, int log_level)
     assert(p.first >= pos);
     pos = p.first + p.second.length;
   }
-  for (auto& b : o->onode.blob_map) {
-    dout(log_level) << __func__ << "  " << b.first << ": " << b.second
-                   << dendl;
-    if (b.second.has_csum_data()) {
-      vector<uint64_t> v;
-      unsigned n = b.second.get_csum_count();
-      for (unsigned i = 0; i < n; ++i)
-       v.push_back(b.second.get_csum_item(i));
-      dout(log_level) << __func__ << "       csum: " << std::hex << v << std::dec
-                     << dendl;
-    }
-  }
   pos = 0;
   for (auto& v : o->onode.overlay_map) {
     dout(log_level) << __func__ << "  overlay 0x" << std::hex << v.first
@@ -5475,6 +5464,18 @@ void BlueStore::_dump_onode(OnodeRef o, int log_level)
                      << dendl;
     }
   }
+  for (auto& b : o->blob_map) {
+    dout(log_level) << __func__ << "  " << b.first << ": " << b.second
+                   << dendl;
+    if (b.second.has_csum_data()) {
+      vector<uint64_t> v;
+      unsigned n = b.second.get_csum_count();
+      for (unsigned i = 0; i < n; ++i)
+       v.push_back(b.second.get_csum_item(i));
+      dout(log_level) << __func__ << "       csum: " << std::hex << v << std::dec
+                     << dendl;
+    }
+  }
   if (o->bnode) {
     _dump_bnode(o->bnode, log_level);
   }
@@ -5748,7 +5749,7 @@ void BlueStore::_do_write_small(
 
   // new blob.
   int64_t blob;
-  b = o->onode.add_blob(&blob);
+  b = o->add_blob(&blob);
   b->length = min_alloc_size;
   uint64_t b_off = offset % min_alloc_size;
   uint64_t b_len = length;
@@ -5788,7 +5789,7 @@ void BlueStore::_do_write_big(
           << std::dec << dendl;
   while (length > 0) {
     int64_t blob;
-    bluestore_blob_t *b = o->onode.add_blob(&blob);
+    bluestore_blob_t *b = o->add_blob(&blob);
     auto l = b->length = MIN(max_blob_len, length);
     bufferlist t;
     blp.copy(l, t);
@@ -5956,7 +5957,7 @@ void BlueStore::_wctx_finish(
       }
       dout(20) << __func__ << " rm blob " << *b << dendl;
       if (l.blob >= 0) {
-       o->onode.blob_map.erase(l.blob);
+       o->blob_map.erase(l.blob);
       } else {
        o->bnode->blob_map.erase(-l.blob);
       }
@@ -6515,9 +6516,9 @@ int BlueStore::_clone(TransContext *txc,
          dout(30) << __func__ << "  moving old onode blob " << p.second.blob
                   << " to bnode blob " << id << dendl;
          bluestore_blob_t& b = e->blob_map[id] =
-           oldo->onode.blob_map[p.second.blob];
+           oldo->blob_map[p.second.blob];
          b.clear_flag(bluestore_blob_t::FLAG_MUTABLE);
-         oldo->onode.blob_map.erase(p.second.blob);
+         oldo->blob_map.erase(p.second.blob);
        }
       }
       // update lextents
index f1d840a653f4232bb90b6dbee6f1a0fe4586a012..de4adc6a96fbc6065bbc8bd7527597aa62ab74bf 100644 (file)
@@ -362,6 +362,8 @@ public:
     bluestore_onode_t onode;  ///< metadata stored as value in kv store
     bool exists;
 
+    bluestore_blob_map_t blob_map;       ///< local blobs (this onode onode)
+
     std::mutex flush_lock;  ///< protect flush_txns
     std::condition_variable flush_cond;   ///< wait here for unapplied txns
     set<TransContext*> flush_txns;   ///< committing or wal txns
@@ -377,13 +379,20 @@ public:
        bc(c) {
     }
 
+    bluestore_blob_t *add_blob(int64_t *id) {
+      *id = blob_map.empty() ? 1 : blob_map.rbegin()->first + 1;
+      return &blob_map[*id];
+    }
+
     bluestore_blob_t *get_blob_ptr(int64_t id) {
       if (id < 0) {
        assert(bnode);
        return bnode->get_blob_ptr(-id);
-      } else {
-       return onode.get_blob_ptr(id);
       }
+      bluestore_blob_map_t::iterator p = blob_map.find(id);
+      if (p == blob_map.end())
+       return nullptr;
+      return &p->second;
     }
 
     void flush();
index 2dbfec55e27c064ff5a4a966e47f9d0ba3d9c50b..6ba849520cb74df905fc3d24abb109fcd7e0336a 100644 (file)
@@ -768,7 +768,6 @@ void bluestore_onode_t::encode(bufferlist& bl) const
   ::encode(nid, bl);
   ::encode(size, bl);
   ::encode(attrs, bl);
-  ::encode(blob_map, bl);
   ::encode(extent_map, bl);
   ::encode(overlay_map, bl);
   ::encode(overlay_refs, bl);
@@ -786,7 +785,6 @@ void bluestore_onode_t::decode(bufferlist::iterator& p)
   ::decode(nid, p);
   ::decode(size, p);
   ::decode(attrs, p);
-  ::decode(blob_map, p);
   ::decode(extent_map, p);
   ::decode(overlay_map, p);
   ::decode(overlay_refs, p);
@@ -811,14 +809,6 @@ void bluestore_onode_t::dump(Formatter *f) const
     f->close_section();
   }
   f->close_section();
-  f->open_object_section("blob_map");
-  for (const auto& p : blob_map) {
-    f->open_object_section("blob");
-    f->dump_unsigned("id", p.first);
-    p.second.dump(f);
-    f->close_section();
-  }
-  f->close_section();
   f->open_object_section("extent_map");
   for (const auto& p : extent_map) {
     f->open_object_section("extent");
index 080ae1e8b8db1904df3b7e84ba994c4170728f59..f47e81753602c50ff7c70a89d27d7647f5cae18c 100644 (file)
@@ -584,7 +584,6 @@ struct bluestore_onode_t {
   map<uint64_t,bluestore_lextent_t> extent_map;  ///< extent refs
   map<uint64_t,bluestore_overlay_t> overlay_map; ///< overlay data (stored in db)
   map<uint64_t,uint16_t> overlay_refs; ///< overlay keys ref counts (if >1)
-  bluestore_blob_map_t blob_map;       ///< local blobs (this onode onode)
   uint32_t last_overlay_key;           ///< key for next overlay
   uint64_t omap_head;                  ///< id for omap root node
 
@@ -650,18 +649,6 @@ struct bluestore_onode_t {
   /// consolidate adjacent lextents in extent_map
   int compress_extent_map();
 
-  bluestore_blob_t *add_blob(int64_t *id) {
-    *id = blob_map.empty() ? 1 : blob_map.rbegin()->first + 1;
-    return &blob_map[*id];
-  }
-
-  bluestore_blob_t *get_blob_ptr(int64_t id) {
-    bluestore_blob_map_t::iterator p = blob_map.find(id);
-    if (p == blob_map.end())
-      return nullptr;
-    return &p->second;
-  }
-
   /// punch a logical hole.  add lextents to deref to target list.
   void punch_hole(uint64_t offset, uint64_t length,
                  vector<bluestore_lextent_t> *deref);