]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add sure and no-increasing options to reweight-by-*
authorDan van der Ster <daniel.vanderster@cern.ch>
Fri, 26 Feb 2016 20:52:41 +0000 (21:52 +0100)
committerSage Weil <sage@redhat.com>
Tue, 1 Mar 2016 16:37:58 +0000 (11:37 -0500)
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 <daniel.vanderster@cern.ch>
doc/man/8/ceph.rst
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 7a4319871588613001c798dccc55d142b27895ee..81c5447e70fd17e4176bf2b8744a7c5c7f2d802a 100644 (file)
@@ -982,6 +982,7 @@ Subcommand ``reweight-by-pg`` reweight OSDs by PG distribution
 Usage::
 
        ceph osd reweight-by-pg {<int[100-]>} {<poolname> [<poolname...]}
+       {--no-increasing} {--yes-i-really-mean-it}
 
 Subcommand ``reweight-by-utilization`` reweight OSDs by utilization
 [overload-percentage-for-consideration, default 120].
@@ -989,6 +990,7 @@ Subcommand ``reweight-by-utilization`` reweight OSDs by utilization
 Usage::
 
        ceph osd reweight-by-utilization {<int[100-]>}
+       {--no-increasing} {--yes-i-really-mean-it}
 
 Subcommand ``rm`` removes osd(s) <id> [<id>...] in the cluster.
 
index bb5a93518ce9a75797fe5b2adb5c4f24bee03ad4..247bccba9588676e26fb26fadf2350efd440a219 100644 (file)
@@ -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 " \
index 5908ca4c6a83229d69608c8f31838498ecbff644..997b4aa721431810189406d1aaa90ee00633d5d4 100644 (file)
@@ -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<int64_t> *pools)
+                                       bool by_pg, const set<int64_t> *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) {
index 3e50daeef8d80c10910deac0f1943f785546ab7a..07cbfcc6e20e18c6ec04eae2c75b7496dbe91059 100644 (file)
@@ -228,8 +228,8 @@ public:
                        MonOpRequestRef req = MonOpRequestRef());
 private:
   int reweight_by_utilization(int oload, std::string& out_str, bool by_pg,
-                             const set<int64_t> *pools);
-
+                             const set<int64_t> *pools, bool no_increasing,
+                             bool sure);
   void print_utilization(ostream &out, Formatter *f, bool tree) const;
 
   bool check_source(PaxosServiceMessage *m, uuid_d fsid);