]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: reweight-by-pg for pool(s)
authorSage Weil <sage@redhat.com>
Wed, 6 Aug 2014 15:51:18 +0000 (08:51 -0700)
committerSage Weil <sage@redhat.com>
Tue, 19 Aug 2014 15:16:55 +0000 (08:16 -0700)
Allow the reweight-by-pg to look at a specific set of pools.  If the list
is ommitted, use PGs from all pools.  This allows you to focus on a
specific pool (the one that will dominate data usage).  Otherwise things
may not be quite right because other pools may have PGs that contain
much less data.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 5c4d9af5084fb4861b5d07d5c1d16d39f4281c0a..ad289eaac3938b822f5ab73238a1d7b411cb6cca 100644 (file)
@@ -603,7 +603,8 @@ COMMAND("osd reweight-by-utilization " \
        "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,req=false", \
+       "name=oload,type=CephInt,range=100 " \
+       "name=pools,type=CephPoolname,n=N,req=false", \
        "reweight OSDs by PG distribution [overload-percentage-for-consideration, default 120]", \
        "osd", "rw", "cli,rest")
 COMMAND("osd thrash " \
index c23503acdd15dd5ff107ad65a476f206478cb2a1..7eb90f13be68afc775f0ed7b145a235f9078be9a 100644 (file)
@@ -444,7 +444,7 @@ 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)
+                                       bool by_pg, const set<int64_t> *pools)
 {
   if (oload <= 100) {
     ostringstream oss;
@@ -470,6 +470,8 @@ int OSDMonitor::reweight_by_utilization(int oload, std::string& out_str,
           pgm.pg_stat.begin();
         p != pgm.pg_stat.end();
         ++p) {
+      if (pools && pools->count(p->first.pool()) == 0)
+       continue;
       for (vector<int>::const_iterator q = p->second.acting.begin();
           q != p->second.acting.end();
           ++q) {
@@ -5772,7 +5774,7 @@ done:
     int64_t oload;
     cmd_getval(g_ceph_context, cmdmap, "oload", oload, int64_t(120));
     string out_str;
-    err = reweight_by_utilization(oload, out_str, false);
+    err = reweight_by_utilization(oload, out_str, false, NULL);
     if (err < 0) {
       ss << "FAILED reweight-by-utilization: " << out_str;
     } else if (err == 0) {
@@ -5787,8 +5789,21 @@ done:
   } else if (prefix == "osd reweight-by-pg") {
     int64_t oload;
     cmd_getval(g_ceph_context, cmdmap, "oload", oload, int64_t(120));
+    set<int64_t> pools;
+    vector<string> poolnamevec;
+    cmd_getval(g_ceph_context, cmdmap, "pools", poolnamevec);
+    for (unsigned j = 0; j < poolnamevec.size(); j++) {
+      int64_t pool = osdmap.lookup_pg_pool_name(poolnamevec[j]);
+      if (pool < 0) {
+       ss << "pool '" << poolnamevec[j] << "' does not exist";
+       err = -ENOENT;
+       goto reply;
+      }
+      pools.insert(pool);
+    }
     string out_str;
-    err = reweight_by_utilization(oload, out_str, true);
+    err = reweight_by_utilization(oload, out_str, true,
+                                 pools.size() ? &pools : NULL);
     if (err < 0) {
       ss << "FAILED reweight-by-pg: " << out_str;
     } else if (err == 0) {
index cfe8d43465fcf2c7c6eecbe3f499d1214a5ea9fc..a3e5a456aae4ac330a9977002a507c8ca168ac64 100644 (file)
@@ -219,7 +219,8 @@ private:
   void send_incremental(PaxosServiceMessage *m, epoch_t first);
   void send_incremental(epoch_t first, entity_inst_t& dest, bool onetime);
 
-  int reweight_by_utilization(int oload, std::string& out_str, bool by_pg);
+  int reweight_by_utilization(int oload, std::string& out_str, bool by_pg,
+                             const set<int64_t> *pools);
 
   bool check_source(PaxosServiceMessage *m, uuid_d fsid);