From 19fa1c7f5b2809e9a223b7b196dfc031e97a5dcd Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 27 Oct 2017 16:45:54 -0400 Subject: [PATCH] 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 --- src/cls/journal/cls_journal.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cls/journal/cls_journal.cc b/src/cls/journal/cls_journal.cc index 091fac1feef1a..30102d18299e4 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); } -- 2.39.5