From: Jason Dillaman Date: Fri, 27 Oct 2017 20:45:54 +0000 (-0400) Subject: cls/journal: ensure tags are properly expired X-Git-Tag: v10.2.11~156^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fa5e13616a69474198efc314a14cabcea9c0edfb;p=ceph.git cls/journal: ensure tags are properly expired 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 (cherry picked from commit 19fa1c7f5b2809e9a223b7b196dfc031e97a5dcd) Conflicts: src/cls/journal/cls_journal.cc (jewel does not have d3de6f5e07cb30d81ce8cc539256c6cf754b28d5) --- diff --git a/src/cls/journal/cls_journal.cc b/src/cls/journal/cls_journal.cc index 2682926d57a4..f11217ed2230 100644 --- a/src/cls/journal/cls_journal.cc +++ b/src/cls/journal/cls_journal.cc @@ -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::max(); - std::string last_read = HEADER_KEY_CLIENT_PREFIX; + std::string last_read = ""; do { std::map 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); }