]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/journal: ensure tags are properly expired 20282/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 27 Oct 2017 20:45:54 +0000 (16:45 -0400)
committerNathan Cutler <ncutler@suse.com>
Sat, 3 Feb 2018 19:50:49 +0000 (20:50 +0100)
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>
(cherry picked from commit 19fa1c7f5b2809e9a223b7b196dfc031e97a5dcd)

Conflicts:
src/cls/journal/cls_journal.cc (jewel does not have d3de6f5e07cb30d81ce8cc539256c6cf754b28d5)

src/cls/journal/cls_journal.cc

index 2682926d57a4e35ca9e5d9200973a15a18d39118..f11217ed2230677ffa09ecb45d93e5ffb4282918 100644 (file)
@@ -125,7 +125,7 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) {
 
   int r;
   uint64_t minimum_tag_tid = std::numeric_limits<uint64_t>::max();
-  std::string last_read = HEADER_KEY_CLIENT_PREFIX;
+  std::string last_read = "";
   do {
     std::map<std::string, bufferlist> vals;
     r = cls_cxx_map_get_vals(hctx, last_read, HEADER_KEY_CLIENT_PREFIX,
@@ -152,6 +152,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);
       }