]> git.proxmox.com Git - ceph.git/blame - ceph/src/mon/PGMap.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / mon / PGMap.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15/*
16 * Placement Group Map. Placement Groups are logical sets of objects
17 * that are replicated by the same set of devices. pgid=(r,hash(o)&m)
18 * where & is a bit-wise AND and m=2^k-1
19 */
20
21#ifndef CEPH_PGMAP_H
22#define CEPH_PGMAP_H
23
224ce89b 24#include "include/health.h"
7c673cae
FG
25#include "common/debug.h"
26#include "common/TextTable.h"
27#include "osd/osd_types.h"
31f18b77 28#include "include/mempool.h"
224ce89b 29#include "mon/health_check.h"
7c673cae 30#include <sstream>
7c673cae
FG
31
32namespace ceph { class Formatter; }
33
31f18b77 34class PGMapDigest {
7c673cae 35public:
31f18b77
FG
36 MEMPOOL_CLASS_HELPERS();
37 virtual ~PGMapDigest() {}
38
39 mempool::pgmap::vector<uint64_t> osd_last_seq;
40
41 mutable std::map<int, int64_t> avail_space_by_rule;
42
43 // aggregate state, populated by PGMap child
44 int64_t num_pg = 0, num_osd = 0;
45 int64_t num_pg_active = 0;
46 int64_t num_pg_unknown = 0;
47 mempool::pgmap::unordered_map<int32_t,pool_stat_t> pg_pool_sum;
48 mempool::pgmap::map<int64_t,int64_t> num_pg_by_pool;
49 pool_stat_t pg_sum;
50 osd_stat_t osd_sum;
9f95a23c 51 mempool::pgmap::map<std::string,osd_stat_t> osd_sum_by_class;
11fdf7f2 52 mempool::pgmap::unordered_map<uint64_t,int32_t> num_pg_by_state;
31f18b77
FG
53 struct pg_count {
54 int32_t acting = 0;
81eedcae 55 int32_t up_not_acting = 0;
31f18b77 56 int32_t primary = 0;
9f95a23c 57 void encode(ceph::buffer::list& bl) const {
11fdf7f2
TL
58 using ceph::encode;
59 encode(acting, bl);
81eedcae 60 encode(up_not_acting, bl);
11fdf7f2 61 encode(primary, bl);
31f18b77 62 }
9f95a23c 63 void decode(ceph::buffer::list::const_iterator& p) {
11fdf7f2
TL
64 using ceph::decode;
65 decode(acting, p);
81eedcae 66 decode(up_not_acting, p);
11fdf7f2 67 decode(primary, p);
31f18b77
FG
68 }
69 };
70 mempool::pgmap::unordered_map<int32_t,pg_count> num_pg_by_osd;
71
11fdf7f2
TL
72 mempool::pgmap::map<int64_t,interval_set<snapid_t>> purged_snaps;
73
81eedcae
TL
74 bool use_per_pool_stats() const {
75 return osd_sum.num_osds == osd_sum.num_per_pool_osds;
76 }
9f95a23c
TL
77 bool use_per_pool_omap_stats() const {
78 return osd_sum.num_osds == osd_sum.num_per_pool_omap_osds;
79 }
81eedcae 80
31f18b77
FG
81 // recent deltas, and summation
82 /**
83 * keep track of last deltas for each pool, calculated using
84 * @p pg_pool_sum as baseline.
85 */
9f95a23c 86 mempool::pgmap::unordered_map<int64_t, mempool::pgmap::list<std::pair<pool_stat_t, utime_t> > > per_pool_sum_deltas;
31f18b77
FG
87 /**
88 * keep track of per-pool timestamp deltas, according to last update on
89 * each pool.
90 */
11fdf7f2 91 mempool::pgmap::unordered_map<int64_t, utime_t> per_pool_sum_deltas_stamps;
31f18b77
FG
92 /**
93 * keep track of sum deltas, per-pool, taking into account any previous
94 * deltas existing in @p per_pool_sum_deltas. The utime_t as second member
11fdf7f2 95 * of the pair is the timestamp referring to the last update (i.e., the first
31f18b77
FG
96 * member of the pair) for a given pool.
97 */
9f95a23c 98 mempool::pgmap::unordered_map<int64_t, std::pair<pool_stat_t,utime_t> > per_pool_sum_delta;
31f18b77
FG
99
100 pool_stat_t pg_sum_delta;
101 utime_t stamp_delta;
102
11fdf7f2
TL
103 void get_recovery_stats(
104 double *misplaced_ratio,
105 double *degraded_ratio,
106 double *inactive_ratio,
107 double *unknown_pgs_ratio) const;
31f18b77 108
9f95a23c
TL
109 void print_summary(ceph::Formatter *f, std::ostream *out) const;
110 void print_oneline_summary(ceph::Formatter *f, std::ostream *out) const;
31f18b77 111
9f95a23c 112 void recovery_summary(ceph::Formatter *f, std::list<std::string> *psl,
b32b8144 113 const pool_stat_t& pool_sum) const;
9f95a23c
TL
114 void overall_recovery_summary(ceph::Formatter *f, std::list<std::string> *psl) const;
115 void pool_recovery_summary(ceph::Formatter *f, std::list<std::string> *psl,
31f18b77 116 uint64_t poolid) const;
9f95a23c 117 void recovery_rate_summary(ceph::Formatter *f, std::ostream *out,
31f18b77
FG
118 const pool_stat_t& delta_sum,
119 utime_t delta_stamp) const;
9f95a23c
TL
120 void overall_recovery_rate_summary(ceph::Formatter *f, std::ostream *out) const;
121 void pool_recovery_rate_summary(ceph::Formatter *f, std::ostream *out,
31f18b77
FG
122 uint64_t poolid) const;
123 /**
124 * Obtain a formatted/plain output for client I/O, source from stats for a
125 * given @p delta_sum pool over a given @p delta_stamp period of time.
126 */
9f95a23c 127 void client_io_rate_summary(ceph::Formatter *f, std::ostream *out,
31f18b77
FG
128 const pool_stat_t& delta_sum,
129 utime_t delta_stamp) const;
130 /**
131 * Obtain a formatted/plain output for the overall client I/O, which is
132 * calculated resorting to @p pg_sum_delta and @p stamp_delta.
133 */
9f95a23c 134 void overall_client_io_rate_summary(ceph::Formatter *f, std::ostream *out) const;
31f18b77
FG
135 /**
136 * Obtain a formatted/plain output for client I/O over a given pool
137 * with id @p pool_id. We will then obtain pool-specific data
138 * from @p per_pool_sum_delta.
139 */
9f95a23c 140 void pool_client_io_rate_summary(ceph::Formatter *f, std::ostream *out,
31f18b77
FG
141 uint64_t poolid) const;
142 /**
143 * Obtain a formatted/plain output for cache tier IO, source from stats for a
144 * given @p delta_sum pool over a given @p delta_stamp period of time.
145 */
9f95a23c 146 void cache_io_rate_summary(ceph::Formatter *f, std::ostream *out,
31f18b77
FG
147 const pool_stat_t& delta_sum,
148 utime_t delta_stamp) const;
149 /**
150 * Obtain a formatted/plain output for the overall cache tier IO, which is
151 * calculated resorting to @p pg_sum_delta and @p stamp_delta.
152 */
9f95a23c 153 void overall_cache_io_rate_summary(ceph::Formatter *f, std::ostream *out) const;
31f18b77
FG
154 /**
155 * Obtain a formatted/plain output for cache tier IO over a given pool
156 * with id @p pool_id. We will then obtain pool-specific data
157 * from @p per_pool_sum_delta.
158 */
9f95a23c 159 void pool_cache_io_rate_summary(ceph::Formatter *f, std::ostream *out,
31f18b77
FG
160 uint64_t poolid) const;
161
d2e6a577
FG
162 /**
163 * Return the number of additional bytes that can be stored in this
164 * pool before the first OSD fills up, accounting for PG overhead.
165 */
166 int64_t get_pool_free_space(const OSDMap &osd_map, int64_t poolid) const;
167
11fdf7f2
TL
168
169 /**
170 * Dump pool usage and io ops/bytes, used by "ceph df" command
171 */
9f95a23c
TL
172 virtual void dump_pool_stats_full(const OSDMap &osd_map, std::stringstream *ss,
173 ceph::Formatter *f, bool verbose) const;
174 void dump_cluster_stats(std::stringstream *ss, ceph::Formatter *f, bool verbose) const;
175 static void dump_object_stat_sum(TextTable &tbl, ceph::Formatter *f,
176 const pool_stat_t &pool_stat,
177 uint64_t avail,
178 float raw_used_rate,
179 bool verbose,
180 bool per_pool,
181 bool per_pool_omap,
81eedcae 182 const pg_pool_t *pool);
31f18b77
FG
183
184 size_t get_num_pg_by_osd(int osd) const {
185 auto p = num_pg_by_osd.find(osd);
186 if (p == num_pg_by_osd.end())
187 return 0;
188 else
189 return p->second.acting;
190 }
191 int get_num_primary_pg_by_osd(int osd) const {
192 auto p = num_pg_by_osd.find(osd);
193 if (p == num_pg_by_osd.end())
194 return 0;
195 else
196 return p->second.primary;
197 }
198
d2e6a577 199 ceph_statfs get_statfs(OSDMap &osdmap,
20effc67 200 std::optional<int64_t> data_pool) const;
31f18b77
FG
201
202 int64_t get_rule_avail(int ruleno) const {
203 auto i = avail_space_by_rule.find(ruleno);
204 if (i != avail_space_by_rule.end())
205 return avail_space_by_rule[ruleno];
206 else
207 return 0;
208 }
209
181888fb
FG
210 // kill me post-mimic or -nautilus
211 bool definitely_converted_snapsets() const {
212 // false negative is okay; false positive is not!
213 return
214 num_pg &&
215 num_pg_unknown == 0 &&
216 pg_sum.stats.sum.num_legacy_snapsets == 0;
217 }
218
31f18b77
FG
219 uint64_t get_last_osd_stat_seq(int osd) {
220 if (osd < (int)osd_last_seq.size())
221 return osd_last_seq[osd];
222 return 0;
223 }
224
9f95a23c
TL
225 void encode(ceph::buffer::list& bl, uint64_t features) const;
226 void decode(ceph::buffer::list::const_iterator& p);
227 void dump(ceph::Formatter *f) const;
228 static void generate_test_instances(std::list<PGMapDigest*>& ls);
31f18b77
FG
229};
230WRITE_CLASS_ENCODER(PGMapDigest::pg_count);
231WRITE_CLASS_ENCODER_FEATURES(PGMapDigest);
232
233class PGMap : public PGMapDigest {
234public:
235 MEMPOOL_CLASS_HELPERS();
236
7c673cae
FG
237 // the map
238 version_t version;
239 epoch_t last_osdmap_epoch; // last osdmap epoch i applied to the pgmap
240 epoch_t last_pg_scan; // osdmap epoch
31f18b77
FG
241 mempool::pgmap::unordered_map<int32_t,osd_stat_t> osd_stat;
242 mempool::pgmap::unordered_map<pg_t,pg_stat_t> pg_stat;
7c673cae 243
11fdf7f2
TL
244 typedef mempool::pgmap::map<
245 std::pair<int64_t, int>, // <pool, osd>
246 store_statfs_t>
247 per_osd_pool_statfs_t;
248
249 per_osd_pool_statfs_t pool_statfs;
7c673cae
FG
250
251 class Incremental {
252 public:
31f18b77 253 MEMPOOL_CLASS_HELPERS();
7c673cae 254 version_t version;
31f18b77 255 mempool::pgmap::map<pg_t,pg_stat_t> pg_stat_updates;
7c673cae
FG
256 epoch_t osdmap_epoch;
257 epoch_t pg_scan; // osdmap epoch
31f18b77 258 mempool::pgmap::set<pg_t> pg_remove;
7c673cae 259 utime_t stamp;
11fdf7f2 260 per_osd_pool_statfs_t pool_statfs_updates;
7c673cae
FG
261
262 private:
31f18b77
FG
263 mempool::pgmap::map<int32_t,osd_stat_t> osd_stat_updates;
264 mempool::pgmap::set<int32_t> osd_stat_rm;
7c673cae
FG
265 public:
266
31f18b77 267 const mempool::pgmap::map<int32_t, osd_stat_t> &get_osd_stat_updates() const {
7c673cae
FG
268 return osd_stat_updates;
269 }
31f18b77 270 const mempool::pgmap::set<int32_t> &get_osd_stat_rm() const {
7c673cae
FG
271 return osd_stat_rm;
272 }
31f18b77 273 template<typename OsdStat>
11fdf7f2 274 void update_stat(int32_t osd, OsdStat&& stat) {
31f18b77 275 osd_stat_updates[osd] = std::forward<OsdStat>(stat);
7c673cae 276 }
11fdf7f2 277 void stat_osd_out(int32_t osd) {
7c673cae
FG
278 osd_stat_updates[osd] = osd_stat_t();
279 }
11fdf7f2 280 void stat_osd_down_up(int32_t osd, const PGMap& pg_map) {
7c673cae 281 // 0 the op_queue_age_hist for this osd
31f18b77 282 auto p = osd_stat_updates.find(osd);
7c673cae
FG
283 if (p != osd_stat_updates.end()) {
284 p->second.op_queue_age_hist.clear();
285 return;
286 }
31f18b77 287 auto q = pg_map.osd_stat.find(osd);
7c673cae
FG
288 if (q != pg_map.osd_stat.end()) {
289 osd_stat_t& t = osd_stat_updates[osd] = q->second;
290 t.op_queue_age_hist.clear();
291 }
292 }
293 void rm_stat(int32_t osd) {
294 osd_stat_rm.insert(osd);
7c673cae
FG
295 osd_stat_updates.erase(osd);
296 }
9f95a23c
TL
297 void dump(ceph::Formatter *f) const;
298 static void generate_test_instances(std::list<Incremental*>& o);
7c673cae 299
11fdf7f2 300 Incremental() : version(0), osdmap_epoch(0), pg_scan(0) {}
7c673cae
FG
301 };
302
303
304 // aggregate stats (soft state), generated by calc_stats()
9f95a23c 305 mempool::pgmap::unordered_map<int,std::set<pg_t> > pg_by_osd;
31f18b77 306 mempool::pgmap::unordered_map<int,int> blocked_by_sum;
9f95a23c 307 mempool::pgmap::list<std::pair<pool_stat_t, utime_t> > pg_sum_deltas;
11fdf7f2 308 mempool::pgmap::unordered_map<int64_t,mempool::pgmap::unordered_map<uint64_t,int32_t>> num_pg_by_pool_state;
7c673cae
FG
309
310 utime_t stamp;
311
31f18b77
FG
312 void update_pool_deltas(
313 CephContext *cct,
314 const utime_t ts,
11fdf7f2 315 const mempool::pgmap::unordered_map<int32_t, pool_stat_t>& pg_pool_sum_old);
7c673cae
FG
316 void clear_delta();
317
318 void deleted_pool(int64_t pool) {
11fdf7f2
TL
319 for (auto i = pool_statfs.begin(); i != pool_statfs.end();) {
320 if (i->first.first == pool) {
321 i = pool_statfs.erase(i);
322 } else {
323 ++i;
324 }
325 }
326
7c673cae 327 pg_pool_sum.erase(pool);
11fdf7f2 328 num_pg_by_pool_state.erase(pool);
31f18b77 329 num_pg_by_pool.erase(pool);
7c673cae
FG
330 per_pool_sum_deltas.erase(pool);
331 per_pool_sum_deltas_stamps.erase(pool);
332 per_pool_sum_delta.erase(pool);
333 }
334
335 private:
31f18b77
FG
336 void update_delta(
337 CephContext *cct,
338 const utime_t ts,
339 const pool_stat_t& old_pool_sum,
340 utime_t *last_ts,
341 const pool_stat_t& current_pool_sum,
342 pool_stat_t *result_pool_delta,
343 utime_t *result_ts_delta,
9f95a23c 344 mempool::pgmap::list<std::pair<pool_stat_t,utime_t> > *delta_avg_list);
7c673cae
FG
345
346 void update_one_pool_delta(CephContext *cct,
347 const utime_t ts,
11fdf7f2 348 const int64_t pool,
7c673cae
FG
349 const pool_stat_t& old_pool_sum);
350
7c673cae
FG
351 public:
352
31f18b77 353 mempool::pgmap::set<pg_t> creating_pgs;
9f95a23c 354 mempool::pgmap::map<int,std::map<epoch_t,std::set<pg_t> > > creating_pgs_by_osd_epoch;
7c673cae
FG
355
356 // Bits that use to be enum StuckPG
357 static const int STUCK_INACTIVE = (1<<0);
358 static const int STUCK_UNCLEAN = (1<<1);
359 static const int STUCK_UNDERSIZED = (1<<2);
360 static const int STUCK_DEGRADED = (1<<3);
361 static const int STUCK_STALE = (1<<4);
362
363 PGMap()
364 : version(0),
11fdf7f2 365 last_osdmap_epoch(0), last_pg_scan(0)
7c673cae
FG
366 {}
367
7c673cae
FG
368 version_t get_version() const {
369 return version;
370 }
371 void set_version(version_t v) {
372 version = v;
373 }
374 epoch_t get_last_osdmap_epoch() const {
375 return last_osdmap_epoch;
376 }
377 void set_last_osdmap_epoch(epoch_t e) {
378 last_osdmap_epoch = e;
379 }
380 epoch_t get_last_pg_scan() const {
381 return last_pg_scan;
382 }
383 void set_last_pg_scan(epoch_t e) {
384 last_pg_scan = e;
385 }
386 utime_t get_stamp() const {
387 return stamp;
388 }
389 void set_stamp(utime_t s) {
390 stamp = s;
391 }
392
7c673cae 393 pool_stat_t get_pg_pool_sum_stat(int64_t pool) const {
31f18b77 394 auto p = pg_pool_sum.find(pool);
7c673cae
FG
395 if (p != pg_pool_sum.end())
396 return p->second;
397 return pool_stat_t();
398 }
399
9f95a23c 400 osd_stat_t get_osd_sum(const std::set<int>& osds) const {
11fdf7f2
TL
401 if (osds.empty()) // all
402 return osd_sum;
403 osd_stat_t sum;
404 for (auto i : osds) {
405 auto os = get_osd_stat(i);
406 if (os)
407 sum.add(*os);
408 }
409 return sum;
410 }
411
412 const osd_stat_t *get_osd_stat(int osd) const {
413 auto i = osd_stat.find(osd);
414 if (i == osd_stat.end()) {
415 return nullptr;
416 }
417 return &i->second;
418 }
7c673cae 419
7c673cae
FG
420
421 void apply_incremental(CephContext *cct, const Incremental& inc);
7c673cae
FG
422 void calc_stats();
423 void stat_pg_add(const pg_t &pgid, const pg_stat_t &s,
424 bool sameosds=false);
11fdf7f2 425 bool stat_pg_sub(const pg_t &pgid, const pg_stat_t &s,
7c673cae 426 bool sameosds=false);
11fdf7f2
TL
427 void calc_purged_snaps();
428 void calc_osd_sum_by_class(const OSDMap& osdmap);
31f18b77
FG
429 void stat_osd_add(int osd, const osd_stat_t &s);
430 void stat_osd_sub(int osd, const osd_stat_t &s);
7c673cae 431
9f95a23c
TL
432 void encode(ceph::buffer::list &bl, uint64_t features=-1) const;
433 void decode(ceph::buffer::list::const_iterator &bl);
7c673cae 434
31f18b77
FG
435 /// encode subset of our data to a PGMapDigest
436 void encode_digest(const OSDMap& osdmap,
9f95a23c 437 ceph::buffer::list& bl, uint64_t features);
7c673cae 438
31f18b77
FG
439 int64_t get_rule_avail(const OSDMap& osdmap, int ruleno) const;
440 void get_rules_avail(const OSDMap& osdmap,
441 std::map<int,int64_t> *avail_map) const;
9f95a23c
TL
442 void dump(ceph::Formatter *f, bool with_net = true) const;
443 void dump_basic(ceph::Formatter *f) const;
444 void dump_pg_stats(ceph::Formatter *f, bool brief) const;
20effc67 445 void dump_pg_progress(ceph::Formatter *f) const;
9f95a23c
TL
446 void dump_pool_stats(ceph::Formatter *f) const;
447 void dump_osd_stats(ceph::Formatter *f, bool with_net = true) const;
448 void dump_osd_ping_times(ceph::Formatter *f) const;
449 void dump_delta(ceph::Formatter *f) const;
450 void dump_filtered_pg_stats(ceph::Formatter *f, std::set<pg_t>& pgs) const;
451 void dump_pool_stats_full(const OSDMap &osd_map, std::stringstream *ss,
452 ceph::Formatter *f, bool verbose) const override {
31f18b77
FG
453 get_rules_avail(osd_map, &avail_space_by_rule);
454 PGMapDigest::dump_pool_stats_full(osd_map, ss, f, verbose);
455 }
7c673cae 456
11fdf7f2
TL
457 /*
458 * Dump client io rate, recovery io rate, cache io rate and recovery information.
459 * this function is used by "ceph osd pool stats" command
460 */
9f95a23c
TL
461 void dump_pool_stats_and_io_rate(int64_t poolid, const OSDMap &osd_map, ceph::Formatter *f,
462 std::stringstream *ss) const;
11fdf7f2 463
20effc67 464 static void dump_pg_stats_plain(
9f95a23c 465 std::ostream& ss,
31f18b77 466 const mempool::pgmap::unordered_map<pg_t, pg_stat_t>& pg_stats,
20effc67 467 bool brief);
31f18b77
FG
468 void get_stuck_stats(
469 int types, const utime_t cutoff,
470 mempool::pgmap::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const;
9f95a23c
TL
471 void dump_stuck(ceph::Formatter *f, int types, utime_t cutoff) const;
472 void dump_stuck_plain(std::ostream& ss, int types, utime_t cutoff) const;
473 int dump_stuck_pg_stats(std::stringstream &ds,
474 ceph::Formatter *f,
475 int threshold,
476 std::vector<std::string>& args) const;
477 void dump(std::ostream& ss) const;
478 void dump_basic(std::ostream& ss) const;
479 void dump_pg_stats(std::ostream& ss, bool brief) const;
480 void dump_pg_sum_stats(std::ostream& ss, bool header) const;
481 void dump_pool_stats(std::ostream& ss, bool header) const;
482 void dump_osd_stats(std::ostream& ss) const;
483 void dump_osd_sum_stats(std::ostream& ss) const;
484 void dump_filtered_pg_stats(std::ostream& ss, std::set<pg_t>& pgs) const;
485
486 void dump_osd_perf_stats(ceph::Formatter *f) const;
7c673cae
FG
487 void print_osd_perf_stats(std::ostream *ss) const;
488
9f95a23c 489 void dump_osd_blocked_by_stats(ceph::Formatter *f) const;
7c673cae
FG
490 void print_osd_blocked_by_stats(std::ostream *ss) const;
491
11fdf7f2 492 void get_filtered_pg_stats(uint64_t state, int64_t poolid, int64_t osdid,
9f95a23c 493 bool primary, std::set<pg_t>& pgs) const;
7c673cae 494
f67539c2 495 std::set<std::string> osd_parentage(const OSDMap& osdmap, int id) const;
224ce89b
WB
496 void get_health_checks(
497 CephContext *cct,
498 const OSDMap& osdmap,
499 health_check_map_t *checks) const;
f67539c2 500 void print_summary(ceph::Formatter *f, std::ostream *out) const;
224ce89b 501
9f95a23c 502 static void generate_test_instances(std::list<PGMap*>& o);
7c673cae 503};
7c673cae
FG
504WRITE_CLASS_ENCODER_FEATURES(PGMap)
505
9f95a23c 506inline std::ostream& operator<<(std::ostream& out, const PGMapDigest& m) {
7c673cae
FG
507 m.print_oneline_summary(NULL, &out);
508 return out;
509}
510
511int process_pg_map_command(
9f95a23c 512 const std::string& prefix,
11fdf7f2 513 const cmdmap_t& cmdmap,
7c673cae
FG
514 const PGMap& pg_map,
515 const OSDMap& osdmap,
9f95a23c
TL
516 ceph::Formatter *f,
517 std::stringstream *ss,
518 ceph::buffer::list *odata);
7c673cae
FG
519
520class PGMapUpdater
521{
522public:
31f18b77
FG
523 static void check_osd_map(
524 CephContext *cct,
525 const OSDMap &osdmap,
526 const PGMap& pg_map,
527 PGMap::Incremental *pending_inc);
7c673cae
FG
528
529 // mark pg's state stale if its acting primary osd is down
530 static void check_down_pgs(
531 const OSDMap &osd_map,
532 const PGMap &pg_map,
533 bool check_all,
9f95a23c 534 const std::set<int>& need_check_down_pg_osds,
7c673cae
FG
535 PGMap::Incremental *pending_inc);
536};
537
538namespace reweight {
539/* Assign a lower weight to overloaded OSDs.
540 *
541 * The osds that will get a lower weight are those with with a utilization
542 * percentage 'oload' percent greater than the average utilization.
543 */
544 int by_utilization(const OSDMap &osd_map,
545 const PGMap &pg_map,
546 int oload,
547 double max_changef,
548 int max_osds,
9f95a23c 549 bool by_pg, const std::set<int64_t> *pools,
7c673cae
FG
550 bool no_increasing,
551 mempool::osdmap::map<int32_t, uint32_t>* new_weights,
552 std::stringstream *ss,
553 std::string *out_str,
9f95a23c 554 ceph::Formatter *f);
7c673cae
FG
555}
556
557#endif