]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMap: de-globalize
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 20 Jun 2011 19:40:34 +0000 (12:40 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 20 Jun 2011 23:41:43 +0000 (16:41 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h
src/osdmaptool.cc

index a4a3e93ea61b2c54ae163931f3688bdf3fbf19b1..5c2da7c8548372f784ddb11d2eaa3aa51af2c200 100644 (file)
@@ -176,15 +176,15 @@ void OSDMap::print_summary(ostream& out) const
 }
 
 
-void OSDMap::build_simple(epoch_t e, ceph_fsid_t &fsid,
+void OSDMap::build_simple(CephContext *cct, epoch_t e, ceph_fsid_t &fsid,
                          int nosd, int ndom, int pg_bits, int pgp_bits, int lpg_bits)
 {
-  dout(10) << "build_simple on " << num_osd
+  ldout(cct, 10) << "build_simple on " << num_osd
           << " osds with " << pg_bits << " pg bits per osd, "
           << lpg_bits << " lpg bits" << dendl;
   epoch = e;
   set_fsid(fsid);
-  created = modified = ceph_clock_now(&g_ceph_context);
+  created = modified = ceph_clock_now(cct);
 
   set_max_osd(nosd);
 
@@ -201,7 +201,7 @@ void OSDMap::build_simple(epoch_t e, ceph_fsid_t &fsid,
   for (map<int,const char*>::iterator p = rulesets.begin(); p != rulesets.end(); p++) {
     int pool = ++pool_max;
     pools[pool].v.type = CEPH_PG_TYPE_REP;
-    pools[pool].v.size = g_conf->osd_pool_default_size;
+    pools[pool].v.size = cct->_conf->osd_pool_default_size;
     pools[pool].v.crush_ruleset = p->first;
     pools[pool].v.object_hash = CEPH_STR_HASH_RJENKINS;
     pools[pool].v.pg_num = nosd << pg_bits;
@@ -212,7 +212,7 @@ void OSDMap::build_simple(epoch_t e, ceph_fsid_t &fsid,
     pool_name[pool] = p->second;
   }
 
-  build_simple_crush_map(crush, rulesets, nosd, ndom);
+  build_simple_crush_map(cct, crush, rulesets, nosd, ndom);
 
   for (int i=0; i<nosd; i++) {
     set_state(i, 0);
@@ -220,8 +220,8 @@ void OSDMap::build_simple(epoch_t e, ceph_fsid_t &fsid,
   }
 }
 
-void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>& rulesets, int nosd,
-                                   int ndom)
+void OSDMap::build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
+       map<int, const char*>& rulesets, int nosd, int ndom)
 {
   // new
   crush.create();
@@ -230,11 +230,12 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
   crush.set_type_name(1, "domain");
   crush.set_type_name(2, "pool");
 
-  int minrep = g_conf->osd_min_rep;
-  int maxrep = g_conf->osd_max_rep;
+  const md_config_t *conf = cct->_conf;
+  int minrep = conf->osd_min_rep;
+  int maxrep = conf->osd_max_rep;
   assert(maxrep >= minrep);
   if (!ndom)
-    ndom = MAX(maxrep, g_conf->osd_max_raid_width);
+    ndom = MAX(maxrep, conf->osd_max_raid_width);
   if (ndom > 1 &&
       nosd >= ndom*3 &&
       nosd > 8) {
@@ -242,7 +243,7 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
     int rweights[ndom];
 
     int nper = ((nosd - 1) / ndom) + 1;
-    dout(0) << ndom << " failure domains, " << nper << " osds each" << dendl;
+    ldout(cct, 0) << ndom << " failure domains, " << nper << " osds each" << dendl;
     
     int o = 0;
     for (int i=0; i<ndom; i++) {
@@ -251,7 +252,7 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
       rweights[i] = 0;
       for (j=0; j<nper; j++, o++) {
        if (o == nosd) break;
-       dout(20) << "added osd" << o << dendl;
+       ldout(cct, 20) << "added osd" << o << dendl;
        items[j] = o;
        weights[j] = 0x10000;
        //w[j] = weights[o] ? (0x10000 - (int)(weights[o] * 0x10000)):0x10000;
@@ -261,7 +262,7 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
 
       crush_bucket *domain = crush_make_bucket(CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, 1, j, items, weights);
       ritems[i] = crush_add_bucket(crush.crush, 0, domain);
-      dout(20) << "added domain bucket i " << ritems[i] << " of size " << j << dendl;
+      ldout(cct, 20) << "added domain bucket i " << ritems[i] << " of size " << j << dendl;
 
       char bname[10];
       snprintf(bname, sizeof(bname), "dom%d", i);
@@ -301,7 +302,7 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
     // replication
     for (map<int,const char*>::iterator p = rulesets.begin(); p != rulesets.end(); p++) {
       int ruleset = p->first;
-      crush_rule *rule = crush_make_rule(3, ruleset, CEPH_PG_TYPE_REP, g_conf->osd_min_rep, maxrep);
+      crush_rule *rule = crush_make_rule(3, ruleset, CEPH_PG_TYPE_REP, conf->osd_min_rep, maxrep);
       crush_rule_set_step(rule, 0, CRUSH_RULE_TAKE, rootid, 0);
       crush_rule_set_step(rule, 1, CRUSH_RULE_CHOOSE_FIRSTN, CRUSH_CHOOSE_N, 0);
       crush_rule_set_step(rule, 2, CRUSH_RULE_EMIT, 0, 0);
@@ -313,6 +314,6 @@ void OSDMap::build_simple_crush_map(CrushWrapper& crush, map<int, const char*>&
 
   crush.finalize();
 
-  dout(20) << "crush max_devices " << crush.crush->max_devices << dendl;
+  ldout(cct, 20) << "crush max_devices " << crush.crush->max_devices << dendl;
 }
 
index 8fff588a7b8303779d614b35eee4896e70addd18..8461952c8e4f93b158ac46e4c717e44d89dfc958 100644 (file)
@@ -1033,10 +1033,11 @@ public:
   /*
    * handy helpers to build simple maps...
    */
-  void build_simple(epoch_t e, ceph_fsid_t &fsid,
+  void build_simple(CephContext *cct, epoch_t e, ceph_fsid_t &fsid,
                    int num_osd, int num_dom,
                    int pg_bits, int pgp_bits, int lpg_bits);
-  static void build_simple_crush_map(CrushWrapper& crush, map<int, const char*>& poolsets, int num_osd, int num_dom=0);
+  static void build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
+               map<int, const char*>& poolsets, int num_osd, int num_dom=0);
 
 private:
   void print_osd_line(int cur, ostream& out) const;
index 24288a4ed534335d0c4a291379dd701927510def..76a20c20247615fd5cc3b9da11c145058211439d 100644 (file)
@@ -148,7 +148,7 @@ int main(int argc, const char **argv)
     }
     ceph_fsid_t fsid;
     memset(&fsid, 0, sizeof(ceph_fsid_t));
-    osdmap.build_simple(0, fsid, num_osd, num_dom, pg_bits, pgp_bits, lpg_bits);
+    osdmap.build_simple(&g_ceph_context, 0, fsid, num_osd, num_dom, pg_bits, pgp_bits, lpg_bits);
     modified = true;
   }