From: Sage Weil Date: Tue, 25 Jun 2013 23:54:58 +0000 (-0700) Subject: mon/Paxos: clean up removal of pre-conversion paxos states X-Git-Tag: v0.67-rc1~175^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ac63b2e0952b782460af75163c3bc429cfb8abdd;p=ceph.git mon/Paxos: clean up removal of pre-conversion paxos states Use a helper, independent of trim machinery, and call on leader, too. Signed-off-by: Sage Weil --- diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index a952da30171..ce9f2952e2a 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -326,17 +326,22 @@ void Paxos::store_state(MMonPaxos *m) _sanity_check_store(); } + remove_legacy_versions(); +} + +void Paxos::remove_legacy_versions() +{ if (get_store()->exists(get_name(), "conversion_first")) { - MonitorDBStore::Transaction scrub_tx; - version_t cf = get_store()->get(get_name(), "conversion_first"); - dout(10) << __func__ << " scrub paxos from " << cf - << " to " << first_committed << dendl; - if (cf < first_committed) - trim_to(&scrub_tx, cf, first_committed); - scrub_tx.erase(get_name(), "conversion_first"); - get_store()->apply_transaction(scrub_tx); + MonitorDBStore::Transaction t; + version_t v = get_store()->get(get_name(), "conversion_first"); + dout(10) << __func__ << " removing pre-conversion paxos states from " << v + << " until " << first_committed << dendl; + for (; v < first_committed; ++v) { + t.erase(get_name(), v); + } + t.erase(get_name(), "conversion_first"); + get_store()->apply_transaction(t); } - } void Paxos::_sanity_check_store() @@ -698,6 +703,8 @@ void Paxos::commit() // get ready for a new round. new_value.clear(); + + remove_legacy_versions(); } diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index fcc06604024..810953c8101 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -1087,6 +1087,12 @@ public: */ void store_state(MMonPaxos *m); void _sanity_check_store(); + + /** + * remove legacy paxos versions from before conversion + */ + void remove_legacy_versions(); + /** * Helper function to decode a bufferlist into a transaction and append it * to another transaction.