]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: add region, pdu, pod types while we are at it 841/head
authorSage Weil <sage@inktank.com>
Mon, 2 Dec 2013 16:31:23 +0000 (08:31 -0800)
committerSage Weil <sage@inktank.com>
Mon, 2 Dec 2013 16:31:23 +0000 (08:31 -0800)
One use noted that they have a 'pdu' type in their type hierarchy that
typically spans multiple racks.  Others are known to use the 'pod'
terminology; add that to.  And I can imagine 'region' above datacenter.

Factor this into a helper to make things a bit less fragile.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 472ceea1130000164b9448a7ee90aa1af4e3b293..48d21911111b355e4f8551b3971645fa349f2e6b 100644 (file)
@@ -1828,6 +1828,21 @@ void OSDMap::build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
   }
 }
 
+int OSDMap::_build_crush_types(CrushWrapper& crush)
+{
+  crush.set_type_name(0, "osd");
+  crush.set_type_name(1, "host");
+  crush.set_type_name(2, "chassis");
+  crush.set_type_name(3, "rack");
+  crush.set_type_name(4, "row");
+  crush.set_type_naem(5, "pdu");
+  crush.set_type_naem(6, "pod");
+  crush.set_type_name(7, "room");
+  crush.set_type_name(8, "datacenter");
+  crush.set_type_name(9, "region");
+  crush.set_type_name(10, "root");
+  return 10;
+}
 
 void OSDMap::build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
                                    map<int, const char*>& rulesets, int nosd)
@@ -1836,19 +1851,11 @@ void OSDMap::build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
 
   crush.create();
 
-  crush.set_type_name(0, "osd");
-  crush.set_type_name(1, "host");
-  crush.set_type_name(2, "chassis");
-  crush.set_type_name(3, "rack");
-  crush.set_type_name(4, "row");
-  crush.set_type_name(5, "room");
-  crush.set_type_name(6, "datacenter");
-  crush.set_type_name(7, "root");
-
   // root
+  int root_type = _build_crush_types(crush);
   int rootid;
   int r = crush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT,
-                          7 /* root */, 0, NULL, NULL, &rootid);
+                          root_type, 0, NULL, NULL, &rootid);
   assert(r == 0);
   crush.set_item_name(rootid, "default");
 
@@ -1968,21 +1975,13 @@ void OSDMap::build_simple_crush_map_from_conf(CephContext *cct, CrushWrapper& cr
 
   crush.create();
 
-  crush.set_type_name(0, "osd");
-  crush.set_type_name(1, "host");
-  crush.set_type_name(2, "chassis");
-  crush.set_type_name(3, "rack");
-  crush.set_type_name(4, "row");
-  crush.set_type_name(5, "room");
-  crush.set_type_name(6, "datacenter");
-  crush.set_type_name(7, "root");
-
   set<string> hosts, racks;
 
   // root
+  int root_type = _build_crush_types(crush);
   int rootid;
   int r = crush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT,
-                          7 /* root */, 0, NULL, NULL, &rootid);
+                          root_type, 0, NULL, NULL, &rootid);
   assert(r == 0);
   crush.set_item_name(rootid, "default");
 
index bd8f09b682e315849d06d9e729fc153e125f8a02..105c979453e580a740a742ac4bcc02dfb645416d 100644 (file)
@@ -596,6 +596,8 @@ public:
   /*
    * handy helpers to build simple maps...
    */
+  /// build crush bucket types.  @return 'root' type id
+  int _build_crush_types(CrushWrapper& crush);
   void build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
                    int num_osd, int pg_bits, int pgp_bits);
   int build_simple_from_conf(CephContext *cct, epoch_t e, uuid_d &fsid,