]> 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>
Thu, 10 Mar 2016 13:16:32 +0000 (08:16 -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>
(cherry picked from commit ddf5c2b62316bb69839f220fe2527d1467863421)

doc/man/8/ceph.rst
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 97c98ada8214fcae76730806ec16854c277aa71c..ce37732bf56e2398c1b00c1e85ca777c23364841 100644 (file)
@@ -946,6 +946,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].
@@ -953,6 +954,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 a75b067362ccb5c074d206358e9f7afc1e6af13a..f3773b3d5a2fde3657ab280e5793533bae3b78f9 100644 (file)
@@ -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 " \
index 968efc43759836590ce2b5eb70ef34e63583c8ad..1d394ba6e49a03a0f040164815f5b0bcd937440c 100644 (file)
@@ -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<int64_t> *pools)
+                                       bool by_pg, const set<int64_t> *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) {
index 3c70cf240e7f8103a40a0944c42836622e7597d9..1f6e3f3ac4aa64a062041cd3501e9690e163c5ce 100644 (file)
@@ -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<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);