From: Sage Weil Date: Tue, 7 Jun 2016 17:24:17 +0000 (-0400) Subject: os/bluestore: move blob_map out of onode_t X-Git-Tag: v11.0.0~151^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e65d2b8692868d6b875d486888c037def0b2273d;p=ceph.git os/bluestore: move blob_map out of onode_t 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d9ee9aef470..686b38e2481 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 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 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 diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index f1d840a653f..de4adc6a96f 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 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(); diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 2dbfec55e27..6ba849520cb 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -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"); diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 080ae1e8b8d..f47e8175360 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -584,7 +584,6 @@ struct bluestore_onode_t { map extent_map; ///< extent refs map overlay_map; ///< overlay data (stored in db) map 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 *deref);