mirror of
https://github.com/ceph/ceph
synced 2025-01-18 09:02:08 +00:00
crush: CrushWrapper s/remove_unused_root/remove_root/
The unused argument allows removal of class buckets that are in use. Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
parent
b7c9f788d8
commit
ea1fdc824a
@ -259,9 +259,9 @@ bool CrushWrapper::_maybe_remove_last_instance(CephContext *cct, int item, bool
|
||||
return true;
|
||||
}
|
||||
|
||||
int CrushWrapper::remove_unused_root(int item)
|
||||
int CrushWrapper::remove_root(int item, bool unused)
|
||||
{
|
||||
if (_bucket_is_in_use(item))
|
||||
if (unused && _bucket_is_in_use(item))
|
||||
return 0;
|
||||
|
||||
crush_bucket *b = get_bucket(item);
|
||||
@ -271,7 +271,7 @@ int CrushWrapper::remove_unused_root(int item)
|
||||
for (unsigned n = 0; n < b->size; n++) {
|
||||
if (b->items[n] >= 0)
|
||||
continue;
|
||||
int r = remove_unused_root(b->items[n]);
|
||||
int r = remove_root(b->items[n], unused);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@ -1035,10 +1035,10 @@ int CrushWrapper::populate_classes()
|
||||
|
||||
int CrushWrapper::cleanup_classes()
|
||||
{
|
||||
return trim_roots_with_class();
|
||||
return trim_roots_with_class(true);
|
||||
}
|
||||
|
||||
int CrushWrapper::trim_roots_with_class()
|
||||
int CrushWrapper::trim_roots_with_class(bool unused)
|
||||
{
|
||||
set<int> roots;
|
||||
find_roots(roots);
|
||||
@ -1047,7 +1047,7 @@ int CrushWrapper::trim_roots_with_class()
|
||||
continue;
|
||||
if (!id_has_class(r))
|
||||
continue;
|
||||
int res = remove_unused_root(r);
|
||||
int res = remove_root(r, unused);
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
|
@ -691,9 +691,10 @@ 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_unused_root(int item);
|
||||
int remove_root(int item, bool unused);
|
||||
|
||||
/**
|
||||
* remove all instances of an item nested beneath a certain point from the map
|
||||
@ -1091,7 +1092,7 @@ public:
|
||||
int device_class_clone(int original, int device_class, int *clone);
|
||||
int populate_classes();
|
||||
/* remove unused roots generated for class devices */
|
||||
int trim_roots_with_class();
|
||||
int trim_roots_with_class(bool unused);
|
||||
int cleanup_classes();
|
||||
|
||||
void start_choose_profile() {
|
||||
|
@ -966,7 +966,7 @@ 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_unused_root(c.get_item_id("default")), 0);
|
||||
ASSERT_EQ(c.remove_root(c.get_item_id("default"), true), 0);
|
||||
ASSERT_FALSE(c.name_exists("default"));
|
||||
ASSERT_TRUE(c.name_exists("r11"));
|
||||
ASSERT_FALSE(c.name_exists("r12"));
|
||||
@ -993,11 +993,11 @@ TEST(CrushWrapper, trim_roots_with_class) {
|
||||
|
||||
ASSERT_TRUE(c.name_exists("default"));
|
||||
ASSERT_TRUE(c.name_exists("default~ssd"));
|
||||
c.trim_roots_with_class(); // do nothing because still in use
|
||||
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(); // do nothing because still in use
|
||||
c.trim_roots_with_class(true); // do nothing because still in use
|
||||
ASSERT_TRUE(c.name_exists("default"));
|
||||
ASSERT_FALSE(c.name_exists("default~ssd"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user