]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: increase max global id only when paxos is writable
authorYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 9 Nov 2009 22:01:43 +0000 (14:01 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 9 Nov 2009 22:01:43 +0000 (14:01 -0800)
src/mon/AuthMonitor.cc
src/mon/AuthMonitor.h

index 2ff7d4ccfecf0f482f3064da1f1242cc4546e00d..8aacb28c21bf70d6d3e0e2ca307b5b4c0c0aec44 100644 (file)
@@ -275,7 +275,7 @@ bool AuthMonitor::preprocess_query(PaxosServiceMessage *m)
     return preprocess_command((MMonCommand*)m);
 
   case CEPH_MSG_AUTH:
-    return preprocess_auth((MAuth *)m);
+    return prep_auth((MAuth *)m, false);
 
   case MSG_MON_GLOBAL_ID:
     return false;
@@ -296,6 +296,8 @@ bool AuthMonitor::prepare_update(PaxosServiceMessage *m)
     return prepare_command((MMonCommand*)m);
   case MSG_MON_GLOBAL_ID:
     return prepare_global_id((MMonGlobalID*)m); 
+  case CEPH_MSG_AUTH:
+    return prep_auth((MAuth *)m, true);
   default:
     assert(0);
     delete m;
@@ -314,7 +316,7 @@ void AuthMonitor::election_finished()
   last_allocated_id = -1;
 }
 
-uint64_t AuthMonitor::assign_global_id(MAuth *m)
+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="
@@ -340,6 +342,9 @@ uint64_t AuthMonitor::assign_global_id(MAuth *m)
       paxos->wait_for_commit(new C_RetryMessage(this, m));
       return 0;
     } else {
+      if (!should_increase_max)
+        return 0;
+
       dout(10) << "increasing max_global_id" << dendl;
       increase_max_global_id();
     }
@@ -351,9 +356,9 @@ uint64_t AuthMonitor::assign_global_id(MAuth *m)
 }
 
 
-bool AuthMonitor::preprocess_auth(MAuth *m)
+bool AuthMonitor::prep_auth(MAuth *m, bool paxos_writable)
 {
-  dout(0) << "preprocess_auth() blob_size=" << m->get_auth_payload().length() << dendl;
+  dout(0) << "prep_auth() blob_size=" << m->get_auth_payload().length() << dendl;
   int ret = 0;
   AuthCapsInfo caps_info;
   MAuthReply *reply;
@@ -370,9 +375,11 @@ bool AuthMonitor::preprocess_auth(MAuth *m)
     EntityName entity_name;
 
     if (!s->auth_handler) {
-      s->global_id = assign_global_id(m);
-      if (!s->global_id)
-        goto done;
+      s->global_id = assign_global_id(m, paxos_writable);
+      if (!s->global_id) {
+        s->put();
+        return false;
+      }
 
       set<__u32> supported;
       
@@ -390,7 +397,7 @@ bool AuthMonitor::preprocess_auth(MAuth *m)
          ret = -EPERM;
        else {
           ::encode(s->global_id, response_bl);
-         proto = s->auth_handler->start_session(entity_name, indata, response_bl);
+         proto = s->auth_handler->start_session(entity_name, s->global_id, indata, response_bl);
           if (proto == CEPH_AUTH_NONE) {
             s->caps.set_allow_all(true);
           }
index 62ed47f2c30ccabce62e1f526b33dc081f7d92a8..d09d78819b1835473bb914b426de820444441673 100644 (file)
@@ -90,7 +90,7 @@ private:
   void create_pending();  // prepare a new pending
   bool prepare_global_id(MMonGlobalID *m);
   void increase_max_global_id();
-  uint64_t assign_global_id(MAuth *m);
+  uint64_t assign_global_id(MAuth *m, bool should_increase_max);
   void encode_pending(bufferlist &bl);  // propose pending update to peers
 
   void committed();
@@ -98,13 +98,11 @@ private:
   bool preprocess_query(PaxosServiceMessage *m);  // true if processed.
   bool prepare_update(PaxosServiceMessage *m);
 
-  bool preprocess_auth(MAuth *m);
+  bool prep_auth(MAuth *m, bool paxos_writable);
 
   bool preprocess_command(MMonCommand *m);
   bool prepare_command(MMonCommand *m);
 
-  uint64_t assign_next_global_id();
-
   void check_rotate();
  public:
   AuthMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p), last_rotating_ver(0), max_global_id(-1), last_allocated_id(-1) {}