string data_dir_option; ///< data_dir config option, if any
public:
- unsigned get_osd_pool_default_min_size(const ConfigValues& values) const {
- auto min_size = get_val<uint64_t>(values, "osd_pool_default_min_size");
- auto size = get_val<uint64_t>(values, "osd_pool_default_size");
+ unsigned get_osd_pool_default_min_size(const ConfigValues& values,
+ uint8_t size) const {
+ uint8_t min_size = get_val<uint64_t>(values, "osd_pool_default_min_size");
return min_size ? std::min(min_size, size) : (size - size / 2);
}
return config.get_val_from_conf_file(values,
sections, key, out, emeta);
}
- unsigned get_osd_pool_default_min_size() const {
- return config.get_osd_pool_default_min_size(values);
+ unsigned get_osd_pool_default_min_size(uint8_t size) const {
+ return config.get_osd_pool_default_min_size(values, size);
}
void early_expand_meta(std::string &val,
std::ostream *oss) const {
Option("osd_pool_default_size", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(3)
+ .set_min_max(0, 255)
.set_flag(Option::FLAG_RUNTIME)
.set_description("the number of copies of an object")
.add_service("mon"),
Option("osd_pool_default_min_size", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(0)
+ .set_min_max(0, 255)
.set_flag(Option::FLAG_RUNTIME)
.set_description("the minimal number of copies allowed to write to a degraded pool")
.set_long_description("0 means no specific default; ceph will use size-size/2")
out, expand_meta);
}
- unsigned get_osd_pool_default_min_size() const {
- return get_config().get_osd_pool_default_min_size(*values);
+ unsigned get_osd_pool_default_min_size(uint8_t size) const {
+ return get_config().get_osd_pool_default_min_size(*values, size);
}
seastar::future<> set_mon_vals(const std::map<std::string,std::string>& kv) {
"name=pool_type,type=CephChoices,strings=replicated|erasure,req=false " \
"name=erasure_code_profile,type=CephString,req=false,goodchars=[A-Za-z0-9-_.] " \
"name=rule,type=CephString,req=false " \
- "name=expected_num_objects,type=CephInt,req=false", \
+ "name=expected_num_objects,type=CephInt,req=false " \
+ "name=size,type=CephInt,req=false", \
"create pool", "osd", "rw")
COMMAND_WITH_FLAG("osd pool delete " \
"name=pool,type=CephPoolname " \
string rule_name;
int ret = 0;
ret = prepare_new_pool(m->name, m->crush_rule, rule_name,
- 0, 0,
+ 0, 0, 0,
erasure_code_profile,
pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, &ss);
int OSDMonitor::prepare_pool_size(const unsigned pool_type,
const string &erasure_code_profile,
+ uint8_t repl_size,
unsigned *size, unsigned *min_size,
ostream *ss)
{
int err = 0;
switch (pool_type) {
case pg_pool_t::TYPE_REPLICATED:
- *size = g_conf().get_val<uint64_t>("osd_pool_default_size");
- *min_size = g_conf().get_osd_pool_default_min_size();
+ if (repl_size == 0) {
+ repl_size = g_conf().get_val<uint64_t>("osd_pool_default_size");
+ }
+ *size = repl_size;
+ *min_size = g_conf().get_osd_pool_default_min_size(repl_size);
break;
case pg_pool_t::TYPE_ERASURE:
{
* @param crush_rule_name The crush rule to use, if crush_rulset <0
* @param pg_num The pg_num to use. If set to 0, will use the system default
* @param pgp_num The pgp_num to use. If set to 0, will use the system default
+ * @param repl_size Replication factor, or 0 for default
* @param erasure_code_profile The profile name in OSDMap to be used for erasure code
* @param pool_type TYPE_ERASURE, or TYPE_REP
* @param expected_num_objects expected number of objects on the pool
int crush_rule,
const string &crush_rule_name,
unsigned pg_num, unsigned pgp_num,
+ const uint64_t repl_size,
const string &erasure_code_profile,
const unsigned pool_type,
const uint64_t expected_num_objects,
<< duration << dendl;
}
unsigned size, min_size;
- r = prepare_pool_size(pool_type, erasure_code_profile, &size, &min_size, ss);
+ r = prepare_pool_size(pool_type, erasure_code_profile, repl_size,
+ &size, &min_size, ss);
if (r) {
dout(10) << "prepare_pool_size returns " << r << dendl;
return r;
fast_read = FAST_READ_OFF;
else if (fast_read_param > 0)
fast_read = FAST_READ_ON;
-
+
+ int64_t repl_size = 0;
+ cmd_getval(cct, cmdmap, "size", repl_size);
+
err = prepare_new_pool(poolstr,
-1, // default crush rule
rule_name,
pg_num, pgp_num,
+ repl_size,
erasure_code_profile, pool_type,
(uint64_t)expected_num_objects,
fast_read,
ostream *ss);
int prepare_pool_size(const unsigned pool_type,
const string &erasure_code_profile,
+ uint8_t repl_size,
unsigned *size, unsigned *min_size,
ostream *ss);
int prepare_pool_stripe_width(const unsigned pool_type,
int crush_rule,
const string &crush_rule_name,
unsigned pg_num, unsigned pgp_num,
+ uint64_t repl_size,
const string &erasure_code_profile,
const unsigned pool_type,
const uint64_t expected_num_objects,
if (cct->_conf->osd_pool_default_flag_nosizechange)
pools[pool].set_flag(pg_pool_t::FLAG_NOSIZECHANGE);
pools[pool].size = cct->_conf.get_val<uint64_t>("osd_pool_default_size");
- pools[pool].min_size = cct->_conf.get_osd_pool_default_min_size();
+ pools[pool].min_size = cct->_conf.get_osd_pool_default_min_size(
+ pools[pool].size);
pools[pool].crush_rule = default_replicated_rule;
pools[pool].object_hash = CEPH_STR_HASH_RJENKINS;
pools[pool].set_pg_num(poolbase << pg_bits);