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: v0.94.7~10^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e993851b7abf80fd793aa5b7188f1af7dbe03041;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 (cherry picked from commit ddf5c2b62316bb69839f220fe2527d1467863421) --- diff --git a/doc/man/8/ceph.rst b/doc/man/8/ceph.rst index 97c98ada821..ce37732bf56 100644 --- a/doc/man/8/ceph.rst +++ b/doc/man/8/ceph.rst @@ -946,6 +946,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 a75b067362c..f3773b3d5a2 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -655,12 +655,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 968efc43759..1d394ba6e49 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -467,7 +467,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; @@ -573,15 +574,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); @@ -589,13 +592,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; } } } @@ -6566,8 +6571,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) { @@ -6594,9 +6604,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 3c70cf240e7..1f6e3f3ac4a 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -218,8 +218,8 @@ private: void send_incremental(epoch_t first, MonSession *session, bool onetime); 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);