]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/AuthMonitor: bump max_global_id from on_active() and tick()
authorSage Weil <sage@redhat.com>
Tue, 15 Jan 2019 20:41:36 +0000 (14:41 -0600)
committerSage Weil <sage@redhat.com>
Thu, 7 Feb 2019 12:53:03 +0000 (06:53 -0600)
We should get some runway even if there isn't an auth request coming in.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/AuthMonitor.cc
src/mon/AuthMonitor.h

index 852530a73a50886ea4f5ae3669f7cad26c1dee61..c56b5424b73d1f7844c4d515c5f989b20ff2e782 100644 (file)
@@ -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();
   }
 
index 208871a9cd550c59225353bf7138164c1c72a712..ecde5b6b60fc8c51b516d9ea3a19a41091260b9b 100644 (file)
@@ -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