From: Sage Weil Date: Fri, 8 Mar 2019 23:23:29 +0000 (-0600) Subject: crush/CrushWrapper: pass cct down into more places X-Git-Tag: v15.0.0~144^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96968487b48c38eb396ff97df4e78cb1df5212ff;p=ceph.git crush/CrushWrapper: pass cct down into more places Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index fa6a1ff4a803..4a442abb6f49 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -367,11 +367,11 @@ bool CrushWrapper::_maybe_remove_last_instance(CephContext *cct, int item, bool class_remove_item(item); } } - rebuild_roots_with_classes(); + rebuild_roots_with_classes(cct); return true; } -int CrushWrapper::remove_root(int item) +int CrushWrapper::remove_root(CephContext *cct, int item) { crush_bucket *b = get_bucket(item); if (IS_ERR(b)) { @@ -387,7 +387,7 @@ int CrushWrapper::remove_root(int item) for (unsigned n = 0; n < b->size; n++) { if (b->items[n] >= 0) continue; - int r = remove_root(b->items[n]); + int r = remove_root(cct, b->items[n]); if (r < 0) return r; } @@ -400,7 +400,7 @@ int CrushWrapper::remove_root(int item) if (class_bucket.count(item) != 0) class_bucket.erase(item); class_remove_item(item); - update_choose_args(nullptr); + update_choose_args(cct); return 0; } @@ -1161,7 +1161,7 @@ int CrushWrapper::insert_item( ldout(cct, 5) << "insert_item max_devices now " << crush->max_devices << dendl; } - r = rebuild_roots_with_classes(); + r = rebuild_roots_with_classes(cct); if (r < 0) { ldout(cct, 0) << __func__ << " unable to rebuild roots with classes: " << cpp_strerror(r) << dendl; @@ -1307,7 +1307,7 @@ int CrushWrapper::swap_bucket(CephContext *cct, int src, int dst) // swap names swap_names(src, dst); - return rebuild_roots_with_classes(); + return rebuild_roots_with_classes(cct); } int CrushWrapper::link_bucket( @@ -1723,14 +1723,14 @@ int CrushWrapper::populate_classes( return 0; } -int CrushWrapper::trim_roots_with_class() +int CrushWrapper::trim_roots_with_class(CephContext *cct) { set roots; find_shadow_roots(&roots); for (auto &r : roots) { if (r >= 0) continue; - int res = remove_root(r); + int res = remove_root(cct, r); if (res) return res; } @@ -1900,7 +1900,7 @@ int CrushWrapper::reclassify( } } - int r = rebuild_roots_with_classes(); + int r = rebuild_roots_with_classes(cct); if (r < 0) { out << "failed to rebuild_roots_with_classes: " << cpp_strerror(r) << std::endl; @@ -2075,7 +2075,7 @@ int CrushWrapper::reclassify( name_map[i.first] = i.second; } - int r = rebuild_roots_with_classes(); + int r = rebuild_roots_with_classes(cct); if (r < 0) { out << "failed to rebuild_roots_with_classes: " << cpp_strerror(r) << std::endl; @@ -2127,7 +2127,7 @@ void CrushWrapper::reweight(CephContext *cct) reweight_bucket(b, i.second, &w); } } - int r = rebuild_roots_with_classes(); + int r = rebuild_roots_with_classes(cct); ceph_assert(r == 0); } @@ -2369,7 +2369,7 @@ int CrushWrapper::remove_rule(int ruleno) crush->rules[ruleno] = NULL; rule_name_map.erase(ruleno); have_rmaps = false; - return rebuild_roots_with_classes(); + return rebuild_roots_with_classes(nullptr); } int CrushWrapper::bucket_adjust_item_weight(CephContext *cct, crush_bucket *bucket, int item, int weight) @@ -2556,7 +2556,7 @@ int CrushWrapper::update_device_class(int id, set_item_class(id, class_id); - int r = rebuild_roots_with_classes(); + int r = rebuild_roots_with_classes(nullptr); if (r < 0) return r; return 1; @@ -2578,7 +2578,7 @@ int CrushWrapper::remove_device_class(CephContext *cct, int id, ostream *ss) } class_remove_item(id); - int r = rebuild_roots_with_classes(); + int r = rebuild_roots_with_classes(cct); if (r < 0) { *ss << "unable to rebuild roots with class '" << class_name << "' " << "of osd." << id << ": " << cpp_strerror(r); @@ -2824,11 +2824,11 @@ void CrushWrapper::cleanup_dead_classes() } } -int CrushWrapper::rebuild_roots_with_classes() +int CrushWrapper::rebuild_roots_with_classes(CephContext *cct) { std::map > old_class_bucket = class_bucket; cleanup_dead_classes(); - int r = trim_roots_with_class(); + int r = trim_roots_with_class(cct); if (r < 0) return r; class_bucket.clear(); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 9e070419b970..89cbb4e4ba9f 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -887,7 +887,7 @@ public: * @param item id to remove * @return 0 on success, negative on error */ - int remove_root(int item); + int remove_root(CephContext *cct, int item); /** * remove all instances of an item nested beneath a certain point from the map @@ -1313,9 +1313,9 @@ public: int get_rules_by_osd(int osd, set *rules); bool _class_is_dead(int class_id); void cleanup_dead_classes(); - int rebuild_roots_with_classes(); + int rebuild_roots_with_classes(CephContext *cct); /* remove unused roots generated for class devices */ - int trim_roots_with_class(); + int trim_roots_with_class(CephContext *cct); int reclassify( CephContext *cct, diff --git a/src/test/crush/CrushWrapper.cc b/src/test/crush/CrushWrapper.cc index cffd20702990..575af8a01dd4 100644 --- a/src/test/crush/CrushWrapper.cc +++ b/src/test/crush/CrushWrapper.cc @@ -1090,7 +1090,7 @@ TEST(CrushWrapper, remove_root) { ASSERT_TRUE(c.name_exists("default")); ASSERT_TRUE(c.name_exists("r11")); ASSERT_TRUE(c.name_exists("r12")); - ASSERT_EQ(c.remove_root(c.get_item_id("default")), 0); + ASSERT_EQ(c.remove_root(g_ceph_context, c.get_item_id("default")), 0); ASSERT_FALSE(c.name_exists("default")); ASSERT_FALSE(c.name_exists("r11")); ASSERT_FALSE(c.name_exists("r12")); @@ -1122,7 +1122,7 @@ TEST(CrushWrapper, trim_roots_with_class) { ASSERT_TRUE(c.name_exists("default")); ASSERT_TRUE(c.name_exists("default~ssd")); - c.trim_roots_with_class(); + c.trim_roots_with_class(g_ceph_context); ASSERT_TRUE(c.name_exists("default")); ASSERT_FALSE(c.name_exists("default~ssd")); } diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index 918b341b5d9a..07b8b79a083a 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -1171,7 +1171,7 @@ int main(int argc, const char **argv) modified = true; } if (rebuild_class_roots) { - int r = crush.rebuild_roots_with_classes(); + int r = crush.rebuild_roots_with_classes(g_ceph_context); if (r < 0) { cerr << "failed to rebuidl roots with classes" << std::endl; return EXIT_FAILURE;