]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #2138 from xiaoxichen/fix_crush_ruleset
authorLoic Dachary <loic@dachary.org>
Sun, 24 Aug 2014 22:50:23 +0000 (00:50 +0200)
committerLoic Dachary <loic@dachary.org>
Sun, 24 Aug 2014 22:50:23 +0000 (00:50 +0200)
mon/OSDMonitor : Use user provided ruleset for replicated pool

Reviewed-by: Loic Dachary <loic-201408@dachary.org>
1  2 
doc/rados/operations/pools.rst
src/mon/OSDMonitor.cc

Simple merge
index 1d25671dbb5c907e09846f23d4b02652fb47b37b,15d2034b34afcf119e0dec1b468768b6a37068d5..dd729f064aa62b7868834e66e605a1396a376703
@@@ -5207,44 -5120,43 +5234,50 @@@ done
      cmd_getval(g_ceph_context, cmdmap, "ruleset", ruleset_name);
      string erasure_code_profile;
      cmd_getval(g_ceph_context, cmdmap, "erasure_code_profile", erasure_code_profile);
-     if (erasure_code_profile == "")
-       erasure_code_profile = "default";
-     if (erasure_code_profile == "default") {
-       if (!osdmap.has_erasure_code_profile(erasure_code_profile)) {
-       if (pending_inc.has_erasure_code_profile(erasure_code_profile)) {
-         dout(20) << "erasure code profile " << erasure_code_profile << " already pending" << dendl;
-         goto wait;
-       }
  
-       map<string,string> profile_map;
-       err = osdmap.get_erasure_code_profile_default(g_ceph_context,
+     if (pool_type == pg_pool_t::TYPE_ERASURE) {
+       if (erasure_code_profile == "")
+       erasure_code_profile = "default";
+       //handle the erasure code profile
+       if (erasure_code_profile == "default") {
+       if (!osdmap.has_erasure_code_profile(erasure_code_profile)) {
+         if (pending_inc.has_erasure_code_profile(erasure_code_profile)) {
+           dout(20) << "erasure code profile " << erasure_code_profile << " already pending" << dendl;
+           goto wait;
+         }
+         map<string,string> profile_map;
+         err = osdmap.get_erasure_code_profile_default(g_ceph_context,
                                                      profile_map,
                                                      &ss);
-       if (err)
-         goto reply;
-       dout(20) << "erasure code profile " << erasure_code_profile << " set" << dendl;
-       pending_inc.set_erasure_code_profile(erasure_code_profile, profile_map);
-       goto wait;
+         if (err)
+           goto reply;
+         dout(20) << "erasure code profile " << erasure_code_profile << " set" << dendl;
+         pending_inc.set_erasure_code_profile(erasure_code_profile, profile_map);
+         goto wait;
+       }
        }
-     }
-     if (ruleset_name == "") {
-       if (erasure_code_profile == "default") {
-       ruleset_name = "erasure-code";
-       } else {
-       dout(1) << "implicitly use ruleset named after the pool: "
+       if (ruleset_name == "") {
+       if (erasure_code_profile == "default") {
+         ruleset_name = "erasure-code";
+       } else {
+         dout(1) << "implicitly use ruleset named after the pool: "
                << poolstr << dendl;
-       ruleset_name = poolstr;
+         ruleset_name = poolstr;
+       }
        }
+     } else {
+       //NOTE:for replicated pool,cmd_map will put ruleset_name to erasure_code_profile field
+       ruleset_name = erasure_code_profile;
      }
  
 +    int64_t expected_num_objects;
 +    cmd_getval(g_ceph_context, cmdmap, "expected_num_objects", expected_num_objects, int64_t(0));
 +    if (expected_num_objects < 0) {
 +      ss << "'expected_num_objects' must be non-negative";
 +      err = -EINVAL;
 +      goto reply;
 +    }
      err = prepare_new_pool(poolstr, 0, // auid=0 for admin created pool
                           -1, // default crush rule
                           ruleset_name,