cls/journal: fixed possible infinite loop in expire_tags

Fixes: http://tracker.ceph.com/issues/21956
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2017-10-27 09:57:43 -04:00
parent 900f1c024a
commit 9e66dca495
2 changed files with 10 additions and 3 deletions

View File

@ -188,6 +188,7 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) {
if (tag.tid >= minimum_tag_tid) {
// no need to check for tag classes beyond this point
vals.clear();
more = false;
break;
}
}

View File

@ -322,15 +322,21 @@ TEST_F(TestClsJournal, ClientUnregisterPruneTags) {
bufferlist()));
ASSERT_EQ(0, client::tag_create(ioctx, oid, 1, Tag::TAG_CLASS_NEW,
bufferlist()));
ASSERT_EQ(0, client::tag_create(ioctx, oid, 2, 1, bufferlist()));
for (uint32_t i = 2; i <= 96; ++i) {
ASSERT_EQ(0, client::tag_create(ioctx, oid, i, 1, bufferlist()));
}
librados::ObjectWriteOperation op1;
client::client_commit(&op1, "id1", {{{1, 2, 120}}});
client::client_commit(&op1, "id1", {{{1, 32, 120}}});
ASSERT_EQ(0, ioctx.operate(oid, &op1));
ASSERT_EQ(0, client::client_unregister(ioctx, oid, "id2"));
std::set<Tag> expected_tags = {{0, 0, {}}, {2, 1, {}}};
std::set<Tag> expected_tags = {{0, 0, {}}};
for (uint32_t i = 32; i <= 96; ++i) {
expected_tags.insert({i, 1, {}});
}
std::set<Tag> tags;
ASSERT_EQ(0, client::tag_list(ioctx, oid, "id1",
boost::optional<uint64_t>(), &tags));