]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_init: initial version
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 30 Jan 2009 23:47:59 +0000 (15:47 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 30 Jan 2009 23:47:59 +0000 (15:47 -0800)
17 files changed:
src/dstart.sh
src/mkmonfs.cc
src/mon/ClientMonitor.cc
src/mon/ClientMonitor.h
src/mon/LogMonitor.cc
src/mon/LogMonitor.h
src/mon/MDSMonitor.cc
src/mon/MDSMonitor.h
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/mon/PGMonitor.cc
src/mon/PGMonitor.h
src/mon/PaxosService.h
src/osdmaptool.cc
src/vstart.sh

index 9ee210491366c4d9393d4557bb303b8f090dff7c..6076d324c2de41c125335272b69a8e80c345ab6e 100755 (executable)
@@ -51,6 +51,16 @@ if [ $stopfirst -eq 1 ]; then
     ./dstop.sh
 fi
 
+if [ $new -eq 1 ]; then
+    # build and inject an initial osd map
+    ./osdmaptool --clobber --createsimple 32 --num_dom 4 .ceph_osdmap
+
+    # use custom crush map to separate data from metadata
+    ./crushtool -c cm.txt -o cm
+    ./osdmaptool --clobber --import-crush cm .ceph_osdmap
+
+#    ./ceph osd setmap 2 -i .ceph_osdmap
+fi
 
 # mkmonfs
 if [ $new -eq 1 ]; then
@@ -86,24 +96,12 @@ if [ $new -eq 1 ]; then
     
     # build a fresh fs monmap, mon fs
     ./monmaptool --create --clobber --add $IP:6789 --print .ceph_monmap
-    ./mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
+    ./mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap --osdmap .ceph_osdmap
 fi
 
 # monitor
 ./cmon -d mondata/mon0 $ARGS $CMON_ARGS
 
-if [ $new -eq 1 ]; then
-    # build and inject an initial osd map
-    ./osdmaptool --clobber --createsimple .ceph_monmap 32 --num_dom 4 .ceph_osdmap
-
-    # use custom crush map to separate data from metadata
-    ./crushtool -c cm.txt -o cm
-    ./osdmaptool --clobber --import-crush cm .ceph_osdmap
-
-    ./ceph osd setmap 2 -i .ceph_osdmap
-fi
-
-
 # osds
 savelog -l cosd
 cp -p cosd.0 cosd
index 1b610f86857b88d4f3b8c7789a97d4034b5f3551..9b0635ababb7c01a88ec4fcca8f8c6449c5ff4e1 100644 (file)
@@ -37,6 +37,7 @@ int main(int argc, const char **argv)
   const char *fsdir = 0;
   int whoami = -1;
   const char *monmapfn = 0;
+  const char *osdmapfn = 0;
   for (unsigned i = 0; i < args.size(); i++) {
     if (strcmp(args[i], "--clobber") == 0)
       clobber = true;
@@ -44,6 +45,8 @@ int main(int argc, const char **argv)
       whoami = atoi(args[++i]);
     else if (strcmp(args[i], "--monmap") == 0) 
       monmapfn = args[++i];
+    else if (strcmp(args[i], "--osdmap") == 0) 
+      osdmapfn = args[++i];
     else if (!fsdir)
       fsdir = args[i];
     else 
@@ -63,17 +66,21 @@ int main(int argc, const char **argv)
   }
 
   // load monmap
-  bufferlist monmapbl;
+  bufferlist monmapbl, osdmapbl;
   int err = monmapbl.read_file(monmapfn);
   if (err < 0)
     exit(1);
   MonMap monmap;
   monmap.decode(monmapbl);
 
+  err = osdmapbl.read_file(osdmapfn);
+  if (err < 0)
+    exit(1);
+
   // go
   MonitorStore store(fsdir);
   Monitor mon(whoami, &store, 0, &monmap);
-  mon.mkfs();
+  mon.mkfs(osdmapbl);
   cout << argv[0] << ": created monfs at " << fsdir 
        << " for mon" << whoami
        << std::endl;
index 32c20cd3612e19ed768842d6571ed06b1888d1d8..f18bfd235e007d763c145a655aa9932d841bf834 100644 (file)
@@ -102,7 +102,7 @@ void ClientMonitor::create_pending()
           << dendl;
 }
 
