Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/bluestore: pass strict flag to bluestore_blob_use_tracker_t::equal() #15705

Merged
merged 1 commit into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/os/bluestore/bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ void bluestore_blob_use_tracker_t::split(
}

bool bluestore_blob_use_tracker_t::equal(
const bluestore_blob_use_tracker_t& other) const
const bluestore_blob_use_tracker_t& other,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some UT for that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

bool strict) const
{
if (!num_au && !other.num_au) {
return total_bytes == other.total_bytes && au_size == other.au_size;
Expand All @@ -504,6 +505,10 @@ bool bluestore_blob_use_tracker_t::equal(
return true;
}

if (strict) {
return false;
}

uint32_t n = num_au ? num_au : other.num_au;
uint32_t referenced =
num_au ? other.get_referenced_bytes() : get_referenced_bytes();
Expand Down
3 changes: 2 additions & 1 deletion src/os/bluestore/bluestore_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ struct bluestore_blob_use_tracker_t {
bluestore_blob_use_tracker_t* r);

bool equal(
const bluestore_blob_use_tracker_t& other) const;
const bluestore_blob_use_tracker_t& other,
bool strict = true) const;

void bound_encode(size_t& p) const {
denc_varint(au_size, p);
Expand Down
38 changes: 37 additions & 1 deletion src/test/objectstore/test_bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,43 @@ TEST(GarbageCollector, BasicTest)
em.clear();
old_extents.clear();
}
}
}

TEST(bluestore_blob_use_tracker_t, equal)
{
bluestore_blob_use_tracker_t t1, t2, t3;

ASSERT_TRUE(t1.equal(t2));
ASSERT_TRUE(t1.equal(t2, false));

t1.init(0x8000, 0x1000);
t2.init(0x8000, 0x1000);
ASSERT_TRUE(t1.equal(t2));
ASSERT_TRUE(t1.equal(t2, false));

t1.get(0, 0x1000);
ASSERT_TRUE(!t1.equal(t2));
ASSERT_TRUE(!t1.equal(t2, false));
t2.get(0, 0x1000);
ASSERT_TRUE(t1.equal(t2));
ASSERT_TRUE(t1.equal(t2, false));

t1.get(0x1000, 0x1000);
t2.get(0x2000, 0x1000);
ASSERT_TRUE(!t1.equal(t2));
ASSERT_TRUE(!t1.equal(t2, false));

t3.init(0x8000, 0x8000);
t3.get(0x4000, 0x2000);
ASSERT_TRUE(!t3.equal(t1));
ASSERT_TRUE(t3.equal(t1, false));
ASSERT_TRUE(!t3.equal(t2));
ASSERT_TRUE(t3.equal(t2, false));

t1.clear();
t2.clear();
t3.clear();
}

int main(int argc, char **argv) {
vector<const char*> args;
Expand Down