newmap.decode(bl);
newmap.set_fsid(mon->monmap->fsid);
} else {
- newmap.build_simple(g_ceph_context, 0, mon->monmap->fsid, 0,
- g_conf->osd_pg_bits, g_conf->osd_pgp_bits);
+ newmap.build_simple(g_ceph_context, 0, mon->monmap->fsid, 0);
}
newmap.set_epoch(1);
newmap.created = newmap.modified = ceph_clock_now();
CephContext *cct = new CephContext(CODE_ENVIRONMENT_UTILITY);
o.push_back(new OSDMap);
uuid_d fsid;
- o.back()->build_simple(cct, 1, fsid, 16, 7, 8);
+ o.back()->build_simple(cct, 1, fsid, 16);
o.back()->created = o.back()->modified = utime_t(1, 2); // fix timestamp
o.back()->blacklist[entity_addr_t()] = utime_t(5, 6);
cct->put();
return false;
}
-int OSDMap::build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
- int nosd, int pg_bits, int pgp_bits)
+int OSDMap::build_simple_optioned(CephContext *cct, epoch_t e, uuid_d &fsid,
+ int nosd, int pg_bits, int pgp_bits,
+ bool default_pool)
{
ldout(cct, 10) << "build_simple on " << nosd
<< " osds" << dendl;
set_max_osd(maxosd + 1);
}
+
stringstream ss;
int r;
if (nosd >= 0)
r = build_simple_crush_map_from_conf(cct, *crush, &ss);
assert(r == 0);
+ int poolbase = get_max_osd() ? get_max_osd() : 1;
+
+ int const default_replicated_rule = crush->get_osd_pool_default_crush_replicated_ruleset(cct);
+ assert(default_replicated_rule >= 0);
+
+ if (default_pool) {
+ // pgp_num <= pg_num
+ if (pgp_bits > pg_bits)
+ pgp_bits = pg_bits;
+
+ vector<string> pool_names;
+ pool_names.push_back("rbd");
+ for (auto &plname : pool_names) {
+ int64_t pool = ++pool_max;
+ pools[pool].type = pg_pool_t::TYPE_REPLICATED;
+ pools[pool].flags = cct->_conf->osd_pool_default_flags;
+ if (cct->_conf->osd_pool_default_flag_hashpspool)
+ pools[pool].set_flag(pg_pool_t::FLAG_HASHPSPOOL);
+ if (cct->_conf->osd_pool_default_flag_nodelete)
+ pools[pool].set_flag(pg_pool_t::FLAG_NODELETE);
+ if (cct->_conf->osd_pool_default_flag_nopgchange)
+ pools[pool].set_flag(pg_pool_t::FLAG_NOPGCHANGE);
+ if (cct->_conf->osd_pool_default_flag_nosizechange)
+ pools[pool].set_flag(pg_pool_t::FLAG_NOSIZECHANGE);
+ pools[pool].size = cct->_conf->osd_pool_default_size;
+ pools[pool].min_size = cct->_conf->get_osd_pool_default_min_size();
+ pools[pool].crush_rule = default_replicated_rule;
+ pools[pool].object_hash = CEPH_STR_HASH_RJENKINS;
+ pools[pool].set_pg_num(poolbase << pg_bits);
+ pools[pool].set_pgp_num(poolbase << pgp_bits);
+ pools[pool].last_change = epoch;
+ pool_name[pool] = plname;
+ name_pool[plname] = pool;
+ }
+ }
+
for (int i=0; i<get_max_osd(); i++) {
set_state(i, 0);
set_weight(i, CEPH_OSD_OUT);
* @param num_osd [in] number of OSDs if >= 0 or read from conf if < 0
* @return **0** on success, negative errno on error.
*/
+private:
+ int build_simple_optioned(CephContext *cct, epoch_t e, uuid_d &fsid,
+ int num_osd, int pg_bits, int pgp_bits,
+ bool default_pool);
+public:
int build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
- int num_osd, int pg_bits, int pgp_bits);
+ int num_osd) {
+ return build_simple_optioned(cct, e, fsid, num_osd, 0, 0, false);
+ }
+ int build_simple_with_pool(CephContext *cct, epoch_t e, uuid_d &fsid,
+ int num_osd, int pg_bits, int pgp_bits) {
+ return build_simple_optioned(cct, e, fsid, num_osd,
+ pg_bits, pgp_bits, true);
+ }
static int _build_crush_types(CrushWrapper& crush);
static int build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
int num_osd, ostream *ss);
void set_up_map() {
uuid_d fsid;
- osdmap.build_simple(g_ceph_context, 0, fsid, num_osds, 6, 6);
+ osdmap.build_simple(g_ceph_context, 0, fsid, num_osds);
OSDMap::Incremental pending_inc(osdmap.get_epoch() + 1);
pending_inc.fsid = osdmap.get_fsid();
entity_addr_t sample_addr;
OSDMap *osdmap = new OSDMap;
uuid_d test_uuid;
test_uuid.generate_random();
- osdmap->build_simple(g_ceph_context, epoch, test_uuid, max_osd, bits, bits);
+ osdmap->build_simple_with_pool(g_ceph_context, epoch, test_uuid, max_osd, bits, bits);
osdmap->set_state(osd_id, CEPH_OSD_EXISTS);
const string hit_set_namespace("internal");
}
uuid_d fsid;
memset(&fsid, 0, sizeof(uuid_d));
- osdmap.build_simple(g_ceph_context, 0, fsid, num_osd, pg_bits, pgp_bits);
+ osdmap.build_simple_with_pool(g_ceph_context, 0, fsid, num_osd, pg_bits, pgp_bits);
modified = true;
}