-void ClientMonitor::create_initial()
+void ClientMonitor::create_initial(bufferlist& bl)
 {
   dout(10) << "create_initial -- creating initial map" << dendl;
 }
index 538c4c8182cdb3e347602ea610488c7aedc87ca0..b83c16b3a7268f3d1199e5cf1bb2f952cfa1f63c 100644 (file)
@@ -77,7 +77,7 @@ private:
   // leader
   ClientMap::Incremental pending_inc;
 
-  void create_initial();
+  void create_initial(bufferlist& bl);
   bool update_from_paxos();
   void create_pending();  // prepare a new pending
   void encode_pending(bufferlist &bl);  // propose pending update to peers
index 60adfafa78b23c87d32b22e3fd3ba2b0c55c632d..b665132c031f06acb1c045ddda6639847caab7b6 100644 (file)
@@ -76,7 +76,7 @@ void LogMonitor::tick()
 
 }
 
-void LogMonitor::create_initial()
+void LogMonitor::create_initial(bufferlist& bl)
 {
   dout(10) << "create_initial -- creating initial map" << dendl;
   LogEntry e;
index 05490eab899de2a3b87721a26f4fef6214785aba..d5c09664cdc42d9ba768735d923050644cc0d94e 100644 (file)
@@ -33,7 +33,7 @@ private:
   bufferlist pending_inc;
   version_t log_version;
 
-  void create_initial();
+  void create_initial(bufferlist& bl);
   bool update_from_paxos();
   void create_pending();  // prepare a new pending
   void encode_pending(bufferlist &bl);  // propose pending update to peers
index c640273dd814ee00dbc45041ca33ecc57c93e306..9ea4288c195ca8004f9a31413d8553a4461d570b 100644 (file)
@@ -57,7 +57,7 @@ void MDSMonitor::print_map(MDSMap &m, int dbl)
 
 // service methods
 
-void MDSMonitor::create_initial()
+void MDSMonitor::create_initial(bufferlist& bl)
 {
   dout(10) << "create_initial" << dendl;
   pending_mdsmap.max_mds = 1;
index a5e93103aa03bf4e50a16e01bcf094a027446cce..67b76a319d86c99c1e187f83b5ff3850683716dd 100644 (file)
@@ -60,7 +60,7 @@ class MDSMonitor : public PaxosService {
 
 
   // service methods
-  void create_initial();
+  void create_initial(bufferlist& bl);
   bool update_from_paxos();
   void create_pending(); 
   void encode_pending(bufferlist &bl);
index f2797f7a1b60f38fe23b59dbafefc03e394c9e6f..1cf64c73dd8fbedf051132475d631fc7c1efcf55 100644 (file)
@@ -42,6 +42,8 @@
 #include "PGMonitor.h"
 #include "LogMonitor.h"
 
+#include "osd/OSDMap.h"
+
 #include "config.h"
 
 #define DOUT_SUBSYS mon
@@ -521,7 +523,7 @@ void Monitor::tick()
  * this is the closest thing to a traditional 'mkfs' for ceph.
  * initialize the monitor state machines to their initial values.
  */
-int Monitor::mkfs()
+int Monitor::mkfs(bufferlist& osdmapbl)
 {
   // create it
   int err = store->mkfs();
@@ -544,13 +546,15 @@ int Monitor::mkfs()
 
   for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); p++) {
     PaxosService *svc = *p;
+    bufferlist bl;
     dout(10) << "initializing " << svc->get_machine_name() << dendl;
     svc->paxos->init();
     svc->create_pending();
-    svc->create_initial();
-
+    if (svc->paxos->machine_id == PAXOS_OSDMAP)
+      svc->create_initial(osdmapbl);
+    else
+      svc->create_initial(bl);
     // commit to paxos
-    bufferlist bl;
     svc->encode_pending(bl);
     store->put_bl_sn(bl, svc->get_machine_name(), 1);
     store->put_int(1, svc->get_machine_name(), "last_committed");
index 8b8c605bd2a3080f56f6366719a185f15ab12b64..a3afb9293037028a0596e5f9bbe68dc0e2edc5cb 100644 (file)
@@ -32,6 +32,8 @@
 #include "Elector.h"
 #include "Paxos.h"
 
+#include "osd/OSDMap.h"
+
 
 class MonitorStore;
 
@@ -159,7 +161,7 @@ public:
 
   void stop_cluster();
 
-  int mkfs();
+  int mkfs(bufferlist& osdmapbl);
 
 };
 
index 4b1534d32b1f1035e9fd187b1128d76d94490152..2572c34e7a71f60005808a0e93902e9a66bed705 100644 (file)
@@ -107,24 +107,20 @@ void OSDMonitor::fake_reorg()
 /************ MAPS ****************/
 
 
-void OSDMonitor::create_initial()
+void OSDMonitor::create_initial(bufferlist& bl)
 {
-  dout(10) << "create_initial for " << mon->monmap->fsid << " from g_conf" << dendl;
+  dout(0) << "create_initial for " << mon->monmap->fsid << dendl;
 
   OSDMap newmap;
+  newmap.decode(bl);
   newmap.epoch = 1;
   newmap.set_fsid(mon->monmap->fsid);
   newmap.ctime = g_clock.now();
-  newmap.crush.create(); // empty crush map
 
   // encode into pending incremental
   newmap.encode(pending_inc.fullmap);
 }
 
-
-
-
-
 bool OSDMonitor::update_from_paxos()
 {
   assert(paxos->is_active());
index c602ca5915eac6d374c25a8ce1f4fc7e2d83a583..698bd4f4be5d46e687ca51a06c3a38d1e8aa412e 100644 (file)
@@ -48,7 +48,7 @@ private:
 
   // svc
 public:  
-  void create_initial();
+  void create_initial(bufferlist& bl);
 private:
   bool update_from_paxos();
   void create_pending();  // prepare a new pending
index 2f8d0d55fc8038c5b1212a0b0984b56e0bc33f22..7394eccc87a69cbc8c87c849e7fa189d7e1650cf 100644 (file)
@@ -75,7 +75,7 @@ void PGMonitor::tick()
   */
 }
 
-void PGMonitor::create_initial()
+void PGMonitor::create_initial(bufferlist& bl)
 {
   dout(10) << "create_initial -- creating initial map" << dendl;
 }
index d8b0005f4d3abebf242d3e7fc6c8be007a82c10e..c9be9a08665efa6ea8938870021d081acde8f2ea 100644 (file)
@@ -42,7 +42,7 @@ public:
 private:
   PGMap::Incremental pending_inc;
 
-  void create_initial();
+  void create_initial(bufferlist& bl);
   bool update_from_paxos();
   void create_pending();  // prepare a new pending
   void encode_pending(bufferlist &bl);  // propose pending update to peers
index 17f74effa90924aafe94eba1a05760e32480eaf4..07764c37634cc910c5a1faa11291f2d63bf3a042 100644 (file)
@@ -94,7 +94,7 @@ public:
   void propose_pending();     // propose current pending as new paxos state
 
   // you implement
-  virtual void create_initial() = 0;
+  virtual void create_initial(bufferlist& bl) = 0;
   virtual bool update_from_paxos() = 0;    // assimilate latest state from paxos
   virtual void create_pending() = 0;       // [leader] create new pending structures
   virtual void encode_pending(bufferlist& bl) = 0; // [leader] finish and encode pending for next paxos state
index 194f22abf2682c20c74d1d51878e54bf600e197a..4a6746bbd7815a5ff42a7453224feb066cab7507 100644 (file)
@@ -29,7 +29,7 @@ using namespace std;
 
 void usage(const char *me)
 {
-  cout << me << " usage: [--print] [--createsimple <monmapfile> <numosd> [--clobber] [--pgbits <bitsperosd>]] <mapfilename>" << std::endl;
+  cout << me << " usage: [--print] [--createsimple <numosd> [--clobber] [--pgbits <bitsperosd>]] <mapfilename>" << std::endl;
   cout << me << "   --export-crush <file>   write osdmap's crush map to <file>" << std::endl;
   cout << me << "   --import-crush <file>   replace osdmap's crush map with <file>" << std::endl;
   exit(1);
@@ -50,7 +50,6 @@ int main(int argc, const char **argv)
   const char *fn = 0;
   bool print = false;
   bool createsimple = false;
-  const char *monmapfn = 0;
   int num_osd = 0, num_dom = 0;
   int pg_bits = g_conf.osd_pg_bits;
   int lpg_bits = g_conf.osd_lpg_bits;
@@ -67,7 +66,6 @@ int main(int argc, const char **argv)
       print = true;
     else if (strcmp(args[i], "--createsimple") == 0) {
       createsimple = true;
-      monmapfn = args[++i];
       num_osd = atoi(args[++i]);
     } else if (strcmp(args[i], "--clobber") == 0) 
       clobber = true;
@@ -113,17 +111,13 @@ int main(int argc, const char **argv)
   }
 
   if (createsimple) {
-    MonMap monmap;
-    int r = monmap.read(monmapfn);
-    if (r < 0) {
-      cerr << me << ": can't read monmap from " << monmapfn << ": " << strerror(r) << std::endl;
-      exit(1);
-    }
     if (num_osd < 1) {
       cerr << me << ": osd count must be > 0" << std::endl;
       exit(1);
     }
-    osdmap.build_simple(0, monmap.fsid, num_osd, num_dom, pg_bits, lpg_bits, 0);
+    ceph_fsid_t fsid;
+    memset(&fsid, 0, sizeof(ceph_fsid_t));
+    osdmap.build_simple(0, fsid, num_osd, num_dom, pg_bits, lpg_bits, 0);
     modified = true;
   }
 
index 2e8f9958cfae37b2e56724dec7b0f1216caa457b..b88ce91213715d685bd11fa968f54da52c6a0521 100755 (executable)
@@ -125,6 +125,12 @@ echo "ip $IP"
 [ "$CEPH_PORT" == "" ] && CEPH_PORT=6789
 
 if [ $start_mon -eq 1 ]; then
+       if [ $new -eq 1 ]; then
+       # build and inject an initial osd map
+               $CEPH_BIN/osdmaptool --clobber --createsimple 4 .ceph_osdmap # --pgbits 2
+#              $CEPH_BIN/ceph osd setmap 2 -i .ceph_osdmap 
+       fi
+
        if [ $new -eq 1 ]; then
                if [ `echo $IP | grep '^127\\.'` ]
                then
@@ -148,7 +154,7 @@ if [ $start_mon -eq 1 ]; then
 
                for f in `seq 0 $((CEPH_NUM_MON-1))`
                do
-                       $CEPH_BIN/mkmonfs --clobber mondata/mon$f --mon $f --monmap .ceph_monmap
+                       $CEPH_BIN/mkmonfs --clobber mondata/mon$f --mon $f --monmap .ceph_monmap --osdmap .ceph_osdmap
                done
        fi
 
@@ -160,12 +166,6 @@ if [ $start_mon -eq 1 ]; then
                done
                sleep 1
        fi
-
-       if [ $new -eq 1 ]; then
-       # build and inject an initial osd map
-               $CEPH_BIN/osdmaptool --clobber --createsimple .ceph_monmap 4 .ceph_osdmap # --pgbits 2
-               $CEPH_BIN/ceph osd setmap 2 -i .ceph_osdmap 
-       fi
 fi
 
 #osd