]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: create-erasure uses crush_ruleset_create_erasure
authorLoic Dachary <loic@dachary.org>
Mon, 3 Mar 2014 14:12:53 +0000 (15:12 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 17 Mar 2014 08:48:02 +0000 (09:48 +0100)
Create the ruleset and branch depending on the result:

* If it succeeds, wait
* If it already exists and is pending (-EALREADY), wait
* If it already exists (-EEXIST), return immediately
* If it fails for other reasons, return immediately

Add an informative message when it succeeds.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/OSDMonitor.cc

index ad4df2b093b6625da8590fae1b61126bf19d71fb..9c7df9bde238853cbf063051db7e380f6ab5209a 100644 (file)
@@ -3900,6 +3900,27 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
     if (err)
       goto reply;
 
+    int ruleset;
+    err = crush_ruleset_create_erasure(name, properties_map, &ruleset, ss);
+    if (err < 0) {
+      switch(err) {
+      case -EEXIST: // return immediately
+       ss << "rule " << name << " already exists";
+       err = 0;
+       goto reply;
+       break;
+      case -EALREADY: // wait for pending to be proposed
+       ss << "rule " << name << " already exists";
+       err = 0;
+       break;
+      default: // non recoverable error
+       goto reply;
+       break;
+      }
+    } else {
+      ss << "created ruleset " << name << " at " << ruleset;
+    }
+
     getline(ss, rs);
     wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs,
                                                       get_last_committed() + 1));