From 2649b27d13d364c6533d514b0d0df53fd6519551 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 7 Aug 2017 16:54:11 -0400 Subject: [PATCH] crush/CrushWrapper: remove unused 'unused' arg for trim_roots_with_classes Signed-off-by: Sage Weil --- src/crush/CrushWrapper.cc | 13 +++++-------- src/crush/CrushWrapper.h | 5 ++--- src/test/crush/CrushWrapper.cc | 12 ++++-------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index eb35ff7326ff5..06dfceb4ae248 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -364,11 +364,8 @@ bool CrushWrapper::_maybe_remove_last_instance(CephContext *cct, int item, bool return true; } -int CrushWrapper::remove_root(int item, bool unused) +int CrushWrapper::remove_root(int item) { - if (unused && _bucket_is_in_use(item)) - return 0; - crush_bucket *b = get_bucket(item); if (IS_ERR(b)) { // should be idempotent @@ -383,7 +380,7 @@ int CrushWrapper::remove_root(int item, bool unused) for (unsigned n = 0; n < b->size; n++) { if (b->items[n] >= 0) continue; - int r = remove_root(b->items[n], unused); + int r = remove_root(b->items[n]); if (r < 0) return r; } @@ -1426,14 +1423,14 @@ int CrushWrapper::populate_classes( return 0; } -int CrushWrapper::trim_roots_with_class(bool unused) +int CrushWrapper::trim_roots_with_class() { set roots; find_shadow_roots(roots); for (auto &r : roots) { if (r >= 0) continue; - int res = remove_root(r, unused); + int res = remove_root(r); if (res) return res; } @@ -1972,7 +1969,7 @@ int CrushWrapper::rebuild_roots_with_classes() { std::map > old_class_bucket = class_bucket; cleanup_dead_classes(); - int r = trim_roots_with_class(false); + int r = trim_roots_with_class(); if (r < 0) return r; class_bucket.clear(); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 3808db08062ca..a75495bcc283d 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -834,10 +834,9 @@ public: * when a bucket is in use. * * @param item id to remove - * @param unused true if only unused items should be removed * @return 0 on success, negative on error */ - int remove_root(int item, bool unused); + int remove_root(int item); /** * remove all instances of an item nested beneath a certain point from the map @@ -1221,7 +1220,7 @@ public: void cleanup_dead_classes(); int rebuild_roots_with_classes(); /* remove unused roots generated for class devices */ - int trim_roots_with_class(bool unused); + int trim_roots_with_class(); void start_choose_profile() { free(crush->choose_tries); diff --git a/src/test/crush/CrushWrapper.cc b/src/test/crush/CrushWrapper.cc index 4502d0d0e69b3..cf651eb2a9636 100644 --- a/src/test/crush/CrushWrapper.cc +++ b/src/test/crush/CrushWrapper.cc @@ -1061,7 +1061,7 @@ TEST(CrushWrapper, choose_args_compat) { } } -TEST(CrushWrapper, remove_unused_root) { +TEST(CrushWrapper, remove_root) { CrushWrapper c; c.create(); c.set_type_name(1, "host"); @@ -1087,9 +1087,9 @@ TEST(CrushWrapper, remove_unused_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"), true), 0); + ASSERT_EQ(c.remove_root(c.get_item_id("default")), 0); ASSERT_FALSE(c.name_exists("default")); - ASSERT_TRUE(c.name_exists("r11")); + ASSERT_FALSE(c.name_exists("r11")); ASSERT_FALSE(c.name_exists("r12")); } @@ -1118,11 +1118,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(true); // do nothing because still in use - ASSERT_TRUE(c.name_exists("default")); - ASSERT_TRUE(c.name_exists("default~ssd")); - c.class_bucket.clear(); - c.trim_roots_with_class(true); // do nothing because still in use + c.trim_roots_with_class(); ASSERT_TRUE(c.name_exists("default")); ASSERT_FALSE(c.name_exists("default~ssd")); } -- 2.39.5