From: Jason Dillaman Date: Fri, 27 Oct 2017 20:45:54 +0000 (-0400) Subject: cls/journal: ensure tags are properly expired X-Git-Tag: v13.0.1~378^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=19fa1c7f5b2809e9a223b7b196dfc031e97a5dcd;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 --- diff --git a/src/cls/journal/cls_journal.cc b/src/cls/journal/cls_journal.cc index 091fac1feef1..30102d18299e 100644 --- a/src/cls/journal/cls_journal.cc +++ b/src/cls/journal/cls_journal.cc @@ -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::max(); - std::string last_read = HEADER_KEY_CLIENT_PREFIX; + std::string last_read = ""; bool more; do { std::map 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); }