Skip to content

Commit

Permalink
os/bluestore: get rid of key from constructor of SharedBlob()
Browse files Browse the repository at this point in the history
We'll generate and assign it to blob explictly later.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
  • Loading branch information
xiexingguo committed Nov 18, 2016
1 parent 8037900 commit fdaef67
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
7 changes: 3 additions & 4 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1280,9 +1280,8 @@ ostream& operator<<(ostream& out, const BlueStore::SharedBlob& sb)
return out << ")";
}

BlueStore::SharedBlob::SharedBlob(uint64_t i, const string& k, Cache *c)
BlueStore::SharedBlob::SharedBlob(uint64_t i, Cache *c)
: sbid(i),
key(k),
bc(c)
{
}
Expand Down Expand Up @@ -2294,7 +2293,7 @@ void BlueStore::Collection::open_shared_blob(BlobRef b)
assert(!b->shared_blob);
const bluestore_blob_t& blob = b->get_blob();
if (!blob.is_shared()) {
b->shared_blob = new SharedBlob(0, string(), cache);
b->shared_blob = new SharedBlob(0, cache);
return;
}

Expand All @@ -2303,7 +2302,7 @@ void BlueStore::Collection::open_shared_blob(BlobRef b)
dout(10) << __func__ << " sbid 0x" << std::hex << blob.sbid << std::dec
<< " had " << *b->shared_blob << dendl;
} else {
b->shared_blob = new SharedBlob(blob.sbid, string(), cache);
b->shared_blob = new SharedBlob(blob.sbid, cache);
get_shared_blob_key(blob.sbid, &b->shared_blob->key);
shared_blob_set.add(b->shared_blob.get());
dout(10) << __func__ << " sbid 0x" << std::hex << blob.sbid << std::dec
Expand Down
4 changes: 2 additions & 2 deletions src/os/bluestore/BlueStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class BlueStore : public ObjectStore,

BufferSpace bc; ///< buffer cache

SharedBlob(uint64_t i, const string& k, Cache *c);
SharedBlob(uint64_t i, Cache *c);
~SharedBlob();

friend void intrusive_ptr_add_ref(SharedBlob *b) { b->get(); }
Expand Down Expand Up @@ -1117,7 +1117,7 @@ class BlueStore : public ObjectStore,

BlobRef new_blob() {
BlobRef b = new Blob;
b->shared_blob = new SharedBlob(0, string(), cache);
b->shared_blob = new SharedBlob(0, cache);
return b;
}

Expand Down
44 changes: 22 additions & 22 deletions src/test/objectstore/test_bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ TEST(Blob, put_ref)
{
{
BlueStore::Blob b;
b.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
b.shared_blob = new BlueStore::SharedBlob(0, nullptr);
b.shared_blob->get(); // hack to avoid dtor from running
b.dirty_blob().extents.push_back(bluestore_pextent_t(0x40715000, 0x2000));
b.dirty_blob().extents.push_back(
Expand All @@ -361,7 +361,7 @@ TEST(Blob, put_ref)

{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand All @@ -381,7 +381,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand All @@ -402,7 +402,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -437,7 +437,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -475,7 +475,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -504,7 +504,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -539,7 +539,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -589,7 +589,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -639,7 +639,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand Down Expand Up @@ -677,7 +677,7 @@ TEST(Blob, put_ref)
// verify csum chunk size if factored in properly
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
Expand All @@ -694,7 +694,7 @@ TEST(Blob, put_ref)
}
{
BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(-1, string(), nullptr);
B.shared_blob = new BlueStore::SharedBlob(0, nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
B.get_ref(0x0, 0x3800);
Expand Down Expand Up @@ -780,9 +780,9 @@ TEST(Blob, split)
BlueStore::Cache *cache = BlueStore::Cache::create("lru", NULL);
{
BlueStore::Blob L, R;
L.shared_blob = new BlueStore::SharedBlob(-1, string(), cache);
L.shared_blob = new BlueStore::SharedBlob(0, cache);
L.shared_blob->get(); // hack to avoid dtor from running
R.shared_blob = new BlueStore::SharedBlob(-1, string(), cache);
R.shared_blob = new BlueStore::SharedBlob(0, cache);
R.shared_blob->get(); // hack to avoid dtor from running
L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x2000, 0x2000));
L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
Expand All @@ -800,9 +800,9 @@ TEST(Blob, split)
}
{
BlueStore::Blob L, R;
L.shared_blob = new BlueStore::SharedBlob(-1, string(), cache);
L.shared_blob = new BlueStore::SharedBlob(0, cache);
L.shared_blob->get(); // hack to avoid dtor from running
R.shared_blob = new BlueStore::SharedBlob(-1, string(), cache);
R.shared_blob = new BlueStore::SharedBlob(0, cache);
R.shared_blob->get(); // hack to avoid dtor from running
L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x2000, 0x1000));
L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x12000, 0x1000));
Expand All @@ -826,7 +826,7 @@ TEST(ExtentMap, find_lextent)
BlueStore::LRUCache cache;
BlueStore::ExtentMap em(nullptr);
BlueStore::BlobRef br(new BlueStore::Blob);
br->shared_blob = new BlueStore::SharedBlob(-1, string(), &cache);
br->shared_blob = new BlueStore::SharedBlob(0, &cache);

ASSERT_EQ(em.extent_map.end(), em.find_lextent(0));
ASSERT_EQ(em.extent_map.end(), em.find_lextent(100));
Expand Down Expand Up @@ -872,7 +872,7 @@ TEST(ExtentMap, seek_lextent)
BlueStore::LRUCache cache;
BlueStore::ExtentMap em(nullptr);
BlueStore::BlobRef br(new BlueStore::Blob);
br->shared_blob = new BlueStore::SharedBlob(-1, string(), &cache);
br->shared_blob = new BlueStore::SharedBlob(0, &cache);

ASSERT_EQ(em.extent_map.end(), em.seek_lextent(0));
ASSERT_EQ(em.extent_map.end(), em.seek_lextent(100));
Expand Down Expand Up @@ -918,7 +918,7 @@ TEST(ExtentMap, has_any_lextents)
BlueStore::LRUCache cache;
BlueStore::ExtentMap em(nullptr);
BlueStore::BlobRef b(new BlueStore::Blob);
b->shared_blob = new BlueStore::SharedBlob(-1, string(), &cache);
b->shared_blob = new BlueStore::SharedBlob(0, &cache);

ASSERT_FALSE(em.has_any_lextents(0, 0));
ASSERT_FALSE(em.has_any_lextents(0, 1000));
Expand Down Expand Up @@ -964,9 +964,9 @@ TEST(ExtentMap, compress_extent_map)
BlueStore::BlobRef b1(new BlueStore::Blob);
BlueStore::BlobRef b2(new BlueStore::Blob);
BlueStore::BlobRef b3(new BlueStore::Blob);
b1->shared_blob = new BlueStore::SharedBlob(-1, string(), &cache);
b2->shared_blob = new BlueStore::SharedBlob(-1, string(), &cache);
b3->shared_blob = new BlueStore::SharedBlob(-1, string(), &cache);
b1->shared_blob = new BlueStore::SharedBlob(0, &cache);
b2->shared_blob = new BlueStore::SharedBlob(0, &cache);
b3->shared_blob = new BlueStore::SharedBlob(0, &cache);

em.extent_map.insert(*new BlueStore::Extent(0, 0, 100, b1));
em.extent_map.insert(*new BlueStore::Extent(100, 0, 100, b2));
Expand Down

0 comments on commit fdaef67

Please sign in to comment.