]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: make 'osd setmap' take epoch, to avoid executing multiple times
authorSage Weil <sage@newdream.net>
Wed, 24 Dec 2008 22:14:59 +0000 (14:14 -0800)
committerSage Weil <sage@newdream.net>
Wed, 24 Dec 2008 22:19:27 +0000 (14:19 -0800)
src/dstart.sh
src/mkcephfs.sh
src/mon/OSDMonitor.cc
src/montest.sh
src/vstart.sh

index de1a606f31c958bfc42b09da92e6edd7c817710f..b4213bbd53ff2e8f631df9f257da479220e5719a 100755 (executable)
@@ -94,7 +94,7 @@ if [ $new -eq 1 ]; then
     ./crushtool -c cm.txt -o cm
     ./osdmaptool --clobber --import-crush cm .ceph_osdmap
 
-    ./ceph osd setmap -i .ceph_osdmap
+    ./ceph osd setmap -i .ceph_osdmap
 fi
 
 
index 748979ed30222592e0e04441ac66e770f4c1a51e..7d42b44bd4cf109ea2f6f439cd3b801753db661c 100755 (executable)
@@ -28,7 +28,7 @@ $CEPH_BIN/cmon $ARGS mondata/mon0 --debug_mon 20 --debug_ms 1
 
 # build and inject an initial osd map
 $CEPH_BIN/osdmaptool --clobber --createsimple .ceph_monmap 4 --print .ceph_osdmap
-$CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap
+$CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap
 
 # stop monitor
 killall cmon
index 0675bbf3e0d68024b359bc07c9b49d0c8b579fac..1e7e5ef4552fc666ce882051a212c1c5e6b7ae79 100644 (file)
@@ -971,17 +971,21 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs));
       return true;
     }
-    else if (m->cmd[1] == "setmap") {
+    else if (m->cmd[1] == "setmap" && m->cmd.size() == 3) {
       OSDMap map;
       map.decode(m->get_data());
+      epoch_t e = atoi(m->cmd[2].c_str());
       if (ceph_fsid_equal(&map.fsid, &mon->monmap->fsid)) {
-       map.epoch = pending_inc.epoch;  // make sure epoch is correct
-       map.encode(pending_inc.fullmap);
-       string rs = "set osd map";
-       paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs));
-       return true;
-      }
-      ss << "osdmap fsid " << map.fsid << " does not match monitor fsid " << mon->monmap->fsid;
+       if (pending_inc.epoch == e) {
+         map.epoch = pending_inc.epoch;  // make sure epoch is correct
+         map.encode(pending_inc.fullmap);
+         string rs = "set osd map";
+         paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs));
+         return true;
+       } else
+         ss << "next osdmap epoch " << pending_inc.epoch << " != " << e;
+      } else
+         ss << "osdmap fsid " << map.fsid << " does not match monitor fsid " << mon->monmap->fsid;
       err = -EINVAL;
     }
     else if (m->cmd[1] == "setmaxosd" && m->cmd.size() > 2) {
index c2f72bb0424b7e05903b7ab57466cb21b323d0a5..b2c897e9db34ccdf3360ad3af0d09bfccee1dbac 100755 (executable)
@@ -35,7 +35,7 @@ ARGS="-d"
 
 # build and inject an initial osd map
 $CEPH_BIN/osdmaptool --clobber --createsimple .ceph_monmap 4 --print .ceph_osdmap # --pgbits 2
-$CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap
+$CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap
 
 for osd in 0 #1 2 3 #4 5 6 7 8 9 10 11 12 13 14 15
 do
index f3fc645e163955a42d799ca984e365e621115144..7f578a19d174e8d4caaeeffe240b6c3acbe043b4 100755 (executable)
@@ -153,7 +153,7 @@ if [ $start_mon -eq 1 ]; then
        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 -i .ceph_osdmap
+               $CEPH_BIN/ceph osd setmap 2 -i .ceph_osdmap 
        fi
 fi