From: Sage Weil Date: Tue, 15 Jan 2019 20:41:36 +0000 (-0600) Subject: mon/AuthMonitor: bump max_global_id from on_active() and tick() X-Git-Tag: v14.1.0~183^2~58 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6663d17ad773c49841626ec57157239aa515ec39;p=ceph.git mon/AuthMonitor: bump max_global_id from on_active() and tick() We should get some runway even if there isn't an auth request coming in. Signed-off-by: Sage Weil --- diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 852530a73a50..c56b5424b73d 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -73,8 +73,20 @@ void AuthMonitor::tick() 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() @@ -84,6 +96,11 @@ 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) @@ -289,6 +306,16 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) << 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()); @@ -481,9 +508,8 @@ uint64_t AuthMonitor::assign_global_id(bool should_increase_max) 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(); } diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 208871a9cd55..ecde5b6b60fc 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -142,6 +142,7 @@ private: 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