From b9bd482d7e2f1824af41ce40345cddf15423b9ce Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Jan 2013 00:50:33 -0800 Subject: [PATCH] crush: remove_rule() method Signed-off-by: Sage Weil --- src/crush/CrushWrapper.cc | 13 +++++++++++++ src/crush/CrushWrapper.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index bae264245f7..bb60d5b3ca8 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -530,6 +530,19 @@ int CrushWrapper::add_simple_rule(string name, string root_name, string failure_ return rno; } +int CrushWrapper::remove_rule(int ruleno) +{ + if (ruleno >= (int)crush->max_rules) + return -ENOENT; + if (crush->rules[ruleno] == NULL) + return -ENOENT; + crush_destroy_rule(crush->rules[ruleno]); + crush->rules[ruleno] = NULL; + rule_name_map.erase(ruleno); + have_rmaps = false; + return 0; +} + void CrushWrapper::encode(bufferlist& bl, bool lean) const { assert(crush); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index df2c620a82e..8bd43f0d925 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -532,6 +532,8 @@ public: int add_simple_rule(string name, string root_name, string failure_domain_type); + int remove_rule(int ruleno); + /** buckets **/ private: -- 2.47.3