From 63fe8635ae56bdc20e8e4f83fa641c56f79805a3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 8 Jul 2013 21:44:05 -0700 Subject: [PATCH] mon/PaxosService: unwind should_trim() Inline the single-caller helper. This will help us in a moment... Signed-off-by: Sage Weil --- src/mon/PaxosService.cc | 35 +++++++++++++++++------------------ src/mon/PaxosService.h | 5 ----- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 5c06f193271b6..9f4a3f690cbe3 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -323,31 +323,30 @@ void PaxosService::shutdown() void PaxosService::maybe_trim() { - if (is_writeable() && should_trim()) { - dout(10) << __func__ << " trimming" << dendl; - - MonitorDBStore::Transaction t; - encode_trim(&t); - bufferlist bl; - t.encode(bl); - - paxos->propose_new_value(bl, new C_Committed(this)); - } -} + if (!is_writeable()) + return; -bool PaxosService::should_trim() -{ update_trim(); if (get_trim_to() == 0) - return false; + return; if (g_conf->paxos_service_trim_min > 0) { version_t trim_to = get_trim_to(); version_t first = get_first_committed(); - if ((trim_to > 0) && trim_to > first) - return ((trim_to - first) >= (version_t)g_conf->paxos_service_trim_min); - } - return true; + if ((trim_to > 0) && + trim_to > first && + (trim_to - first) < (version_t)g_conf->paxos_service_trim_min) + return; // not enough to trim + } + + dout(10) << __func__ << " trimming" << dendl; + + MonitorDBStore::Transaction t; + encode_trim(&t); + bufferlist bl; + t.encode(bl); + + paxos->propose_new_value(bl, new C_Committed(this)); } void PaxosService::encode_trim(MonitorDBStore::Transaction *t) diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index cd00718a36711..ae15f049115d8 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -686,11 +686,6 @@ public: */ virtual void encode_trim_extra(MonitorDBStore::Transaction *tx, version_t first) {} - /** - * decide whether we should trim service states - */ - bool should_trim(); - /** * Update our trim status. We do nothing here, because there is no * straightforward way to update the trim version, since that's service -- 2.39.5