From 80d789f1a12e05c876c448fe484169d49eb679ea Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 15 Jun 2016 05:17:21 -0400 Subject: [PATCH 1/6] os/bluestore: extent_t -> pextent_t Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 16 +++++++++------- src/os/bluestore/BlueStore.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index ed4798d9f8ef3..746038b730578 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1892,7 +1892,7 @@ int BlueStore::_reconcile_bluefs_freespace() return 0; } -int BlueStore::_balance_bluefs_freespace(vector *extents, +int BlueStore::_balance_bluefs_freespace(vector *extents, KeyValueDB::Transaction t) { int ret = 0; @@ -1969,16 +1969,18 @@ int BlueStore::_balance_bluefs_freespace(vector *extents, int r = alloc->reserve(gift); assert(r == 0); - bluestore_extent_t e; - r = alloc->allocate(gift, min_alloc_size, 0, &e.offset, &e.length); + uint64_t eoffset; + uint32_t elength; + r = alloc->allocate(gift, min_alloc_size, 0, &eoffset, &elength); if (r < 0) { assert(0 == "allocate failed, wtf"); return r; } - if (e.length < gift) { - alloc->unreserve(gift - e.length); + if (elength < gift) { + alloc->unreserve(gift - elength); } + bluestore_pextent_t e(eoffset, elength); dout(1) << __func__ << " gifting " << e << " to bluefs" << dendl; extents->push_back(e); ret = 1; @@ -2013,7 +2015,7 @@ int BlueStore::_balance_bluefs_freespace(vector *extents, } void BlueStore::_commit_bluefs_freespace( - const vector& bluefs_gift_extents) + const vector& bluefs_gift_extents) { dout(10) << __func__ << dendl; for (auto& p : bluefs_gift_extents) { @@ -4635,7 +4637,7 @@ void BlueStore::_kv_sync_thread() // one final transaction to force a sync KeyValueDB::Transaction t = db->get_transaction(); - vector bluefs_gift_extents; + vector bluefs_gift_extents; if (bluefs) { int r = _balance_bluefs_freespace(&bluefs_gift_extents, t); assert(r >= 0); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 5e67cd7e6a5b7..699ddf8d3192c 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1061,9 +1061,9 @@ class BlueStore : public ObjectStore, int _open_super_meta(); int _reconcile_bluefs_freespace(); - int _balance_bluefs_freespace(vector *extents, + int _balance_bluefs_freespace(vector *extents, KeyValueDB::Transaction t); - void _commit_bluefs_freespace(const vector& extents); + void _commit_bluefs_freespace(const vector& extents); CollectionRef _get_collection(const coll_t& cid); void _queue_reap_collection(CollectionRef& c); From bd6471fdc9bef83a916021aadb37f797b98fedbb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 15 Jun 2016 05:17:30 -0400 Subject: [PATCH 2/6] os/bluestore: drop old bluestore_extent_t Signed-off-by: Sage Weil --- src/os/bluestore/bluestore_types.cc | 33 --------------------- src/os/bluestore/bluestore_types.h | 46 ----------------------------- src/test/encoding/types.h | 1 - 3 files changed, 80 deletions(-) diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 6ba849520cb74..cc0e1a6bd1dca 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -98,39 +98,6 @@ void bluestore_cnode_t::generate_test_instances(list& o) o.push_back(new bluestore_cnode_t(123)); } -// bluestore_extent_t - -string bluestore_extent_t::get_flags_string(unsigned flags) -{ - string s; - if (flags & FLAG_SHARED) { - s = "shared"; - } - return s; -} - -void bluestore_extent_t::dump(Formatter *f) const -{ - f->dump_unsigned("offset", offset); - f->dump_unsigned("length", length); - f->dump_unsigned("flags", flags); -} - -void bluestore_extent_t::generate_test_instances(list& o) -{ - o.push_back(new bluestore_extent_t()); - o.push_back(new bluestore_extent_t(123, 456)); - o.push_back(new bluestore_extent_t(789, 1024, 322)); -} - -ostream& operator<<(ostream& out, const bluestore_extent_t& e) -{ - out << e.offset << "~" << e.length; - if (e.flags) - out << ":" << bluestore_extent_t::get_flags_string(e.flags); - return out; -} - // bluestore_extent_ref_map_t void bluestore_extent_ref_map_t::_check() const diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index f47e81753602c..db6f8661676f2 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -54,52 +54,6 @@ struct bluestore_cnode_t { }; WRITE_CLASS_ENCODER(bluestore_cnode_t) -/// extent: a byte extent back by the block device -struct bluestore_extent_t { - enum { - FLAG_SHARED = 2, ///< extent is shared by another object, and refcounted - }; - static string get_flags_string(unsigned flags); - - uint64_t offset; - uint32_t length; - uint32_t flags; /// or reserved - - bluestore_extent_t(uint64_t o=0, uint32_t l=0, uint32_t f=0) - : offset(o), length(l), flags(f) {} - - uint64_t end() const { - return offset + length; - } - - bool has_flag(unsigned f) const { - return flags & f; - } - void set_flag(unsigned f) { - flags |= f; - } - void clear_flag(unsigned f) { - flags &= ~f; - } - - void encode(bufferlist& bl) const { - ::encode(offset, bl); - ::encode(length, bl); - ::encode(flags, bl); - } - void decode(bufferlist::iterator& p) { - ::decode(offset, p); - ::decode(length, p); - ::decode(flags, p); - } - void dump(Formatter *f) const; - static void generate_test_instances(list& o); -}; -WRITE_CLASS_ENCODER(bluestore_extent_t) - -ostream& operator<<(ostream& out, const bluestore_extent_t& bp); - - /// pextent: physical extent struct bluestore_pextent_t { const static uint64_t INVALID_OFFSET = ~0ull; diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 7a274ad82f112..2594e4ac3f27f 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -119,7 +119,6 @@ TYPE(SequencerPosition) #include "os/bluestore/bluestore_types.h" TYPE(bluestore_cnode_t) TYPE(bluestore_compression_header_t) -TYPE(bluestore_extent_t) TYPE(bluestore_extent_ref_map_t) TYPE(bluestore_overlay_t) TYPE(bluestore_pextent_t) From 82c8793beda5326091d5e0f3634e11cf10103355 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Jun 2016 14:25:24 -0400 Subject: [PATCH 3/6] os/bluestore/bluestore_types: remove flags from lextent_t Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 6 +-- src/os/bluestore/bluestore_types.cc | 33 ++++---------- src/os/bluestore/bluestore_types.h | 21 +-------- src/test/objectstore/test_bluestore_types.cc | 46 ++++++++++---------- 4 files changed, 37 insertions(+), 69 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 746038b730578..20d277622000d 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5659,7 +5659,7 @@ void BlueStore::_do_write_small( dout(20) << __func__ << " lexold 0x" << std::hex << offset << std::dec << ": " << ep->second << dendl; bluestore_lextent_t& lex = o->onode.extent_map[offset] = - bluestore_lextent_t(blob, b_off + head_pad, length, 0); + bluestore_lextent_t(blob, b_off + head_pad, length); b->blob.ref_map.get(lex.offset, lex.length); b->blob.mark_used(lex.offset, lex.length); txc->statfs_delta.stored() += lex.length; @@ -5732,7 +5732,7 @@ void BlueStore::_do_write_small( << " at " << op->extents << dendl; o->onode.punch_hole(offset, length, &wctx->lex_old); bluestore_lextent_t& lex = o->onode.extent_map[offset] = - bluestore_lextent_t(blob, offset - bstart, length, 0); + bluestore_lextent_t(blob, offset - bstart, length); b->blob.ref_map.get(lex.offset, lex.length); b->blob.mark_used(lex.offset, lex.length); txc->statfs_delta.stored() += lex.length; @@ -5792,7 +5792,7 @@ void BlueStore::_do_write_big( b->bc.write(txc->seq, 0, t, wctx->buffered ? 0 : Buffer::FLAG_NOCACHE); wctx->write(b, 0, t); o->onode.punch_hole(offset, l, &wctx->lex_old); - o->onode.extent_map[offset] = bluestore_lextent_t(b->id, 0, l, 0); + o->onode.extent_map[offset] = bluestore_lextent_t(b->id, 0, l); b->blob.ref_map.get(0, l); txc->statfs_delta.stored() += l; dout(20) << __func__ << " lex 0x" << std::hex << offset << std::dec << ": " diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index cc0e1a6bd1dca..26469f962ccc4 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -696,34 +696,24 @@ int bluestore_blob_t::verify_csum(uint64_t b_off, const bufferlist& bl, // bluestore_lextent_t -string bluestore_lextent_t::get_flags_string(unsigned flags) -{ - string s; - return s; -} - void bluestore_lextent_t::dump(Formatter *f) const { f->dump_unsigned("blob", blob); f->dump_unsigned("offset", offset); f->dump_unsigned("length", length); - f->dump_unsigned("flags", flags); } void bluestore_lextent_t::generate_test_instances(list& ls) { ls.push_back(new bluestore_lextent_t); - ls.push_back(new bluestore_lextent_t(23232, 0, 4096, 0)); - ls.push_back(new bluestore_lextent_t(23232, 16384, 8192, 7)); + ls.push_back(new bluestore_lextent_t(23232, 0, 4096)); + ls.push_back(new bluestore_lextent_t(23232, 16384, 8192)); } ostream& operator<<(ostream& out, const bluestore_lextent_t& lb) { - out << "0x" << std::hex << lb.offset << "~" << lb.length << std::dec - << "->" << lb.blob; - if (lb.flags) - out << ":" << bluestore_lextent_t::get_flags_string(lb.flags); - return out; + return out << "0x" << std::hex << lb.offset << "~" << lb.length << std::dec + << "->" << lb.blob; } @@ -866,13 +856,11 @@ void bluestore_onode_t::punch_hole( bluestore_lextent_t( p->second.blob, p->second.offset + front, - length, - p->second.flags)); + length)); extent_map[end] = bluestore_lextent_t( p->second.blob, p->second.offset + front + length, - p->second.length - front - length, - p->second.flags); + p->second.length - front - length); p->second.length = front; break; } else { @@ -883,8 +871,7 @@ void bluestore_onode_t::punch_hole( bluestore_lextent_t( p->second.blob, p->second.offset + keep, - p->second.length - keep, - p->second.flags)); + p->second.length - keep)); p->second.length = keep; ++p; continue; @@ -902,13 +889,11 @@ void bluestore_onode_t::punch_hole( bluestore_lextent_t( p->second.blob, p->second.offset, - p->second.length - keep, - p->second.flags)); + p->second.length - keep)); extent_map[end] = bluestore_lextent_t( p->second.blob, p->second.offset + p->second.length - keep, - keep, - p->second.flags); + keep); extent_map.erase(p++); break; } diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index db6f8661676f2..a4335e2269d37 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -474,21 +474,16 @@ typedef int64_t bluestore_blob_id_t; /// lextent: logical data block back by the extent struct bluestore_lextent_t { - static string get_flags_string(unsigned flags); - bluestore_blob_id_t blob; ///< blob uint32_t offset; ///< relative offset within the blob uint32_t length; ///< length within the blob - uint32_t flags; ///< FLAGS_* bluestore_lextent_t(bluestore_blob_id_t _blob = 0, uint32_t o = 0, - uint32_t l = 0, - uint32_t f = 0) + uint32_t l = 0) : blob(_blob), offset(o), - length(l), - flags(f) {} + length(l) {} uint64_t end() const { return offset + length; @@ -498,27 +493,15 @@ struct bluestore_lextent_t { return blob < 0; } - bool has_flag(unsigned f) const { - return flags & f; - } - void set_flag(unsigned f) { - flags |= f; - } - void clear_flag(unsigned f) { - flags &= ~f; - } - void encode(bufferlist& bl) const { ::encode(blob, bl); ::encode(offset, bl); ::encode(length, bl); - ::encode(flags, bl); } void decode(bufferlist::iterator& p) { ::decode(blob, p); ::decode(offset, p); ::decode(length, p); - ::decode(flags, p); } void dump(Formatter *f) const; static void generate_test_instances(list& o); diff --git a/src/test/objectstore/test_bluestore_types.cc b/src/test/objectstore/test_bluestore_types.cc index 18935280c4d9f..3354d092ae9b9 100644 --- a/src/test/objectstore/test_bluestore_types.cc +++ b/src/test/objectstore/test_bluestore_types.cc @@ -624,7 +624,7 @@ TEST(bluestore_onode_t, find_lextent) ASSERT_EQ(on.extent_map.end(), on.find_lextent(0)); ASSERT_EQ(on.extent_map.end(), on.find_lextent(100)); - on.extent_map[100] = bluestore_lextent_t(1, 0, 100, 0); + on.extent_map[100] = bluestore_lextent_t(1, 0, 100); map::iterator a = on.extent_map.find(100); ASSERT_EQ(on.extent_map.end(), on.find_lextent(0)); ASSERT_EQ(on.extent_map.end(), on.find_lextent(99)); @@ -633,7 +633,7 @@ TEST(bluestore_onode_t, find_lextent) ASSERT_EQ(a, on.find_lextent(199)); ASSERT_EQ(on.extent_map.end(), on.find_lextent(200)); - on.extent_map[200] = bluestore_lextent_t(2, 0, 100, 0); + on.extent_map[200] = bluestore_lextent_t(2, 0, 100); map::iterator b = on.extent_map.find(200); ASSERT_EQ(on.extent_map.end(), on.find_lextent(0)); ASSERT_EQ(on.extent_map.end(), on.find_lextent(99)); @@ -644,7 +644,7 @@ TEST(bluestore_onode_t, find_lextent) ASSERT_EQ(b, on.find_lextent(299)); ASSERT_EQ(on.extent_map.end(), on.find_lextent(300)); - on.extent_map[400] = bluestore_lextent_t(4, 0, 100, 0); + on.extent_map[400] = bluestore_lextent_t(4, 0, 100); map::iterator d = on.extent_map.find(400); ASSERT_EQ(on.extent_map.end(), on.find_lextent(0)); ASSERT_EQ(on.extent_map.end(), on.find_lextent(99)); @@ -666,7 +666,7 @@ TEST(bluestore_onode_t, seek_lextent) ASSERT_EQ(on.extent_map.end(), on.seek_lextent(0)); ASSERT_EQ(on.extent_map.end(), on.seek_lextent(100)); - on.extent_map[100] = bluestore_lextent_t(1, 0, 100, 0); + on.extent_map[100] = bluestore_lextent_t(1, 0, 100); map::iterator a = on.extent_map.find(100); ASSERT_EQ(a, on.seek_lextent(0)); ASSERT_EQ(a, on.seek_lextent(99)); @@ -675,7 +675,7 @@ TEST(bluestore_onode_t, seek_lextent) ASSERT_EQ(a, on.seek_lextent(199)); ASSERT_EQ(on.extent_map.end(), on.seek_lextent(200)); - on.extent_map[200] = bluestore_lextent_t(2, 0, 100, 0); + on.extent_map[200] = bluestore_lextent_t(2, 0, 100); map::iterator b = on.extent_map.find(200); ASSERT_EQ(a, on.seek_lextent(0)); ASSERT_EQ(a, on.seek_lextent(99)); @@ -686,7 +686,7 @@ TEST(bluestore_onode_t, seek_lextent) ASSERT_EQ(b, on.seek_lextent(299)); ASSERT_EQ(on.extent_map.end(), on.seek_lextent(300)); - on.extent_map[400] = bluestore_lextent_t(4, 0, 100, 0); + on.extent_map[400] = bluestore_lextent_t(4, 0, 100); map::iterator d = on.extent_map.find(400); ASSERT_EQ(a, on.seek_lextent(0)); ASSERT_EQ(a, on.seek_lextent(99)); @@ -709,7 +709,7 @@ TEST(bluestore_onode_t, has_any_lextents) ASSERT_FALSE(on.has_any_lextents(0, 1000)); ASSERT_FALSE(on.has_any_lextents(1000, 1000)); - on.extent_map[100] = bluestore_lextent_t(1, 0, 100, 0); + on.extent_map[100] = bluestore_lextent_t(1, 0, 100); ASSERT_FALSE(on.has_any_lextents(0, 50)); ASSERT_FALSE(on.has_any_lextents(0, 100)); ASSERT_FALSE(on.has_any_lextents(50, 50)); @@ -721,7 +721,7 @@ TEST(bluestore_onode_t, has_any_lextents) ASSERT_TRUE(on.has_any_lextents(199, 2)); ASSERT_FALSE(on.has_any_lextents(200, 2)); - on.extent_map[200] = bluestore_lextent_t(2, 0, 100, 0); + on.extent_map[200] = bluestore_lextent_t(2, 0, 100); ASSERT_TRUE(on.has_any_lextents(199, 1)); ASSERT_TRUE(on.has_any_lextents(199, 2)); ASSERT_TRUE(on.has_any_lextents(200, 2)); @@ -729,7 +729,7 @@ TEST(bluestore_onode_t, has_any_lextents) ASSERT_TRUE(on.has_any_lextents(299, 1)); ASSERT_FALSE(on.has_any_lextents(300, 1)); - on.extent_map[400] = bluestore_lextent_t(4, 0, 100, 0); + on.extent_map[400] = bluestore_lextent_t(4, 0, 100); ASSERT_TRUE(on.has_any_lextents(0, 10000)); ASSERT_TRUE(on.has_any_lextents(199, 1)); ASSERT_FALSE(on.has_any_lextents(300, 1)); @@ -746,30 +746,30 @@ TEST(bluestore_onode_t, compress_extent_map) { bluestore_onode_t on; vector r; - on.extent_map[0] = bluestore_lextent_t(1, 0, 100, 0); - on.extent_map[100] = bluestore_lextent_t(2, 0, 100, 0); + on.extent_map[0] = bluestore_lextent_t(1, 0, 100); + on.extent_map[100] = bluestore_lextent_t(2, 0, 100); ASSERT_EQ(0, on.compress_extent_map()); ASSERT_EQ(2u, on.extent_map.size()); - on.extent_map[200] = bluestore_lextent_t(2, 100, 100, 0); - on.extent_map[300] = bluestore_lextent_t(2, 200, 100, 0); + on.extent_map[200] = bluestore_lextent_t(2, 100, 100); + on.extent_map[300] = bluestore_lextent_t(2, 200, 100); ASSERT_EQ(2, on.compress_extent_map()); ASSERT_EQ(2u, on.extent_map.size()); - on.extent_map[200] = bluestore_lextent_t(3, 100, 100, 0); - on.extent_map[300] = bluestore_lextent_t(2, 200, 100, 0); + on.extent_map[200] = bluestore_lextent_t(3, 100, 100); + on.extent_map[300] = bluestore_lextent_t(2, 200, 100); ASSERT_EQ(0, on.compress_extent_map()); ASSERT_EQ(4u, on.extent_map.size()); - on.extent_map[400] = bluestore_lextent_t(2, 300, 100, 0); - on.extent_map[500] = bluestore_lextent_t(2, 500, 100, 0); - on.extent_map[600] = bluestore_lextent_t(2, 600, 100, 0); + on.extent_map[400] = bluestore_lextent_t(2, 300, 100); + on.extent_map[500] = bluestore_lextent_t(2, 500, 100); + on.extent_map[600] = bluestore_lextent_t(2, 600, 100); ASSERT_EQ(2, on.compress_extent_map()); ASSERT_EQ(5u, on.extent_map.size()); - on.extent_map[400] = bluestore_lextent_t(2, 300, 100, 0); - on.extent_map[500] = bluestore_lextent_t(2, 400, 100, 0); - on.extent_map[700] = bluestore_lextent_t(2, 500, 100, 0); + on.extent_map[400] = bluestore_lextent_t(2, 300, 100); + on.extent_map[500] = bluestore_lextent_t(2, 400, 100); + on.extent_map[700] = bluestore_lextent_t(2, 500, 100); ASSERT_EQ(1, on.compress_extent_map()); ASSERT_EQ(6u, on.extent_map.size()); } @@ -778,8 +778,8 @@ TEST(bluestore_onode_t, punch_hole) { bluestore_onode_t on; vector r; - on.extent_map[0] = bluestore_lextent_t(1, 0, 100, 0); - on.extent_map[100] = bluestore_lextent_t(2, 0, 100, 0); + on.extent_map[0] = bluestore_lextent_t(1, 0, 100); + on.extent_map[100] = bluestore_lextent_t(2, 0, 100); on.punch_hole(0, 100, &r); ASSERT_EQ(1u, on.extent_map.size()); From be61cc921ac2b85388465c6020352d70a22a9a72 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Jun 2016 14:33:30 -0400 Subject: [PATCH 4/6] os/bluestore: drop overlay support We can resurrect this from the history if/when we decide we want it. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 253 ---------------------------------- src/os/bluestore/BlueStore.h | 13 -- 2 files changed, 266 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 20d277622000d..59116f8aa2943 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -37,7 +37,6 @@ const string PREFIX_SUPER = "S"; // field -> value const string PREFIX_STAT = "T"; // field -> value(int64 array) const string PREFIX_COLL = "C"; // collection name -> cnode_t const string PREFIX_OBJ = "O"; // object name -> onode_t -const string PREFIX_OVERLAY = "V"; // u64 + offset -> data const string PREFIX_OMAP = "M"; // u64 + keyname -> value const string PREFIX_WAL = "L"; // id -> wal_transaction_t const string PREFIX_ALLOC = "B"; // u64 offset -> u64 length (freelist) @@ -393,12 +392,6 @@ static int get_key_object(const string& key, ghobject_t *oid) } -static void get_overlay_key(uint64_t nid, uint64_t offset, string *out) -{ - _key_encode_u64(nid, out); - _key_encode_u64(offset, out); -} - // '-' < '.' < '~' static void get_omap_header(uint64_t id, string *out) { @@ -2659,82 +2652,6 @@ int BlueStore::fsck() local_blobs, used_blocks, expected_statfs); - // overlays - set overlay_keys; - map refs; - for (auto& v : o->onode.overlay_map) { - if (v.first + v.second.length > o->onode.size) { - derr << " " << oid << " overlay " << v.first << " " << v.second - << " extends past end of object" << dendl; - ++errors; - continue; // go for next overlay - } - if (v.second.key > o->onode.last_overlay_key) { - derr << " " << oid << " overlay " << v.first << " " << v.second - << " is > last_overlay_key " << o->onode.last_overlay_key - << dendl; - ++errors; - continue; // go for next overlay - } - ++refs[v.second.key]; - string key; - bufferlist val; - get_overlay_key(o->onode.nid, v.second.key, &key); - if (overlay_keys.count(key)) { - derr << " " << oid << " dup overlay key " << key << dendl; - ++errors; - } - overlay_keys.insert(key); - int r = db->get(PREFIX_OVERLAY, key, &val); - if (r < 0) { - derr << " " << oid << " overlay " << v.first << " " << v.second - << " failed to fetch: " << cpp_strerror(r) << dendl; - ++errors; - continue; - } - if (val.length() < v.second.value_offset + v.second.length) { - derr << " " << oid << " overlay " << v.first << " " << v.second - << " too short, " << val.length() << dendl; - ++errors; - } - } - for (auto& vr : o->onode.overlay_refs) { - if (refs[vr.first] != vr.second) { - derr << " " << oid << " overlay key " << vr.first - << " says " << vr.second << " refs but we have " - << refs[vr.first] << dendl; - ++errors; - } - refs.erase(vr.first); - } - for (auto& p : refs) { - if (p.second > 1) { - derr << " " << oid << " overlay key " << p.first - << " has " << p.second << " refs but they are not recorded" - << dendl; - ++errors; - } - } - do { - string start; - get_overlay_key(o->onode.nid, 0, &start); - KeyValueDB::Iterator it = db->get_iterator(PREFIX_OVERLAY); - if (!it) - break; - for (it->lower_bound(start); it->valid(); it->next()) { - string k = it->key(); - const char *p = k.c_str(); - uint64_t nid; - p = _key_decode_u64(p, &nid); - if (nid != o->onode.nid) - break; - if (!overlay_keys.count(k)) { - derr << " " << oid << " has stray overlay kv pair for " - << k << dendl; - ++errors; - } - } - } while (false); // omap while (o->onode.omap_head) { if (used_omap_head.count(o->onode.omap_head)) { @@ -2857,21 +2774,6 @@ int BlueStore::fsck() } } - dout(1) << __func__ << " checking for stray overlay data" << dendl; - it = db->get_iterator(PREFIX_OVERLAY); - if (it) { - for (it->lower_bound(string()); it->valid(); it->next()) { - string key = it->key(); - const char *p = key.c_str(); - uint64_t nid; - p = _key_decode_u64(p, &nid); - if (used_nids.count(nid) == 0) { - derr << __func__ << " found stray overlay data on nid " << nid << dendl; - ++errors; - } - } - } - dout(1) << __func__ << " checking for stray omap data" << dendl; it = db->get_iterator(PREFIX_OMAP); if (it) { @@ -4661,14 +4563,6 @@ void BlueStore::_kv_sync_thread() bluestore_wal_transaction_t& wt =*(*it)->wal_txn; // kv metadata updates _txc_finalize_kv(*it, t); - // cleanup the data in overlays - for (auto& p : wt.ops) { - for (auto q : p.removed_overlays) { - string key; - get_overlay_key(p.nid, q, &key); - t->rm_single_key(PREFIX_OVERLAY, key); - } - } // cleanup the wal string key; get_wal_key(wt.seq, &key); @@ -4770,9 +4664,6 @@ int BlueStore::_wal_finish(TransContext *txc) int BlueStore::_do_wal_op(TransContext *txc, bluestore_wal_op_t& wo) { - // read all the overlay data first for apply - _do_read_all_overlays(wo); - switch (wo.op) { case bluestore_wal_op_t::OP_WRITE: { @@ -5292,131 +5183,6 @@ int BlueStore::_touch(TransContext *txc, return r; } -int BlueStore::_do_overlay_trim(TransContext *txc, - OnodeRef o, - uint64_t offset, - uint64_t length) -{ - dout(10) << __func__ << " " << o->oid << " 0x" - << std::hex << offset << "~" << length << std::dec << dendl; - int changed = 0; - - map::iterator p = - o->onode.overlay_map.lower_bound(offset); - if (p != o->onode.overlay_map.begin()) { - --p; - } - while (p != o->onode.overlay_map.end()) { - if (p->first >= offset + length) { - dout(20) << __func__ << " stop at " << p->first << " " << p->second - << dendl; - break; - } - if (p->first + p->second.length <= offset) { - dout(20) << __func__ << " skip " << p->first << " " << p->second - << dendl; - ++p; - continue; - } - if (p->first >= offset && - p->first + p->second.length <= offset + length) { - dout(20) << __func__ << " rm " << p->first << " " << p->second - << dendl; - if (o->onode.put_overlay_ref(p->second.key)) { - string key; - get_overlay_key(o->onode.nid, p->second.key, &key); - txc->t->rm_single_key(PREFIX_OVERLAY, key); - } - o->onode.overlay_map.erase(p++); - ++changed; - continue; - } - if (p->first >= offset) { - dout(20) << __func__ << " trim_front " << p->first << " " << p->second - << dendl; - bluestore_overlay_t& ov = o->onode.overlay_map[offset + length] = p->second; - uint64_t by = offset + length - p->first; - ov.value_offset += by; - ov.length -= by; - o->onode.overlay_map.erase(p++); - ++changed; - continue; - } - if (p->first < offset && - p->first + p->second.length <= offset + length) { - dout(20) << __func__ << " trim_tail " << p->first << " " << p->second - << dendl; - p->second.length = offset - p->first; - ++p; - ++changed; - continue; - } - dout(20) << __func__ << " split " << p->first << " " << p->second - << dendl; - assert(p->first < offset); - assert(p->first + p->second.length > offset + length); - bluestore_overlay_t& nov = o->onode.overlay_map[offset + length] = p->second; - p->second.length = offset - p->first; - uint64_t by = offset + length - p->first; - nov.value_offset += by; - nov.length -= by; - o->onode.get_overlay_ref(p->second.key); - ++p; - ++changed; - } - return changed; -} - -int BlueStore::_do_overlay_write(TransContext *txc, - OnodeRef o, - uint64_t offset, - uint64_t length, - const bufferlist& bl) -{ - _do_overlay_trim(txc, o, offset, length); - - dout(10) << __func__ << " " << o->oid << " 0x" - << std::hex << offset << "~" << length << std::dec << dendl; - bluestore_overlay_t& ov = o->onode.overlay_map[offset] = - bluestore_overlay_t(++o->onode.last_overlay_key, 0, length); - dout(20) << __func__ << " added 0x" << std::hex << offset << std::dec - << " " << ov << dendl; - string key; - get_overlay_key(o->onode.nid, o->onode.last_overlay_key, &key); - txc->t->set(PREFIX_OVERLAY, key, bl); - return 0; -} - -int BlueStore::_do_write_overlays(TransContext *txc, - CollectionRef& c, - OnodeRef o, - uint64_t orig_offset, - uint64_t orig_length) -{ - if (o->onode.overlay_map.empty()) - return 0; - - assert(0 == "this is all broken"); - - txc->write_onode(o); - return 0; -} - -void BlueStore::_do_read_all_overlays(bluestore_wal_op_t& wo) -{ - for (vector::iterator q = wo.overlays.begin(); - q != wo.overlays.end(); ++q) { - string key; - get_overlay_key(wo.nid, q->key, &key); - bufferlist bl, bl_data; - int r = db->get(PREFIX_OVERLAY, key, &bl); - assert(r >= 0); - bl_data.substr_of(bl, q->value_offset, q->length); - wo.data.claim_append(bl_data); - } - return; -} - void BlueStore::_dump_onode(OnodeRef o, int log_level) { if (!g_conf->subsys.should_gather(ceph_subsys_bluestore, log_level)) @@ -5442,18 +5208,6 @@ void BlueStore::_dump_onode(OnodeRef o, int log_level) assert(p.first >= pos); pos = p.first + p.second.length; } - pos = 0; - for (auto& v : o->onode.overlay_map) { - dout(log_level) << __func__ << " overlay 0x" << std::hex << v.first - << std::dec << ": " << v.second - << dendl; - assert(v.first >= pos); - pos = v.first + v.second.length; - } - if (!o->onode.overlay_refs.empty()) { - dout(log_level) << __func__ << " overlay_refs " << o->onode.overlay_refs - << dendl; - } _dump_blob_map(o->blob_map, log_level); if (o->bnode) { _dump_bnode(o->bnode, log_level); @@ -5552,13 +5306,6 @@ void BlueStore::_pad_zeros( logger->inc(l_bluestore_write_pad_bytes, pad_count); } -bool BlueStore::_can_overlay_write(OnodeRef o, uint64_t length) -{ - return - (int)o->onode.overlay_map.size() < g_conf->bluestore_overlay_max && - (int)length <= g_conf->bluestore_overlay_max_length; -} - void BlueStore::_do_write_small( TransContext *txc, CollectionRef &c, diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 699ddf8d3192c..df7f5074f0710 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1392,19 +1392,6 @@ class BlueStore : public ObjectStore, uint64_t offset, size_t len, bufferlist& bl, uint32_t fadvise_flags); - bool _can_overlay_write(OnodeRef o, uint64_t length); - int _do_overlay_trim(TransContext *txc, - OnodeRef o, - uint64_t offset, - uint64_t length); - int _do_overlay_write(TransContext *txc, - OnodeRef o, - uint64_t offset, - uint64_t length, - const bufferlist& bl); - int _do_write_overlays(TransContext *txc, CollectionRef& c, OnodeRef o, - uint64_t offset, uint64_t length); - void _do_read_all_overlays(bluestore_wal_op_t& wo); void _pad_zeros(bufferlist *bl, uint64_t *offset, uint64_t *length, uint64_t chunk_size); int _do_write(TransContext *txc, From e5cbb450b6d85916bcbeae7310c8a59f5c027794 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Jun 2016 14:34:18 -0400 Subject: [PATCH 5/6] os/bluestore/bluestore_types: drop overlay fields from wal and onode Signed-off-by: Sage Weil --- src/os/bluestore/bluestore_types.cc | 42 ----------------------------- src/os/bluestore/bluestore_types.h | 26 ------------------ 2 files changed, 68 deletions(-) diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 26469f962ccc4..67bff11652861 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -726,9 +726,6 @@ void bluestore_onode_t::encode(bufferlist& bl) const ::encode(size, bl); ::encode(attrs, bl); ::encode(extent_map, bl); - ::encode(overlay_map, bl); - ::encode(overlay_refs, bl); - ::encode(last_overlay_key, bl); ::encode(omap_head, bl); ::encode(expected_object_size, bl); ::encode(expected_write_size, bl); @@ -743,9 +740,6 @@ void bluestore_onode_t::decode(bufferlist::iterator& p) ::decode(size, p); ::decode(attrs, p); ::decode(extent_map, p); - ::decode(overlay_map, p); - ::decode(overlay_refs, p); - ::decode(last_overlay_key, p); ::decode(omap_head, p); ::decode(expected_object_size, p); ::decode(expected_write_size, p); @@ -774,25 +768,6 @@ void bluestore_onode_t::dump(Formatter *f) const f->close_section(); } f->close_section(); - f->open_object_section("overlays"); - for (map::const_iterator p = overlay_map.begin(); - p != overlay_map.end(); ++p) { - f->open_object_section("overlay"); - f->dump_unsigned("offset", p->first); - p->second.dump(f); - f->close_section(); - } - f->close_section(); - f->open_array_section("overlay_refs"); - for (map::const_iterator p = overlay_refs.begin(); - p != overlay_refs.end(); ++p) { - f->open_object_section("overlay"); - f->dump_unsigned("offset", p->first); - f->dump_unsigned("refs", p->second); - f->close_section(); - } - f->close_section(); - f->dump_unsigned("last_overlay_key", last_overlay_key); f->dump_unsigned("omap_head", omap_head); f->dump_unsigned("expected_object_size", expected_object_size); f->dump_unsigned("expected_write_size", expected_write_size); @@ -907,9 +882,6 @@ void bluestore_wal_op_t::encode(bufferlist& bl) const ::encode(op, bl); ::encode(extents, bl); ::encode(data, bl); - ::encode(nid, bl); - ::encode(overlays, bl); - ::encode(removed_overlays, bl); ENCODE_FINISH(bl); } @@ -919,9 +891,6 @@ void bluestore_wal_op_t::decode(bufferlist::iterator& p) ::decode(op, p); ::decode(extents, p); ::decode(data, p); - ::decode(nid, p); - ::decode(overlays, p); - ::decode(removed_overlays, p); DECODE_FINISH(p); } @@ -934,17 +903,6 @@ void bluestore_wal_op_t::dump(Formatter *f) const f->dump_object("extent", e); } f->close_section(); - f->dump_unsigned("nid", nid); - f->open_array_section("overlays"); - for (auto& o : overlays) { - f->dump_object("overlay", o); - } - f->close_section(); - f->open_array_section("removed_overlays"); - for (auto key : removed_overlays) { - f->dump_unsigned("key", key); - } - f->close_section(); } void bluestore_wal_op_t::generate_test_instances(list& o) diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index a4335e2269d37..fb06fc20c643a 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -519,9 +519,6 @@ struct bluestore_onode_t { uint64_t size; ///< object size map attrs; ///< attrs map extent_map; ///< extent refs - map overlay_map; ///< overlay data (stored in db) - map overlay_refs; ///< overlay keys ref counts (if >1) - uint32_t last_overlay_key; ///< key for next overlay uint64_t omap_head; ///< id for omap root node uint32_t expected_object_size; @@ -531,7 +528,6 @@ struct bluestore_onode_t { bluestore_onode_t() : nid(0), size(0), - last_overlay_key(0), omap_head(0), expected_object_size(0), expected_write_size(0), @@ -590,24 +586,6 @@ struct bluestore_onode_t { void punch_hole(uint64_t offset, uint64_t length, vector *deref); - bool put_overlay_ref(uint64_t key) { - map::iterator q = overlay_refs.find(key); - if (q == overlay_refs.end()) - return true; - assert(q->second >= 2); - if (--q->second == 1) { - overlay_refs.erase(q); - } - return false; - } - void get_overlay_ref(uint64_t key) { - map::iterator q = overlay_refs.find(key); - if (q == overlay_refs.end()) - overlay_refs[key] = 2; - else - ++q->second; - } - void encode(bufferlist& bl) const; void decode(bufferlist::iterator& p); void dump(Formatter *f) const; @@ -626,10 +604,6 @@ struct bluestore_wal_op_t { vector extents; bufferlist data; - uint64_t nid; - vector overlays; - vector removed_overlays; - void encode(bufferlist& bl) const; void decode(bufferlist::iterator& p); void dump(Formatter *f) const; From 9665f4718c080502a63487942ec039babfa506dc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Jun 2016 14:35:02 -0400 Subject: [PATCH 6/6] os/bluestore/bluestore_types: drop overlay types Signed-off-by: Sage Weil --- src/os/bluestore/bluestore_types.cc | 41 ----------------------------- src/os/bluestore/bluestore_types.h | 21 --------------- src/test/encoding/types.h | 1 - 3 files changed, 63 deletions(-) diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 67bff11652861..4f81ac8081d83 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -335,47 +335,6 @@ ostream& operator<<(ostream& out, const bluestore_extent_ref_map_t& m) return out; } -// bluestore_overlay_t - -void bluestore_overlay_t::encode(bufferlist& bl) const -{ - ENCODE_START(1, 1, bl); - ::encode(key, bl); - ::encode(value_offset, bl); - ::encode(length, bl); - ENCODE_FINISH(bl); -} - -void bluestore_overlay_t::decode(bufferlist::iterator& p) -{ - DECODE_START(1, p); - ::decode(key, p); - ::decode(value_offset, p); - ::decode(length, p); - DECODE_FINISH(p); -} - -void bluestore_overlay_t::dump(Formatter *f) const -{ - f->dump_unsigned("key", key); - f->dump_unsigned("value_offset", value_offset); - f->dump_unsigned("length", length); -} - -void bluestore_overlay_t::generate_test_instances(list& o) -{ - o.push_back(new bluestore_overlay_t()); - o.push_back(new bluestore_overlay_t(789, 1024, 1232232)); -} - -ostream& operator<<(ostream& out, const bluestore_overlay_t& o) -{ - out << "overlay(0x" << std::hex << o.value_offset << "~" << o.length - << std::dec << " key " << o.key << ")"; - return out; -} - - // bluestore_pextent_t void bluestore_pextent_t::dump(Formatter *f) const diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index fb06fc20c643a..ad1655df67dbf 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -144,27 +144,6 @@ static inline bool operator!=(const bluestore_extent_ref_map_t& l, return !(l == r); } -/// overlay: a byte extent backed by kv pair, logically overlaying other content -struct bluestore_overlay_t { - uint64_t key; ///< key (nid+key identify the kv pair in the kvdb) - uint32_t value_offset; ///< offset in associated value for this extent - uint32_t length; - - bluestore_overlay_t() : key(0), value_offset(0), length(0) {} - bluestore_overlay_t(uint64_t k, uint32_t vo, uint32_t l) - : key(k), value_offset(vo), length(l) {} - - void encode(bufferlist& bl) const; - void decode(bufferlist::iterator& p); - void dump(Formatter *f) const; - static void generate_test_instances(list& o); - -}; -WRITE_CLASS_ENCODER(bluestore_overlay_t) - -ostream& operator<<(ostream& out, const bluestore_overlay_t& o); - - /// blob: a piece of data on disk struct bluestore_blob_t { enum { diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 2594e4ac3f27f..e39641111f09e 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -120,7 +120,6 @@ TYPE(SequencerPosition) TYPE(bluestore_cnode_t) TYPE(bluestore_compression_header_t) TYPE(bluestore_extent_ref_map_t) -TYPE(bluestore_overlay_t) TYPE(bluestore_pextent_t) TYPE(bluestore_blob_t) TYPE(bluestore_lextent_t)