]> git.apps.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>
Mon, 30 Oct 2017 13:01:17 +0000 (09:01 -0400)
Fixes: http://tracker.ceph.com/issues/21956
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 9e66dca49591e50b9cab5df311f1dc217eb58fcc)

src/cls/journal/cls_journal.cc
src/test/cls_journal/test_cls_journal.cc

index dfcba9813a3a37e41ae7bdb6e5841aafb9704857..2f1d18d0d79c88a3caa383a915a2885e7d18e322 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 d9cdb6b7754f19765e9855c227a3c14f1ea227cb..7d948c976e62dc1889b7c987e65333bf9868ef02 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));