From: Dan van der Ster Date: Fri, 26 Feb 2016 20:52:41 +0000 (+0100) Subject: osd: add sure and no-increasing options to reweight-by-* X-Git-Tag: v10.1.0~198^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ddf5c2b62316bb69839f220fe2527d1467863421;p=ceph.git osd: add sure and no-increasing options to reweight-by-* Add a --no-increasing option to reweight-by-* which can be used to only decrease OSD weights without increasing any. This is useful for example if you need to urgently lower the weight of nearly full OSDs. Also add a --yes-i-really-mean-it confirmation to reweight-by-*. Signed-off-by: Dan van der Ster --- diff --git a/doc/man/8/ceph.rst b/doc/man/8/ceph.rst index 7a4319871588..81c5447e70fd 100644 --- a/doc/man/8/ceph.rst +++ b/doc/man/8/ceph.rst @@ -982,6 +982,7 @@ Subcommand ``reweight-by-pg`` reweight OSDs by PG distribution Usage:: ceph osd reweight-by-pg {} { [} + {--no-increasing} {--yes-i-really-mean-it} Subcommand ``rm`` removes osd(s) [...] in the cluster. diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index bb5a93518ce9..247bccba9588 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -702,12 +702,16 @@ COMMAND("osd pool stats " \ "obtain stats from all pools, or from specified pool", "osd", "r", "cli,rest") COMMAND("osd reweight-by-utilization " \ - "name=oload,type=CephInt,range=100,req=false", \ + "name=oload,type=CephInt,range=100,req=false " \ + "name=no_increasing,type=CephChoices,strings=--no-increasing,req=false " \ + "name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \ "reweight OSDs by utilization [overload-percentage-for-consideration, default 120]", \ "osd", "rw", "cli,rest") COMMAND("osd reweight-by-pg " \ - "name=oload,type=CephInt,range=100 " \ - "name=pools,type=CephPoolname,n=N,req=false", \ + "name=oload,type=CephInt,range=100,req=false " \ + "name=no_increasing,type=CephChoices,strings=--no-increasing,req=false " \ + "name=pools,type=CephPoolname,n=N,req=false " \ + "name=sure,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \ "reweight OSDs by PG distribution [overload-percentage-for-consideration, default 120]", \ "osd", "rw", "cli,rest") COMMAND("osd thrash " \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 5908ca4c6a83..997b4aa72143 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -479,7 +479,8 @@ void OSDMonitor::update_logger() * percentage 'oload' percent greater than the average utilization. */ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, - bool by_pg, const set *pools) + bool by_pg, const set *pools, + bool no_increasing, bool sure) { if (oload <= 100) { ostringstream oss; @@ -585,15 +586,17 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, // to represent e.g. differing storage capacities unsigned weight = osdmap.get_weight(p->first); unsigned new_weight = (unsigned)((average_util / util) * (float)weight); - pending_inc.new_weight[p->first] = new_weight; + if (sure) { + pending_inc.new_weight[p->first] = new_weight; + changed = true; + } char buf[128]; snprintf(buf, sizeof(buf), "osd.%d [%04f -> %04f]", p->first, (float)weight / (float)0x10000, (float)new_weight / (float)0x10000); oss << buf << sep; - changed = true; } - if (util <= underload_util) { + if (!no_increasing && util <= underload_util) { // assign a higher weight.. if we can. unsigned weight = osdmap.get_weight(p->first); unsigned new_weight = (unsigned)((average_util / util) * (float)weight); @@ -601,13 +604,15 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str, new_weight = 0x10000; if (new_weight > weight) { sep = ", "; - pending_inc.new_weight[p->first] = new_weight; + if (sure) { + pending_inc.new_weight[p->first] = new_weight; + changed = true; + } char buf[128]; snprintf(buf, sizeof(buf), "osd.%d [%04f -> %04f]", p->first, (float)weight / (float)0x10000, (float)new_weight / (float)0x10000); oss << buf << sep; - changed = true; } } } @@ -7421,8 +7426,13 @@ done: } else if (prefix == "osd reweight-by-utilization") { int64_t oload; cmd_getval(g_ceph_context, cmdmap, "oload", oload, int64_t(120)); + string no_increasing, sure; + cmd_getval(g_ceph_context, cmdmap, "no_increasing", no_increasing); + cmd_getval(g_ceph_context, cmdmap, "sure", sure); string out_str; - err = reweight_by_utilization(oload, out_str, false, NULL); + err = reweight_by_utilization(oload, out_str, false, NULL, + no_increasing == "--no-increasing", + sure == "--yes-i-really-mean-it"); if (err < 0) { ss << "FAILED reweight-by-utilization: " << out_str; } else if (err == 0) { @@ -7449,9 +7459,14 @@ done: } pools.insert(pool); } + string no_increasing, sure; + cmd_getval(g_ceph_context, cmdmap, "no_increasing", no_increasing); + cmd_getval(g_ceph_context, cmdmap, "sure", sure); string out_str; err = reweight_by_utilization(oload, out_str, true, - pools.empty() ? NULL : &pools); + pools.empty() ? NULL : &pools, + no_increasing == "--no-increasing", + sure == "--yes-i-really-mean-it"); if (err < 0) { ss << "FAILED reweight-by-pg: " << out_str; } else if (err == 0) { diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 3e50daeef8d8..07cbfcc6e20e 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -228,8 +228,8 @@ public: MonOpRequestRef req = MonOpRequestRef()); private: int reweight_by_utilization(int oload, std::string& out_str, bool by_pg, - const set *pools); - + const set *pools, bool no_increasing, + bool sure); void print_utilization(ostream &out, Formatter *f, bool tree) const; bool check_source(PaxosServiceMessage *m, uuid_d fsid);