if (!mon->is_leader()) return;
- if (check_rotate())
+ // increase global_id?
+ bool propose = false;
+ if (should_increase_max_global_id()) {
+ increase_max_global_id();
+ propose = true;
+ }
+
+ if (check_rotate()) {
+ propose = true;
+ }
+
+ if (propose) {
propose_pending();
+ }
}
void AuthMonitor::on_active()
if (!mon->is_leader())
return;
mon->key_server.start_server();
+
+ if (is_writeable() && should_increase_max_global_id()) {
+ increase_max_global_id();
+ propose_pending();
+ }
}
bufferlist _encode_cap(const string& cap)
<< dendl;
}
+bool AuthMonitor::should_increase_max_global_id()
+{
+ auto num_prealloc = g_conf()->mon_globalid_prealloc;
+ if (max_global_id < num_prealloc ||
+ (last_allocated_id + 1) >= max_global_id - num_prealloc / 2) {
+ return true;
+ }
+ return false;
+}
+
void AuthMonitor::increase_max_global_id()
{
ceph_assert(mon->is_leader());
bool return_next = (next_global_id <= max_global_id);
// bump the max?
- while (mon->is_leader() &&
- (max_global_id < g_conf()->mon_globalid_prealloc ||
- next_global_id >= max_global_id - g_conf()->mon_globalid_prealloc / 2)) {
+ if (mon->is_leader() &&
+ should_increase_max_global_id()) {
increase_max_global_id();
}
void update_from_paxos(bool *need_bootstrap) override;
void create_pending() override; // prepare a new pending
bool prepare_global_id(MonOpRequestRef op);
+ bool should_increase_max_global_id();
void increase_max_global_id();
uint64_t assign_global_id(bool should_increase_max);
// propose pending update to peers