mirror of
https://github.com/ceph/ceph
synced 2025-04-01 00:26:47 +00:00
mon: osd create pool must fail on incompatible type
When osd create pool is called twice on the same pool, it will succeed because the pool already exists. However, if a different type is specified, it must fail. Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
parent
af22b0a09b
commit
df0d038d7b
@ -275,13 +275,13 @@ ceph osd pool create erasurecodes 12 12 erasure
|
||||
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
|
||||
|
@ -3941,21 +3941,31 @@ done:
|
||||
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") {
|
||||
|
||||
|
@ -712,6 +712,9 @@ struct pg_pool_t {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user