ceph osd pool create erasurecodes 12 12 erasure
# should fail because the default type is replicated and
# the pool is of type erasure
-#expect_false ceph osd pool create erasurecodes 12 12
+expect_false ceph osd pool create erasurecodes 12 12
ceph osd pool create replicated 12 12 replicated
ceph osd pool create replicated 12 12 replicated
ceph osd pool create replicated 12 12 # default is replicated
ceph osd pool create replicated 12 # default is replicated, pgp_num = pg_num
# should fail because the type is not the same
-# expect_false ceph osd pool create replicated 12 12 erasure
+expect_false ceph osd pool create replicated 12 12 erasure
ceph osd lspools | grep erasurecodes
ceph osd lspools | grep replicated
ceph osd pool delete erasurecodes erasurecodes --yes-i-really-really-mean-it
goto reply;
}
+ string pool_type_str;
+ cmd_getval(g_ceph_context, cmdmap, "pool_type", pool_type_str);
+ if (pool_type_str.empty())
+ pool_type_str = pg_pool_t::get_default_type();
+
string poolstr;
cmd_getval(g_ceph_context, cmdmap, "pool", poolstr);
- if (osdmap.name_pool.count(poolstr)) {
- ss << "pool '" << poolstr << "' already exists";
- err = 0;
+ int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr);
+ if (pool_id >= 0) {
+ const pg_pool_t *p = osdmap.get_pg_pool(pool_id);
+ if (pool_type_str != p->get_type_name()) {
+ ss << "pool '" << poolstr << "' cannot change to type " << pool_type_str;
+ err = -EINVAL;
+ } else {
+ ss << "pool '" << poolstr << "' already exists";
+ err = 0;
+ }
goto reply;
}
vector<string> properties;
cmd_getval(g_ceph_context, cmdmap, "properties", properties);
- string pool_type_str;
- cmd_getval(g_ceph_context, cmdmap, "pool_type", pool_type_str);
int pool_type;
- if (pool_type_str.empty() || pool_type_str == "replicated") {
+ if (pool_type_str == "replicated") {
pool_type = pg_pool_t::TYPE_REPLICATED;
} else if (pool_type_str == "erasure") {
const char *get_type_name() const {
return get_type_name(type);
}
+ static const char* get_default_type() {
+ return "replicated";
+ }
enum {
FLAG_HASHPSPOOL = 1, // hash pg seed and pool together (instead of adding)