print_rule_name(out, i, crush);
out << " {\n";
out << "\tid " << i << "\n";
- if (i != crush.get_rule_mask_ruleset(i)) {
- out << "\t# WARNING: ruleset " << crush.get_rule_mask_ruleset(i) << " != id " << i << "; this will not recompile to the same map\n";
- }
- switch (crush.get_rule_mask_type(i)) {
+ switch (crush.get_rule_type(i)) {
case CEPH_PG_TYPE_REPLICATED:
out << "\ttype replicated\n";
break;
out << "\ttype erasure\n";
break;
default:
- out << "\ttype " << crush.get_rule_mask_type(i) << "\n";
+ out << "\ttype " << crush.get_rule_type(i) << "\n";
}
out << "\tmin_size " << crush.get_rule_mask_min_size(i) << "\n";
return true;
}
-static string get_rule_name(CrushWrapper& crush, int rule)
-{
- if (crush.get_rule_name(rule))
- return crush.get_rule_name(rule);
- else
- return string("rule") + std::to_string(rule);
-}
-
int CrushTester::test()
{
if (min_rule < 0 || max_rule < 0) {
using ceph::encode;
using ceph::Formatter;
-bool CrushWrapper::has_legacy_rule_ids() const
-{
- for (unsigned i=0; i<crush->max_rules; i++) {
- crush_rule *r = crush->rules[i];
- if (r &&
- r->mask.ruleset != i) {
- return true;
- }
- }
- return false;
-}
-
-std::map<int, int> CrushWrapper::renumber_rules()
-{
- std::map<int, int> result;
- for (unsigned i=0; i<crush->max_rules; i++) {
- crush_rule *r = crush->rules[i];
- if (r && r->mask.ruleset != i) {
- result[r->mask.ruleset] = i;
- r->mask.ruleset = i;
- }
- }
- return result;
-}
-
bool CrushWrapper::has_non_straw2_buckets() const
{
for (int i=0; i<crush->max_buckets; ++i) {
*err << "rule with ruleno " << rno << " exists";
return -EEXIST;
}
- if (ruleset_exists(rno)) {
- if (err)
- *err << "ruleset " << rno << " exists";
- return -EEXIST;
- }
} else {
for (rno = 0; rno < get_max_rules(); rno++) {
- if (!rule_exists(rno) && !ruleset_exists(rno))
+ if (!rule_exists(rno))
break;
}
}
steps = 5;
int min_rep = mode == "firstn" ? 1 : 3;
int max_rep = mode == "firstn" ? 10 : 20;
- //set the ruleset the same as rule_id(rno)
crush_rule *rule = crush_make_rule(steps, rno, rule_type, min_rep, max_rep);
ceph_assert(rule);
int step = 0;
}
}
-void CrushWrapper::dump_rule(int ruleset, Formatter *f) const
+void CrushWrapper::dump_rule(int rule_id, Formatter *f) const
{
f->open_object_section("rule");
- f->dump_int("rule_id", ruleset);
- if (get_rule_name(ruleset))
- f->dump_string("rule_name", get_rule_name(ruleset));
- f->dump_int("ruleset", get_rule_mask_ruleset(ruleset));
- f->dump_int("type", get_rule_mask_type(ruleset));
- f->dump_int("min_size", get_rule_mask_min_size(ruleset));
- f->dump_int("max_size", get_rule_mask_max_size(ruleset));
+ f->dump_int("rule_id", rule_id);
+ if (get_rule_name(rule_id))
+ f->dump_string("rule_name", get_rule_name(rule_id));
+ f->dump_int("type", get_rule_type(rule_id));
+ f->dump_int("min_size", get_rule_mask_min_size(rule_id));
+ f->dump_int("max_size", get_rule_mask_max_size(rule_id));
f->open_array_section("steps");
- for (int j=0; j<get_rule_len(ruleset); j++) {
+ for (int j=0; j<get_rule_len(rule_id); j++) {
f->open_object_section("step");
- switch (get_rule_op(ruleset, j)) {
+ switch (get_rule_op(rule_id, j)) {
case CRUSH_RULE_NOOP:
f->dump_string("op", "noop");
break;
case CRUSH_RULE_TAKE:
f->dump_string("op", "take");
{
- int item = get_rule_arg1(ruleset, j);
+ int item = get_rule_arg1(rule_id, j);
f->dump_int("item", item);
const char *name = get_item_name(item);
break;
case CRUSH_RULE_CHOOSE_FIRSTN:
f->dump_string("op", "choose_firstn");
- f->dump_int("num", get_rule_arg1(ruleset, j));
- f->dump_string("type", get_type_name(get_rule_arg2(ruleset, j)));
+ f->dump_int("num", get_rule_arg1(rule_id, j));
+ f->dump_string("type", get_type_name(get_rule_arg2(rule_id, j)));
break;
case CRUSH_RULE_CHOOSE_INDEP:
f->dump_string("op", "choose_indep");
- f->dump_int("num", get_rule_arg1(ruleset, j));
- f->dump_string("type", get_type_name(get_rule_arg2(ruleset, j)));
+ f->dump_int("num", get_rule_arg1(rule_id, j));
+ f->dump_string("type", get_type_name(get_rule_arg2(rule_id, j)));
break;
case CRUSH_RULE_CHOOSELEAF_FIRSTN:
f->dump_string("op", "chooseleaf_firstn");
- f->dump_int("num", get_rule_arg1(ruleset, j));
- f->dump_string("type", get_type_name(get_rule_arg2(ruleset, j)));
+ f->dump_int("num", get_rule_arg1(rule_id, j));
+ f->dump_string("type", get_type_name(get_rule_arg2(rule_id, j)));
break;
case CRUSH_RULE_CHOOSELEAF_INDEP:
f->dump_string("op", "chooseleaf_indep");
- f->dump_int("num", get_rule_arg1(ruleset, j));
- f->dump_string("type", get_type_name(get_rule_arg2(ruleset, j)));
+ f->dump_int("num", get_rule_arg1(rule_id, j));
+ f->dump_string("type", get_type_name(get_rule_arg2(rule_id, j)));
break;
case CRUSH_RULE_SET_CHOOSE_TRIES:
f->dump_string("op", "set_choose_tries");
- f->dump_int("num", get_rule_arg1(ruleset, j));
+ f->dump_int("num", get_rule_arg1(rule_id, j));
break;
case CRUSH_RULE_SET_CHOOSELEAF_TRIES:
f->dump_string("op", "set_chooseleaf_tries");
- f->dump_int("num", get_rule_arg1(ruleset, j));
+ f->dump_int("num", get_rule_arg1(rule_id, j));
break;
default:
- f->dump_int("opcode", get_rule_op(ruleset, j));
- f->dump_int("arg1", get_rule_arg1(ruleset, j));
- f->dump_int("arg2", get_rule_arg2(ruleset, j));
+ f->dump_int("opcode", get_rule_op(rule_id, j));
+ f->dump_int("arg1", get_rule_arg1(rule_id, j));
+ f->dump_int("arg2", get_rule_arg2(rule_id, j));
}
f->close_section();
}
if (crush_rule < 0) {
crush_rule = find_first_rule(pg_pool_t::TYPE_REPLICATED);
} else if (!rule_exists(crush_rule)) {
- crush_rule = -1; // match find_first_ruleset() retval
+ crush_rule = -1; // match find_first_rule() retval
}
return crush_rule;
}
private:
struct crush_map *crush = nullptr;
- bool have_uniform_rules = false;
-
/* reverse maps */
mutable bool have_rmaps = false;
mutable std::map<std::string, int> type_rmap, name_rmap, rule_name_rmap;
set_tunables_default();
}
- /**
- * true if any rule has a rule id != its position in the array
- *
- * These indicate "ruleset" IDs that were created by older versions
- * of Ceph. They are cleaned up in renumber_rules so that eventually
- * we can remove the code for handling them.
- */
- bool has_legacy_rule_ids() const;
-
- /**
- * fix rules whose ruleid != ruleset
- *
- * These rules were created in older versions of Ceph. The concept
- * of a ruleset no longer exists.
- *
- * Return a map of old ID -> new ID. Caller must update OSDMap
- * to use new IDs.
- */
- std::map<int, int> renumber_rules();
-
/// true if any buckets that aren't straw2
bool has_non_straw2_buckets() const;
if (IS_ERR(r)) return PTR_ERR(r);
return r->len;
}
- int get_rule_mask_ruleset(unsigned ruleno) const {
- crush_rule *r = get_rule(ruleno);
- if (IS_ERR(r)) return -1;
- return r->mask.ruleset;
- }
- int get_rule_mask_type(unsigned ruleno) const {
+ int get_rule_type(unsigned ruleno) const {
crush_rule *r = get_rule(ruleno);
if (IS_ERR(r)) return -1;
return r->mask.type;
name_map.rbegin()->first >= crush->max_devices) {
crush->max_devices = name_map.rbegin()->first + 1;
}
- have_uniform_rules = !has_legacy_rule_ids();
build_rmaps();
}
int bucket_set_alg(int id, int alg);
crush->max_devices = m;
}
- bool ruleset_exists(const int ruleset) const {
- for (size_t i = 0; i < crush->max_rules; ++i) {
- if (rule_exists(i) && crush->rules[i]->mask.ruleset == ruleset) {
- return true;
- }
- }
-
- return false;
- }
-
/**
- * Return the lowest numbered ruleset of type `type`
+ * Return the lowest numbered rule of type `type`
*
- * @returns a ruleset ID, or -1 if no matching rules found.
+ * @returns a rule ID, or -1 if no matching rules found.
*/
- int find_first_ruleset(int type) const {
- int result = -1;
-
+ int find_first_rule(int type) const {
for (size_t i = 0; i < crush->max_rules; ++i) {
if (crush->rules[i]
- && crush->rules[i]->mask.type == type
- && (crush->rules[i]->mask.ruleset < result || result == -1)) {
- result = crush->rules[i]->mask.ruleset;
+ && crush->rules[i]->mask.type == type) {
+ return i;
}
}
-
- return result;
+ return -1;
}
bool have_choose_args(int64_t choose_args_index) const {
const std::vector<int>& orig,
std::vector<int> *out) const;
- bool check_crush_rule(int ruleset, int type, int size, std::ostream& ss) {
- ceph_assert(crush);
-
- __u32 i;
- for (i = 0; i < crush->max_rules; i++) {
- if (crush->rules[i] &&
- crush->rules[i]->mask.ruleset == ruleset &&
- crush->rules[i]->mask.type == type) {
-
- if (crush->rules[i]->mask.min_size <= size &&
- crush->rules[i]->mask.max_size >= size) {
- return true;
- } else if (size < crush->rules[i]->mask.min_size) {
- ss << "pool size is smaller than the crush rule min size";
- return false;
- } else {
- ss << "pool size is bigger than the crush rule max size";
- return false;
- }
- }
- }
-
- return false;
- }
-
void encode(ceph::buffer::list &bl, uint64_t features) const;
void decode(ceph::buffer::list::const_iterator &blp);
void decode_crush_bucket(crush_bucket** bptr,
ceph::buffer::list::const_iterator &blp);
void dump(ceph::Formatter *f) const;
void dump_rules(ceph::Formatter *f) const;
- void dump_rule(int ruleset, ceph::Formatter *f) const;
+ void dump_rule(int rule, ceph::Formatter *f) const;
void dump_tunables(ceph::Formatter *f) const;
void dump_choose_args(ceph::Formatter *f) const;
void list_rules(ceph::Formatter *f) const;
return r;
}
-struct crush_rule *crush_make_rule(int len, int ruleset, int type, int minsize, int maxsize)
+struct crush_rule *crush_make_rule(int len, int ruleid, int type, int minsize, int maxsize)
{
struct crush_rule *rule;
rule = malloc(crush_rule_size(len));
if (!rule)
return NULL;
rule->len = len;
- rule->mask.ruleset = ruleset;
+ rule->mask.ruleset = ruleid; // these always match now
rule->mask.type = type;
rule->mask.min_size = minsize;
rule->mask.max_size = maxsize;
/** @ingroup API
*
* Allocate an empty crush_rule structure large enough to store __len__ steps.
- * Steps can be added to a rule via crush_rule_set_step(). The __ruleset__
- * is a user defined integer, not used by __libcrush__ and stored in
- * the allocated rule at __rule->mask.ruleset__.
+ * Steps can be added to a rule via crush_rule_set_step().
*
* The rule is designed to allow crush_do_rule() to get at least __minsize__ items
* and at most __maxsize__ items.
* If __malloc(3)__ fails, return NULL.
*
* @param len number of steps in the rule
- * @param ruleset user defined value
+ * @param ruleid user defined value
* @param type user defined value
* @param minsize minimum number of items the rule can map
* @param maxsize maximum number of items the rule can map
*
* @returns a pointer to the newly created rule or NULL
*/
-extern struct crush_rule *crush_make_rule(int len, int ruleset, int type, int minsize, int maxsize);
+extern struct crush_rule *crush_make_rule(int len, int ruleid, int type, int minsize, int maxsize);
/** @ingroup API
*
* Set the __pos__ step of the __rule__ to an operand and up to two arguments.
#define CRUSH_MAGIC 0x00010000ul /* for detecting algorithm revisions */
#define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */
-#define CRUSH_MAX_RULESET (1<<8) /* max crush ruleset number */
-#define CRUSH_MAX_RULES CRUSH_MAX_RULESET /* should be the same as max rulesets */
+#define CRUSH_MAX_RULES (1<<8) /* max crush rule id */
#define CRUSH_MAX_DEVICE_WEIGHT (100u * 0x10000u)
#define CRUSH_MAX_BUCKET_WEIGHT (65535u * 0x10000u)
* rule list for a matching rule_mask.
*/
struct crush_rule_mask {
- __u8 ruleset;
+ __u8 ruleset; /* always matches rule_id now */
__u8 type;
__u8 min_size;
__u8 max_size;
/* object -> pg layout */
__le32 fl_unused; /* unused; used to be preferred primary for pg (-1 for none) */
- __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
+ __le32 fl_pg_pool; /* namespace, crush rule, rep level */
} __attribute__ ((packed));
#define CEPH_MIN_STRIPE_UNIT 65536
/* object -> pg layout */
uint32_t fl_pg_preferred; /* preferred primary for pg (-1 for none) */
- uint32_t fl_pg_pool; /* namespace, crush ruleset, rep level */
+ uint32_t fl_pg_pool; /* namespace, crush rule, rep level */
} __attribute__ ((packed));
struct CephContext;
/*
-1 was set as the default value and monitor will pickup the right crush rule with below order:
- a) osd pool default crush replicated ruleset
- b) the first ruleset in crush ruleset
+ a) osd pool default crush replicated rule
+ b) the first rule
c) error out if no value find
*/
int pool_create(string& name, int16_t crush_rule=-1);
# (Default: 8)
;osd pool default pgp num = 128
- # The default CRUSH ruleset to use when creating a pool
+ # The default CRUSH rule to use when creating a pool
# Type: 32-bit Integer
# (Default: 0)
;osd pool default crush rule = 0
{
"rule_id": 3,
"rule_name": "data",
- "ruleset": 3,
"type": 1,
"min_size": 2,
"max_size": 2,
profile["k"] = "2";
profile["m"] = "2";
EXPECT_EQ(0, clay.init(profile, &cerr));
- int ruleset = clay.create_rule("myrule", *c, &ss);
- EXPECT_EQ(0, ruleset);
+ int ruleid = clay.create_rule("myrule", *c, &ss);
+ EXPECT_EQ(0, ruleid);
EXPECT_EQ(-EEXIST, clay.create_rule("myrule", *c, &ss));
//
- // the minimum that is expected from the created ruleset is to
+ // the minimum that is expected from the created rule is to
// successfully map get_chunk_count() devices from the crushmap,
// at least once.
//
vector<__u32> weight(c->get_max_devices(), 0x10000);
vector<int> out;
int x = 0;
- c->do_rule(ruleset, x, out, clay.get_chunk_count(), weight, 0);
+ c->do_rule(ruleid, x, out, clay.get_chunk_count(), weight, 0);
ASSERT_EQ(out.size(), clay.get_chunk_count());
for (unsigned i=0; i<out.size(); ++i)
ASSERT_NE(CRUSH_ITEM_NONE, out[i]);
profile["m"] = "2";
profile["w"] = "8";
isa.init(profile, &cerr);
- int ruleset = isa.create_rule("myrule", *c, &ss);
- EXPECT_EQ(0, ruleset);
+ int rule = isa.create_rule("myrule", *c, &ss);
+ EXPECT_EQ(0, rule);
EXPECT_EQ(-EEXIST, isa.create_rule("myrule", *c, &ss));
//
- // the minimum that is expected from the created ruleset is to
+ // the minimum that is expected from the created rule is to
// successfully map get_chunk_count() devices from the crushmap,
// at least once.
//
vector<__u32> weight(c->get_max_devices(), 0x10000);
vector<int> out;
int x = 0;
- c->do_rule(ruleset, x, out, isa.get_chunk_count(), weight, 0);
+ c->do_rule(rule, x, out, isa.get_chunk_count(), weight, 0);
ASSERT_EQ(out.size(), isa.get_chunk_count());
for (unsigned i=0; i<out.size(); ++i)
ASSERT_NE(CRUSH_ITEM_NONE, out[i]);
profile["m"] = "2";
profile["w"] = "8";
jerasure.init(profile, &cerr);
- int ruleset = jerasure.create_rule("myrule", *c, &ss);
- EXPECT_EQ(0, ruleset);
+ int rule = jerasure.create_rule("myrule", *c, &ss);
+ EXPECT_EQ(0, rule);
EXPECT_EQ(-EEXIST, jerasure.create_rule("myrule", *c, &ss));
//
- // the minimum that is expected from the created ruleset is to
+ // the minimum that is expected from the created rule is to
// successfully map get_chunk_count() devices from the crushmap,
// at least once.
//
vector<__u32> weight(c->get_max_devices(), 0x10000);
vector<int> out;
int x = 0;
- c->do_rule(ruleset, x, out, jerasure.get_chunk_count(), weight, 0);
+ c->do_rule(rule, x, out, jerasure.get_chunk_count(), weight, 0);
ASSERT_EQ(out.size(), jerasure.get_chunk_count());
for (unsigned i=0; i<out.size(); ++i)
ASSERT_NE(CRUSH_ITEM_NONE, out[i]);
TEST(ErasureCodeShec, create_rule_1_2)
{
- //create ruleset
+ //create rule
CrushWrapper *crush = new CrushWrapper;
crush->create();
crush->set_type_name(2, "root");
TEST(ErasureCodeShec, create_rule_4)
{
- //create ruleset
+ //create rule
CrushWrapper *crush = new CrushWrapper;
crush->create();
crush->set_type_name(2, "root");
TEST(ErasureCodeShec, create_rule2_1)
{
- //create ruleset
+ //create rule
CrushWrapper *crush = new CrushWrapper;
crush->create();
crush->set_type_name(2, "root");
TEST(ErasureCodeShec, create_rule2_3)
{
- //create ruleset
+ //create rule
CrushWrapper *crush = new CrushWrapper;
crush->create();
crush->set_type_name(2, "root");
return ret;
}
-int destroy_ruleset(rados_t *cluster,
- const std::string &ruleset,
- std::ostream &oss)
+int destroy_rule(rados_t *cluster,
+ const std::string &rule,
+ std::ostream &oss)
{
char *cmd[2];
std::string tmp = ("{\"prefix\": \"osd crush rule rm\", \"name\":\"" +
- ruleset + "\"}");
+ rule + "\"}");
cmd[0] = (char*)tmp.c_str();
cmd[1] = NULL;
int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0);
if (ret)
- oss << "rados_mon_command: osd crush rule rm " + ruleset + " failed with error " << ret;
+ oss << "rados_mon_command: osd crush rule rm " + rule + " failed with error " << ret;
return ret;
}
-int destroy_ec_profile_and_ruleset(rados_t *cluster,
- const std::string &ruleset,
- std::ostream &oss)
+int destroy_ec_profile_and_rule(rados_t *cluster,
+ const std::string &rule,
+ std::ostream &oss)
{
int ret;
- ret = destroy_ec_profile(cluster, ruleset, oss);
+ ret = destroy_ec_profile(cluster, rule, oss);
if (ret)
return ret;
- return destroy_ruleset(cluster, ruleset, oss);
+ return destroy_rule(cluster, rule, oss);
}
return err;
std::ostringstream oss;
- int ret = destroy_ec_profile_and_ruleset(cluster, pool_name, oss);
+ int ret = destroy_ec_profile_and_rule(cluster, pool_name, oss);
if (ret) {
rados_shutdown(*cluster);
return oss.str();
CephContext *cct = static_cast<CephContext*>(rados_cct(*cluster));
if (!cct->_conf->mon_fake_pool_delete) { // hope this is in [global]
std::ostringstream oss;
- ret = destroy_ec_profile_and_ruleset(cluster, pool_name, oss);
+ ret = destroy_ec_profile_and_rule(cluster, pool_name, oss);
if (ret) {
rados_shutdown(*cluster);
return ret;
return "";
}
-int destroy_ruleset_pp(Rados &cluster,
- const std::string &ruleset,
+int destroy_rule_pp(Rados &cluster,
+ const std::string &rule,
std::ostream &oss)
{
bufferlist inbl;
int ret = cluster.mon_command("{\"prefix\": \"osd crush rule rm\", \"name\":\"" +
- ruleset + "\"}", inbl, NULL, NULL);
+ rule + "\"}", inbl, NULL, NULL);
if (ret)
- oss << "mon_command: osd crush rule rm " + ruleset + " failed with error " << ret << std::endl;
+ oss << "mon_command: osd crush rule rm " + rule + " failed with error " << ret << std::endl;
return ret;
}
return ret;
}
-int destroy_ec_profile_and_ruleset_pp(Rados &cluster,
- const std::string &ruleset,
+int destroy_ec_profile_and_rule_pp(Rados &cluster,
+ const std::string &rule,
std::ostream &oss)
{
int ret;
- ret = destroy_ec_profile_pp(cluster, ruleset, oss);
+ ret = destroy_ec_profile_pp(cluster, rule, oss);
if (ret)
return ret;
- return destroy_ruleset_pp(cluster, ruleset, oss);
+ return destroy_rule_pp(cluster, rule, oss);
}
std::string create_one_ec_pool_pp(const std::string &pool_name, Rados &cluster)
return err;
std::ostringstream oss;
- int ret = destroy_ec_profile_and_ruleset_pp(cluster, pool_name, oss);
+ int ret = destroy_ec_profile_and_rule_pp(cluster, pool_name, oss);
if (ret) {
cluster.shutdown();
return oss.str();
CephContext *cct = static_cast<CephContext*>(cluster.cct());
if (!cct->_conf->mon_fake_pool_delete) { // hope this is in [global]
std::ostringstream oss;
- ret = destroy_ec_profile_and_ruleset_pp(cluster, pool_name, oss);
+ ret = destroy_ec_profile_and_rule_pp(cluster, pool_name, oss);
if (ret) {
cluster.shutdown();
return ret;
if (no_default_pools) // do not create any default pool(s)
return;
- // Create an EC ruleset and a pool using it
+ // Create an EC rule and a pool using it
int r = osdmap.crush->add_simple_rule(
"erasure", "default", "osd", "",
"indep", pg_pool_t::TYPE_ERASURE,
ASSERT_TRUE(!crush.rule_exists(rule_name));
int rno;
for (rno = 0; rno < crush.get_max_rules(); rno++) {
- if (!crush.rule_exists(rno) && !crush.ruleset_exists(rno))
+ if (!crush.rule_exists(rno))
break;
}
string root_name = "default";
ASSERT_TRUE(!crush.rule_exists(rule_name));
int rno;
for (rno = 0; rno < crush.get_max_rules(); rno++) {
- if (!crush.rule_exists(rno) && !crush.ruleset_exists(rno))
+ if (!crush.rule_exists(rno))
break;
}
int min_size = 3;
ASSERT_TRUE(!crush.rule_exists(rule_name));
int rno;
for (rno = 0; rno < crush.get_max_rules(); rno++) {
- if (!crush.rule_exists(rno) && !crush.ruleset_exists(rno))
+ if (!crush.rule_exists(rno))
break;
}
int min_size = 3;
ASSERT_TRUE(!crush.rule_exists(rule_name));
int rno;
for (rno = 0; rno < crush.get_max_rules(); rno++) {
- if (!crush.rule_exists(rno) && !crush.ruleset_exists(rno))
+ if (!crush.rule_exists(rno))
break;
}
int min_size = 3;
ASSERT_TRUE(!crush.rule_exists(rule_name));
int rno;
for (rno = 0; rno < crush.get_max_rules(); rno++) {
- if (!crush.rule_exists(rno) && !crush.ruleset_exists(rno))
+ if (!crush.rule_exists(rno))
break;
}
string root_name = "default";
ASSERT_TRUE(!crush.rule_exists(rule_name));
int rno;
for (rno = 0; rno < crush.get_max_rules(); rno++) {
- if (!crush.rule_exists(rno) && !crush.ruleset_exists(rno))
+ if (!crush.rule_exists(rno))
break;
}
int min_size = 1;
'replicated'])
self.assert_valid_command(['osd', 'pool', 'create',
'poolname', '128', '128',
- 'erasure', 'A-Za-z0-9-_.', 'ruleset^^'])
+ 'erasure', 'A-Za-z0-9-_.', 'rule^^'])
self.assert_valid_command(['osd', 'pool', 'create', 'poolname'])
assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create']))
# invalid pg_num and pgp_num, like "-1", could spill over to
assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
'poolname',
'-1', '-1',
- 'ruleset']))
+ 'rule']))
assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
'poolname',
'128', '128',
'erasure', '^^^',
- 'ruleset']))
+ 'rule']))
assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
'poolname',
'128', '128',
'erasure', 'profile',
- 'ruleset',
+ 'rule',
'toomany']))
assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
'poolname',
'128', '128',
'INVALID', 'profile',
- 'ruleset']))
+ 'rule']))
def test_pool_delete(self):
self.assert_valid_command(['osd', 'pool', 'delete',
local rulename=testrule
local poolname=rulepool
- local var=`ceph osd crush rule dump|grep -w ruleset|sed -n '$p'|grep -o '[0-9]\+'`
+ local var=`ceph osd crush rule dump|grep -w rule|sed -n '$p'|grep -o '[0-9]\+'`
var=`expr $var + 1 `
ceph osd getcrushmap -o "$dir/map1"
crushtool -d "$dir/map1" -o "$dir/map1.txt"
local minsize=0
local maxsize=1
- sed -i '/# end crush map/i\rule '$rulename' {\n ruleset \'$var'\n type replicated\n min_size \'$minsize'\n max_size \'$maxsize'\n step take default\n step choose firstn 0 type osd\n step emit\n }\n' "$dir/map1.txt"
+ sed -i '/# end crush map/i\rule '$rulename' {\n id \'$var'\n type replicated\n min_size \'$minsize'\n max_size \'$maxsize'\n step take default\n step choose firstn 0 type osd\n step emit\n }\n' "$dir/map1.txt"
crushtool -c "$dir/map1.txt" -o "$dir/map1.bin"
ceph osd setcrushmap -i "$dir/map1.bin"
ceph osd pool create $poolname 200 $rulename 2>"$dir/rev"
set<int> roots;
crush.find_roots(&roots);
if (roots.size() > 1) {
- cerr << "The crush rulesets will use the root " << root << "\n"
+ cerr << "The crush rules will use the root " << root << "\n"
<< "and ignore the others.\n"
<< "There are " << roots.size() << " roots, they can be\n"
<< "grouped into a single root by appending something like:\n"