From 6298a576d353ee389f5e1176a42990927ea6025c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 2 Dec 2013 08:31:23 -0800 Subject: [PATCH] osd/OSDMap: add region, pdu, pod types while we are at it 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 --- src/osd/OSDMap.cc | 39 +++++++++++++++++++-------------------- src/osd/OSDMap.h | 2 ++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 472ceea113000..48d21911111b3 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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& 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 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"); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index bd8f09b682e31..105c979453e58 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -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, -- 2.39.5