]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: do not reencode OSDMap on 'osd getmap'
authorSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 23:53:26 +0000 (15:53 -0800)
committerSage Weil <sage@redhat.com>
Fri, 12 Dec 2014 19:08:40 +0000 (11:08 -0800)
Return the bits unmolested.

This is a slight change in that we do not reencode based on the client's
features.  However, this is an admin command and the client is generally
the CLI or REST API.  It makes more sense to provide the unmolested
bits than to reencode them based on features present in a tool that
never inspects the map.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc

index 180d350d9718487571b1575babb5c343921b6805..44a7f12f660b6eca8f40f28995fbccd81f2391f6 100644 (file)
@@ -2363,21 +2363,27 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
     int64_t epochnum;
     cmd_getval(g_ceph_context, cmdmap, "epoch", epochnum, (int64_t)0);
     epoch = epochnum;
+    if (!epoch)
+      epoch = osdmap.get_epoch();
 
-    OSDMap *p = &osdmap;
-    if (epoch) {
-      bufferlist b;
-      int err = get_version_full(epoch, b);
-      if (err == -ENOENT) {
-       r = -ENOENT;
-        ss << "there is no map for epoch " << epoch;
-       goto reply;
-      }
-      assert(err == 0);
-      assert(b.length());
+    bufferlist osdmap_bl;
+    int err = get_version_full(epoch, osdmap_bl);
+    if (err == -ENOENT) {
+      r = -ENOENT;
+      ss << "there is no map for epoch " << epoch;
+      goto reply;
+    }
+    assert(err == 0);
+    assert(osdmap_bl.length());
+
+    OSDMap *p;
+    if (epoch == osdmap.get_epoch()) {
+      p = &osdmap;
+    } else {
       p = new OSDMap;
-      p->decode(b);
+      p->decode(osdmap_bl);
     }
+
     if (prefix == "osd dump") {
       stringstream ds;
       if (f) {
@@ -2424,7 +2430,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
       } 
       rdata.append(ds);
     } else if (prefix == "osd getmap") {
-      p->encode(rdata, m->get_connection()->get_features());
+      rdata.append(osdmap_bl);
       ss << "got osdmap epoch " << p->get_epoch();
     } else if (prefix == "osd getcrushmap") {
       p->crush->encode(rdata);