]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PaxosService: unwind should_trim()
authorSage Weil <sage@inktank.com>
Tue, 9 Jul 2013 04:44:05 +0000 (21:44 -0700)
committerSage Weil <sage@inktank.com>
Tue, 9 Jul 2013 04:44:05 +0000 (21:44 -0700)
Inline the single-caller helper.  This will help us in a moment...

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 5c06f193271b67ab5384f6d5138c3c41579cc588..9f4a3f690cbe3309dfd4847d5c3b6f1cdfac05ac 100644 (file)
@@ -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)
index cd00718a36711d351950a195b174362f0852d055..ae15f049115d8533b699f0c053b1eb5e95586e7e 100644 (file)
@@ -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