From 279661f353570a2c4a0f223003636688b28f13fb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 7 Nov 2011 22:09:56 -0800 Subject: [PATCH] paxos: last_consumed == latest_stashed; behave accordingly Initialize on startup. Don't re-read off of disk on every trim_to() call. Signed-off-by: Sage Weil --- src/mon/Paxos.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 885325b7990e1..9e12be7ec4bf4 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -43,7 +43,7 @@ void Paxos::init() accepted_pn = mon->store->get_int(machine_name, "accepted_pn"); last_committed = mon->store->get_int(machine_name, "last_committed"); first_committed = mon->store->get_int(machine_name, "first_committed"); - latest_stashed = 0; + latest_stashed = mon->store->get_int(machine_name, "last_consumed"); dout(10) << "init" << dendl; } @@ -710,17 +710,15 @@ void Paxos::lease_renew_timeout() void Paxos::trim_to(version_t first) { - version_t last_consumed = mon->store->get_int(machine_name, "last_consumed"); - dout(10) << "trim_to " << first << " (was " << first_committed << ")" - << ", last_consumed " << last_consumed + << ", latest_stashed " << latest_stashed << dendl; if (first_committed >= first) return; while (first_committed < first && - first_committed < last_consumed) { + first_committed < latest_stashed) { dout(10) << "trim " << first_committed << dendl; mon->store->erase_sn(machine_name, first_committed); for (list::iterator p = extra_state_dirs.begin(); -- 2.39.5