]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: make initial osdmap optional
authorSage Weil <sage.weil@dreamhost.com>
Sat, 12 Nov 2011 21:41:59 +0000 (13:41 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Sat, 12 Nov 2011 21:41:59 +0000 (13:41 -0800)
If an initial osdmap is not provided, we generate an empty one.  The user
add osds on their own after that.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/ceph_mon.cc
src/mon/Monitor.cc
src/mon/OSDMonitor.cc

index ff65c55c6be39d9a13f7a8446c3b3421fd890e05..88932fb0cc7b76ac8c0945f3a100dd2eae367aa4 100644 (file)
@@ -99,8 +99,6 @@ int main(int argc, const char **argv)
   // -- mkfs --
   if (mkfs) {
     common_init_finish(g_ceph_context);
-    if (g_conf->monmap.empty() || osdmapfn.empty())
-      usage();
 
     bufferlist monmapbl, osdmapbl;
     std::string error;
@@ -124,6 +122,7 @@ int main(int argc, const char **argv)
       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);
       }
     }
@@ -134,16 +133,18 @@ int main(int argc, const char **argv)
     }
     
     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
index 3ebf762895b683f0ea6dd6aaf8053239bb006884..7412e6fcc1c2e73f01cbdf2ec5d401ae55cb98b6 100644 (file)
@@ -1553,7 +1553,8 @@ int Monitor::mkfs(bufferlist& osdmapbl)
   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);
index 4dba0fbab3ee7908c9f2f519f7fd807cafbedad9..9380ce025fbbfe1daf994801f21cc3f14b2344b7 100644 (file)
@@ -67,13 +67,18 @@ void OSDMonitor::create_initial()
 {
   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
@@ -1745,7 +1750,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       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;
@@ -1755,6 +1760,10 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
          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))) {