// -- mkfs --
if (mkfs) {
common_init_finish(g_ceph_context);
- if (g_conf->monmap.empty() || osdmapfn.empty())
- usage();
bufferlist monmapbl, osdmapbl;
std::string error;
int err = MonClient::build_initial_monmap(g_ceph_context, monmap);
if (err < 0) {
cerr << argv[0] << ": error generating initial monmap: " << cpp_strerror(err) << std::endl;
+ usage();
exit(1);
}
}
}
if (monmap.fsid.is_zero()) {
- cerr << argv[0] << ": generated monmap has no fsid; use --fsid" << std::endl;
+ cerr << argv[0] << ": generated monmap has no fsid; use '--fsid <uuid>'" << std::endl;
exit(10);
}
// osdmap
- err = osdmapbl.read_file(osdmapfn.c_str(), &error);
- if (err < 0) {
- cerr << argv[0] << ": error reading " << osdmapfn << ": "
- << error << std::endl;
- exit(1);
+ if (osdmapfn.length()) {
+ err = osdmapbl.read_file(osdmapfn.c_str(), &error);
+ if (err < 0) {
+ cerr << argv[0] << ": error reading " << osdmapfn << ": "
+ << error << std::endl;
+ exit(1);
+ }
}
// go
monmap->set_epoch(0); // must be 0 to avoid confusing first MonmapMonitor::update_from_paxos()
store->put_bl_ss(monmapbl, "mkfs", "monmap");
- store->put_bl_ss(osdmapbl, "mkfs", "osdmap");
+ if (osdmapbl.length())
+ store->put_bl_ss(osdmapbl, "mkfs", "osdmap");
KeyRing keyring;
r = keyring.load(g_ceph_context, g_conf->keyring);
{
dout(10) << "create_initial for " << mon->monmap->fsid << dendl;
+ OSDMap newmap;
+
bufferlist bl;
mon->store->get_bl_ss(bl, "mkfs", "osdmap");
-
- OSDMap newmap;
- newmap.decode(bl);
+ if (bl.length()) {
+ newmap.decode(bl);
+ newmap.set_fsid(mon->monmap->fsid);
+ } else {
+ newmap.build_simple(g_ceph_context, 0, mon->monmap->fsid, 0, 0,
+ g_conf->osd_pg_bits, g_conf->osd_pgp_bits, g_conf->osd_lpg_bits);
+ }
newmap.set_epoch(1);
- newmap.set_fsid(mon->monmap->fsid);
newmap.created = newmap.modified = ceph_clock_now(g_ceph_context);
// encode into pending incremental
int i;
if (m->cmd.size() > 2) {
i = atoi(m->cmd[2].c_str());
- if (i < 0 || i >= osdmap.get_max_osd()) {
+ if (i < 0) {
ss << i << " is not a valid osd id";
err = -ERANGE;
goto out;
err = -EEXIST;
goto out;
}
+ if (i >= osdmap.get_max_osd()) {
+ if (i >= pending_inc.new_max_osd)
+ pending_inc.new_max_osd = i + 1;
+ }
if (pending_inc.new_up_client.count(i) ||
(pending_inc.new_state.count(i) &&
(pending_inc.new_state[i] & CEPH_OSD_EXISTS))) {