]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mgr/DaemonServer.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / mgr / DaemonServer.cc
index 48534f896ac49815c4c9c007102ae23ab086e42e..f5c0376c7ca63366a38949a4229cac79c2f7a609 100644 (file)
 #define dout_subsys ceph_subsys_mgr
 #undef dout_prefix
 #define dout_prefix *_dout << "mgr.server " << __func__ << " "
+
 using namespace TOPNSPC::common;
+
+using std::list;
+using std::ostringstream;
+using std::string;
+using std::stringstream;
+using std::vector;
+using std::unique_ptr;
+
 namespace {
   template <typename Map>
   bool map_compare(Map const &lhs, Map const &rhs) {
@@ -669,9 +678,11 @@ bool DaemonServer::handle_report(const ref_t<MMgrReport>& m)
   }
 
   // if there are any schema updates, notify the python modules
+  /* no users currently
   if (!m->declare_types.empty() || !m->undeclare_types.empty()) {
     py_modules.notify_all("perf_schema_update", ceph::to_string(key));
   }
+  */
 
   if (m->get_connection()->peer_is_osd()) {
     osd_perf_metric_collector.process_reports(m->osd_perf_metric_reports);
@@ -1046,7 +1057,7 @@ bool DaemonServer::_handle_command(
     if (boost::algorithm::ends_with(prefix, "_json")) {
       format = "json";
     } else {
-      cmd_getval(cmdctx->cmdmap, "format", format, string("plain"));
+      format = cmd_getval_or<string>(cmdctx->cmdmap, "format", "plain");
     }
     f.reset(Formatter::create(format));
   }
@@ -1064,7 +1075,7 @@ bool DaemonServer::_handle_command(
 
     auto dump_cmd = [&cmdnum, &f, m](const MonCommand &mc){
       ostringstream secname;
-      secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
+      secname << "cmd" << std::setfill('0') << std::setw(3) << cmdnum;
       dump_cmddesc_to_json(&f, m->get_connection()->get_features(),
                            secname.str(), mc.cmdstring, mc.helpstring,
                            mc.module, mc.req_perms, 0);
@@ -1235,20 +1246,13 @@ bool DaemonServer::_handle_command(
       return true;
     }
     for (auto& con : p->second) {
-      if (HAVE_FEATURE(con->get_features(), SERVER_MIMIC)) {
-       vector<spg_t> pgs = { spgid };
-       con->send_message(new MOSDScrub2(monc->get_fsid(),
-                                        epoch,
-                                        pgs,
-                                        scrubop == "repair",
-                                        scrubop == "deep-scrub"));
-      } else {
-       vector<pg_t> pgs = { pgid };
-       con->send_message(new MOSDScrub(monc->get_fsid(),
-                                       pgs,
-                                       scrubop == "repair",
-                                       scrubop == "deep-scrub"));
-      }
+      assert(HAVE_FEATURE(con->get_features(), SERVER_OCTOPUS));
+      vector<spg_t> pgs = { spgid };
+      con->send_message(new MOSDScrub2(monc->get_fsid(),
+                                      epoch,
+                                      pgs,
+                                      scrubop == "repair",
+                                      scrubop == "deep-scrub"));
     }
     ss << "instructing pg " << spgid << " on osd." << acting_primary
        << " to " << scrubop;
@@ -1415,8 +1419,7 @@ bool DaemonServer::_handle_command(
     bool dry_run =
       prefix == "osd test-reweight-by-pg" ||
       prefix == "osd test-reweight-by-utilization";
-    int64_t oload;
-    cmd_getval(cmdctx->cmdmap, "oload", oload, int64_t(120));
+    int64_t oload = cmd_getval_or<int64_t>(cmdctx->cmdmap, "oload", 120);
     set<int64_t> pools;
     vector<string> poolnames;
     cmd_getval(cmdctx->cmdmap, "pools", poolnames);
@@ -1450,7 +1453,7 @@ bool DaemonServer::_handle_command(
       return true;
     }
     bool no_increasing = false;
-    cmd_getval(cmdctx->cmdmap, "no_increasing", no_increasing);
+    cmd_getval_compat_cephbool(cmdctx->cmdmap, "no_increasing", no_increasing);
     string out_str;
     mempool::osdmap::map<int32_t, uint32_t> new_weights;
     r = cluster_state.with_osdmap_and_pgmap([&](const OSDMap &osdmap, const PGMap& pgmap) {
@@ -2765,15 +2768,24 @@ void DaemonServer::adjust_pgs()
            } else {
              active = false;
            }
+           unsigned pg_gap = p.get_pg_num() - p.get_pgp_num();
+           unsigned max_jump = cct->_conf->mgr_max_pg_num_change;
            if (!active) {
              dout(10) << "pool " << i.first
                       << " pg_num_target " << p.get_pg_num_target()
                       << " pg_num " << p.get_pg_num()
                       << " - not all pgs active"
                       << dendl;
+           } else if (pg_gap >= max_jump) {
+             dout(10) << "pool " << i.first
+                      << " pg_num " << p.get_pg_num()
+                      << " - pgp_num " << p.get_pgp_num()
+                      << " gap > max_pg_num_change " << max_jump
+                      << " - must scale pgp_num first"
+                      << dendl;
            } else {
              unsigned add = std::min(
-               left,
+               std::min(left, max_jump - pg_gap),
                p.get_pg_num_target() - p.get_pg_num());
              unsigned target = p.get_pg_num() + add;
              left -= add;
@@ -2824,7 +2836,7 @@ void DaemonServer::adjust_pgs()
            // single adjustment that's more than half of the
            // max_misplaced, to somewhat limit the magnitude of
            // our potential error here.
-           int next;
+           unsigned next;
            static constexpr unsigned MAX_NUM_OBJECTS_PER_PG_FOR_LEAP = 1;
            pool_stat_t s = pg_map.get_pg_pool_sum_stat(i.first);
            if (aggro ||