]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/journal: ensure tags are properly expired 18604/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 27 Oct 2017 20:45:54 +0000 (16:45 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sat, 28 Oct 2017 12:48:00 +0000 (08:48 -0400)
Previously, if only the local image was using the journal or if
a disconnected peer was attached, the tag entries could not be
expired even if unreferenced.

Fixes: http://tracker.ceph.com/issues/21960
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/journal/cls_journal.cc

index 091fac1feef1a51229b0e07f1b1416803c027a7e..30102d18299e4ae783e85a5009b15842a4fd9b1d 100644 (file)
@@ -102,7 +102,7 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) {
   }
 
   uint64_t minimum_tag_tid = std::numeric_limits<uint64_t>::max();
-  std::string last_read = HEADER_KEY_CLIENT_PREFIX;
+  std::string last_read = "";
   bool more;
   do {
     std::map<std::string, bufferlist> vals;
@@ -130,6 +130,14 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) {
         return -EIO;
       }
 
+      if (client.state == cls::journal::CLIENT_STATE_DISCONNECTED) {
+        // don't allow a disconnected client to prevent pruning
+        continue;
+      } else if (client.commit_position.object_positions.empty()) {
+        // cannot prune if one or more clients has an empty commit history
+        return 0;
+      }
+
       for (auto object_position : client.commit_position.object_positions) {
         minimum_tag_tid = MIN(minimum_tag_tid, object_position.tag_tid);
       }