From f31135c1c878efa97c1224cf7c25f7e1d7e428ed Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 4 Dec 2014 15:53:26 -0800 Subject: [PATCH] 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 --- src/mon/OSDMonitor.cc | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 180d350d97184..44a7f12f660b6 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); -- 2.39.5