From 1ecf44eb57a6434e1f3a52859ffd3c4000d4bd00 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 6 Aug 2014 08:51:18 -0700 Subject: [PATCH] mon/OSDMonitor: reweight-by-pg for pool(s) 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 --- src/mon/MonCommands.h | 3 ++- src/mon/OSDMonitor.cc | 21 ++++++++++++++++++--- src/mon/OSDMonitor.h | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 5c4d9af5084fb..ad289eaac3938 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 " \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c23503acdd15d..7eb90f13be68a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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 *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::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 pools; + vector 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) { diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index cfe8d43465fcf..a3e5a456aae4a 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -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 *pools); bool check_source(PaxosServiceMessage *m, uuid_d fsid); -- 2.39.5