]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PaxosService: simplify is_writeable
authorSage Weil <sage@inktank.com>
Thu, 6 Jun 2013 22:20:05 +0000 (15:20 -0700)
committerSage Weil <sage@inktank.com>
Wed, 19 Jun 2013 18:27:05 +0000 (11:27 -0700)
Recast this in terms of paxos check + our conditions, and make it
match wait_for_writeable().

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/PaxosService.h

index dbe37434a71c4b2b3657ca06250b0c29d8d47f67..2fd7515c32358ce6e118d00221d72334c34a2bd4 100644 (file)
@@ -545,19 +545,16 @@ public:
    * We consider to be writeable iff:
    *
    *  - we are not proposing a new version;
-   *  - our monitor is the leader;
-   *  - we have a valid lease;
-   *  - Paxos is not boostrapping.
-   *  - Paxos is not recovering.
    *  - we are ready to be written to -- i.e., we have a pending value.
+   *  - paxos is writeable
    *
    * @returns true if writeable; false otherwise
    */
   bool is_writeable() {
-    return (is_active()
-        && mon->is_leader()
-        && paxos->is_lease_valid()
-        && is_write_ready());
+    return
+      !is_proposing() &&
+      is_write_ready() &&
+      paxos->is_writeable();
   }
 
   /**
@@ -621,12 +618,12 @@ public:
    * @param c The callback to be awaken once we become writeable.
    */
   void wait_for_writeable(Context *c) {
-    if (!is_proposing()) {
+    if (is_proposing())
+      wait_for_finished_proposal(c);
+    else if (!is_write_ready())
+      wait_for_active(c);
+    else
       paxos->wait_for_writeable(c);
-      return;
-    }
-
-    wait_for_finished_proposal(c);
   }
 
   /**