]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: create default profile if necessary 1966/head
authorLoic Dachary <loic@dachary.org>
Sun, 15 Jun 2014 14:54:02 +0000 (16:54 +0200)
committerLoic Dachary <loic@dachary.org>
Sun, 15 Jun 2014 14:54:02 +0000 (16:54 +0200)
http://tracker.ceph.com/issues/8601

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

index 1f50f8c0ae971b0896dc9287d27138e350f9a043..54eb2f52ca5abc7d6a32c82094fcadae832fe898 100644 (file)
@@ -4184,8 +4184,23 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
     cmd_getval(g_ceph_context, cmdmap, "name", name);
     string profile;
     cmd_getval(g_ceph_context, cmdmap, "profile", profile);
-    if (profile == "")
+    if (profile == "") {
       profile = "default";
+      if (!osdmap.has_erasure_code_profile(profile)) {
+       if (pending_inc.has_erasure_code_profile(profile))
+         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 " << name << " set" << dendl;
+       pending_inc.set_erasure_code_profile(profile, profile_map);
+       goto wait;
+      }
+    }
 
     int ruleset;
     err = crush_ruleset_create_erasure(name, profile, &ruleset, ss);
index 8d2a346fb64b8a271aad869b40cdf6e4a062910c..79759d7d4c02bc9a677b85c61a8ccb3f4d862ff3 100644 (file)
@@ -2562,13 +2562,25 @@ int OSDMap::build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
     set_weight(i, CEPH_OSD_OUT);
   }
 
-  map<string,string> erasure_code_profile_map;
-  r = get_str_map(cct->_conf->osd_pool_default_erasure_code_profile,
-                 ss,
-                 &erasure_code_profile_map);
-  erasure_code_profile_map["directory"] =
+  map<string,string> profile_map;
+  r = get_erasure_code_profile_default(cct, profile_map, &ss);
+  if (r < 0) {
+    lderr(cct) << ss.str() << dendl;
+    return r;
+  }
+  set_erasure_code_profile("default", profile_map);
+  return 0;
+}
+
+int OSDMap::get_erasure_code_profile_default(CephContext *cct,
+                                            map<string,string> &profile_map,
+                                            ostream *ss)
+{
+  int r = get_str_map(cct->_conf->osd_pool_default_erasure_code_profile,
+                     *ss,
+                     &profile_map);
+  profile_map["directory"] =
     cct->_conf->osd_pool_default_erasure_code_directory;
-  set_erasure_code_profile("default", erasure_code_profile_map);
   return r;
 }
 
index fcb3e26d847ac076892bb02e9ddc9fa61a9d9c1d..f51d6c4f54e7bcc3515b5eb7902e08d62f8ef372 100644 (file)
@@ -381,6 +381,9 @@ public:
       erasure_code_profiles.find(name);
     return i != erasure_code_profiles.end();
   }
+  int get_erasure_code_profile_default(CephContext *cct,
+                                      map<string,string> &profile_map,
+                                      ostream *ss);
   void set_erasure_code_profile(const string &name,
                                const map<string,string> &profile) {
     erasure_code_profiles[name] = profile;
@@ -793,6 +796,8 @@ public:
    */
   int build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
                   int num_osd, int pg_bits, int pgp_bits);
+  int set_erasure_code_profile_default(CephContext *cct);
+
   static int _build_crush_types(CrushWrapper& crush);
   static int build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
                                    int num_osd, ostream *ss);