]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MDSMonitor: check all conditions are met *before* osdmon proposal
authorJoao Eduardo Luis <joao@redhat.com>
Fri, 17 Oct 2014 16:43:33 +0000 (17:43 +0100)
committerJoao Eduardo Luis <joao@redhat.com>
Fri, 17 Oct 2014 16:43:33 +0000 (17:43 +0100)
We should not allow ourselves to request the osdmon to propose before we
know for sure that we meet the required conditions to go through with
our own state change.  Even if we still can't guarantee that our
proposal is going to be committed, we shouldn't just change the osdmon's
state just because we can.  This way, at least, we make sure that our
checks hold up before doing anything with side-effects.

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
src/mon/MDSMonitor.cc

index dd3a6698e5ce1989f6bb7cf56e8e477cd9ffc40f..aa20d933a0fddc7ef6cbca0126a662ba518c33c2 100644 (file)
@@ -1117,14 +1117,11 @@ bool MDSMonitor::management_command(
     pg_pool_t const *metadata_pool = mon->osdmon()->osdmap.get_pg_pool(metadata);
     assert(metadata_pool != NULL);  // Checked it existed above
 
-    // Automatically set crash_replay_interval on data pool if it
-    // isn't already set.
-    if (data_pool->get_crash_replay_interval() == 0) {
-      r = mon->osdmon()->set_crash_replay_interval(data, g_conf->osd_default_data_pool_replay_window);
-      assert(r == 0);  // We just did get_pg_pool so it must exist and be settable
-      request_proposal(mon->osdmon());
-    }
-
+    // we must make these checks before we even allow ourselves to *think*
+    // about requesting a proposal to the osdmonitor and bail out now if
+    // we believe we must.  bailing out *after* we request the proposal is
+    // bad business as we could have changed the osdmon's state and ending up
+    // returning an error to the user.
     r = _check_pool(data, &ss);
     if (r) {
       return true;
@@ -1135,6 +1132,14 @@ bool MDSMonitor::management_command(
       return true;
     }
 
+    // Automatically set crash_replay_interval on data pool if it
+    // isn't already set.
+    if (data_pool->get_crash_replay_interval() == 0) {
+      r = mon->osdmon()->set_crash_replay_interval(data, g_conf->osd_default_data_pool_replay_window);
+      assert(r == 0);  // We just did get_pg_pool so it must exist and be settable
+      request_proposal(mon->osdmon());
+    }
+
     // All checks passed, go ahead and create.
     MDSMap newmap;
     newmap.inc = pending_mdsmap.inc;