From: Sage Weil Date: Thu, 4 Dec 2014 23:53:26 +0000 (-0800) Subject: mon/OSDMonitor: do not reencode OSDMap on 'osd getmap' X-Git-Tag: v0.91~55^2~2^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f31135c1c878efa97c1224cf7c25f7e1d7e428ed;p=ceph.git mon/OSDMonitor: do not reencode OSDMap on 'osd getmap' 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 --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 180d350d971..44a7f12f660 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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);