summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-12-02 15:03:50 -0800
committerSage Weil <sage@newdream.net>2009-12-02 15:03:50 -0800
commit714a9af30d3433798dcaccfcdfd632ee801cbdc3 (patch)
tree8fcc0c02782cf939eba8c09c85f2b81b0e4f01fd
parent89603b6bca0c5fcf23e24e5d5be14a55d88b7f42 (diff)
downloadceph-historic/aleung_mds_security.tar.gz
mon: fix allocation of low global_ids after mon restarthistoric/aleung_mds_security
We need to set last_allocated in init(). Also avoid the -1 casting and just use 0 instead.
-rw-r--r--src/mon/AuthMonitor.cc15
-rw-r--r--src/mon/AuthMonitor.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc
index 85ac9238fd8..feba38e2bfa 100644
--- a/src/mon/AuthMonitor.cc
+++ b/src/mon/AuthMonitor.cc
@@ -192,10 +192,11 @@ bool AuthMonitor::update_from_paxos()
mon->key_server.set_ver(keys_ver);
}
- if (last_allocated_id == (uint64_t)-1) {
+ if (last_allocated_id == 0)
last_allocated_id = max_global_id;
- }
- dout(10) << "update_from_paxos() last_allocated_id=" << last_allocated_id << " max_global_id=" << max_global_id << dendl;
+
+ dout(10) << "update_from_paxos() last_allocated_id=" << last_allocated_id
+ << " max_global_id=" << max_global_id << dendl;
bufferlist bl;
::encode(max_global_id, bl);
@@ -245,6 +246,8 @@ void AuthMonitor::init()
}
}
+ last_allocated_id = max_global_id;
+
/* should only happen on the first time */
update_from_paxos();
}
@@ -309,14 +312,14 @@ void AuthMonitor::committed()
void AuthMonitor::election_finished()
{
dout(10) << "AuthMonitor::election_starting" << dendl;
- last_allocated_id = -1;
+ last_allocated_id = 0;
}
uint64_t AuthMonitor::assign_global_id(MAuth *m, bool should_increase_max)
{
int total_mon = mon->monmap->size();
- dout(10) << "AuthMonitor::assign_global_id m=" << *m << " mon=" << mon->whoami << "/" << total_mon << " last_allocated="
- << last_allocated_id << " max_global_id=" << max_global_id << dendl;
+ dout(10) << "AuthMonitor::assign_global_id m=" << *m << " mon=" << mon->whoami << "/" << total_mon
+ << " last_allocated=" << last_allocated_id << " max_global_id=" << max_global_id << dendl;
uint64_t next_global_id = last_allocated_id + 1;
diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h
index 4a9da02f083..0d79ac187c0 100644
--- a/src/mon/AuthMonitor.h
+++ b/src/mon/AuthMonitor.h
@@ -106,7 +106,7 @@ private:
void check_rotate();
public:
- AuthMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p), last_rotating_ver(0), max_global_id(-1), last_allocated_id(-1) {}
+ AuthMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p), last_rotating_ver(0), max_global_id(0), last_allocated_id(0) {}
void pre_auth(MAuth *m);
void tick(); // check state, take actions