]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/journal: fixed possible infinite loop in expire_tags
authorJason Dillaman <dillaman@redhat.com>
Fri, 27 Oct 2017 13:57:43 +0000 (09:57 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 27 Oct 2017 19:23:44 +0000 (15:23 -0400)
Fixes: http://tracker.ceph.com/issues/21956
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/journal/cls_journal.cc
src/test/cls_journal/test_cls_journal.cc

index 091fac1feef1a51229b0e07f1b1416803c027a7e..e8646116e981bf6b9c5f0ddad373ef658220adfc 100644 (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;
       }
     }
index 29bf4250faa862d4e8200cb51f8a1152078aa84f..9df173d6202714aded8c22acb95a2ac5ee1d8a50 100644 (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));