"name=pool,type=CephPoolname " \
"name=pg_num,type=CephInt,range=0 " \
"name=pgp_num,type=CephInt,range=0,req=false " \
+ "name=pool_type,type=CephChoices,strings=rep|raid4|erasure,req=false " \
"name=properties,type=CephString,n=N,req=false,goodchars=[A-Za-z0-9-_.=]", \
"create pool", "osd", "rw", "cli,rest")
COMMAND("osd pool delete " \
return -EPERM;
vector<string> properties;
if (m->auid)
- return prepare_new_pool(m->name, m->auid, m->crush_rule, 0, 0, properties);
+ return prepare_new_pool(m->name, m->auid, m->crush_rule, 0, 0,
+ properties, pg_pool_t::TYPE_REP);
else
- return prepare_new_pool(m->name, session->auid, m->crush_rule, 0, 0, properties);
+ return prepare_new_pool(m->name, session->auid, m->crush_rule, 0, 0,
+ properties, pg_pool_t::TYPE_REP);
}
/**
*/
int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_rule,
unsigned pg_num, unsigned pgp_num,
- const vector<string> &properties)
+ const vector<string> &properties,
+ const unsigned pool_type)
{
for (map<int64_t,string>::iterator p = pending_inc.new_pool_names.begin();
p != pending_inc.new_pool_names.end();
int64_t pool = ++pending_inc.new_pool_max;
pg_pool_t empty;
pg_pool_t *pi = pending_inc.get_new_pool(pool, &empty);
- pi->type = pg_pool_t::TYPE_REP;
+ pi->type = pool_type;
pi->flags = g_conf->osd_pool_default_flags;
if (g_conf->osd_pool_default_flag_hashpspool)
pi->flags |= pg_pool_t::FLAG_HASHPSPOOL;
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 == "rep") {
+ pool_type = pg_pool_t::TYPE_REP;
+ } else if (pool_type_str == "raid4") {
+ pool_type = pg_pool_t::TYPE_RAID4;
+ } else if (pool_type_str == "erasure") {
+
+ // check if all up osds support erasure coding
+ set<int32_t> up_osds;
+ osdmap.get_up_osds(up_osds);
+ stringstream ec_unsupported_ss;
+ int ec_unsupported_count = 0;
+
+ for (set<int32_t>::iterator it = up_osds.begin();
+ it != up_osds.end(); it ++) {
+ const osd_xinfo_t &xi = osdmap.get_xinfo(*it);
+ if (!(xi.features & CEPH_FEATURE_OSD_ERASURE_CODES)) {
+ if (ec_unsupported_count > 0)
+ ec_unsupported_ss << ", ";
+ ec_unsupported_ss << "osd." << *it;
+ ec_unsupported_count ++;
+ }
+ }
+
+ if (ec_unsupported_count > 0) {
+ ss << "unable to create erasure pool; unsupported by: "
+ << ec_unsupported_ss.str();
+ err = -ENOTSUP;
+ goto reply;
+ }
+
+ pool_type = pg_pool_t::TYPE_ERASURE;
+ } else {
+ ss << "unknown pool type '" << pool_type_str << "'";
+ err = -EINVAL;
+ goto reply;
+ }
+
err = prepare_new_pool(poolstr, 0, // auid=0 for admin created pool
-1, // default crush rule
pg_num, pgp_num,
- properties);
+ properties, pool_type);
if (err < 0 && err != -EEXIST) {
goto reply;
}