]> git.proxmox.com Git - ceph.git/blob - ceph/src/osd/OSDMap.h
6639b4f65ed519c0e2842391ed0dc9eed5e5a0c3
[ceph.git] / ceph / src / osd / OSDMap.h
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 * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
8 *
9 * Author: Loic Dachary <loic@dachary.org>
10 *
11 * This is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License version 2.1, as published by the Free Software
14 * Foundation. See file COPYING.
15 *
16 */
17
18
19 #ifndef CEPH_OSDMAP_H
20 #define CEPH_OSDMAP_H
21
22 #include "include/cpp-btree/btree_map.h"
23
24 /*
25 * describe properties of the OSD cluster.
26 * disks, disk groups, total # osds,
27 *
28 */
29 #include "include/types.h"
30 #include "osd_types.h"
31
32 //#include "include/ceph_features.h"
33 #include "crush/CrushWrapper.h"
34 #include <vector>
35 #include <list>
36 #include <set>
37 #include <map>
38 #include "include/memory.h"
39 using namespace std;
40
41 // forward declaration
42 class CephContext;
43 class CrushWrapper;
44
45 // FIXME C++11 does not have std::equal for two differently-typed containers.
46 // use this until we move to c++14
47 template<typename A, typename B>
48 bool vectors_equal(A a, B b)
49 {
50 return
51 a.size() == b.size() &&
52 (a.empty() ||
53 memcmp((char*)&a[0], (char*)&b[0], sizeof(a[0]) * a.size()) == 0);
54 }
55
56
57 /*
58 * we track up to two intervals during which the osd was alive and
59 * healthy. the most recent is [up_from,up_thru), where up_thru is
60 * the last epoch the osd is known to have _started_. i.e., a lower
61 * bound on the actual osd death. down_at (if it is > up_from) is an
62 * upper bound on the actual osd death.
63 *
64 * the second is the last_clean interval [first,last]. in that case,
65 * the last interval is the last epoch known to have been either
66 * _finished_, or during which the osd cleanly shut down. when
67 * possible, we push this forward to the epoch the osd was eventually
68 * marked down.
69 *
70 * the lost_at is used to allow build_prior to proceed without waiting
71 * for an osd to recover. In certain cases, progress may be blocked
72 * because an osd is down that may contain updates (i.e., a pg may have
73 * gone rw during an interval). If the osd can't be brought online, we
74 * can force things to proceed knowing that we _might_ be losing some
75 * acked writes. If the osd comes back to life later, that's fine to,
76 * but those writes will still be lost (the divergent objects will be
77 * thrown out).
78 */
79 struct osd_info_t {
80 epoch_t last_clean_begin; // last interval that ended with a clean osd shutdown
81 epoch_t last_clean_end;
82 epoch_t up_from; // epoch osd marked up
83 epoch_t up_thru; // lower bound on actual osd death (if > up_from)
84 epoch_t down_at; // upper bound on actual osd death (if > up_from)
85 epoch_t lost_at; // last epoch we decided data was "lost"
86
87 osd_info_t() : last_clean_begin(0), last_clean_end(0),
88 up_from(0), up_thru(0), down_at(0), lost_at(0) {}
89
90 void dump(Formatter *f) const;
91 void encode(bufferlist& bl) const;
92 void decode(bufferlist::iterator& bl);
93 static void generate_test_instances(list<osd_info_t*>& o);
94 };
95 WRITE_CLASS_ENCODER(osd_info_t)
96
97 ostream& operator<<(ostream& out, const osd_info_t& info);
98
99 struct osd_xinfo_t {
100 utime_t down_stamp; ///< timestamp when we were last marked down
101 float laggy_probability; ///< encoded as __u32: 0 = definitely not laggy, 0xffffffff definitely laggy
102 __u32 laggy_interval; ///< average interval between being marked laggy and recovering
103 uint64_t features; ///< features supported by this osd we should know about
104 __u32 old_weight; ///< weight prior to being auto marked out
105
106 osd_xinfo_t() : laggy_probability(0), laggy_interval(0),
107 features(0), old_weight(0) {}
108
109 void dump(Formatter *f) const;
110 void encode(bufferlist& bl) const;
111 void decode(bufferlist::iterator& bl);
112 static void generate_test_instances(list<osd_xinfo_t*>& o);
113 };
114 WRITE_CLASS_ENCODER(osd_xinfo_t)
115
116 ostream& operator<<(ostream& out, const osd_xinfo_t& xi);
117
118
119 struct PGTempMap {
120 #if 1
121 bufferlist data;
122 typedef btree::btree_map<pg_t,int32_t*> map_t;
123 map_t map;
124
125 void encode(bufferlist& bl) const {
126 uint32_t n = map.size();
127 ::encode(n, bl);
128 for (auto &p : map) {
129 ::encode(p.first, bl);
130 bl.append((char*)p.second, (*p.second + 1) * sizeof(int32_t));
131 }
132 }
133 void decode(bufferlist::iterator& p) {
134 data.clear();
135 map.clear();
136 uint32_t n;
137 ::decode(n, p);
138 if (!n)
139 return;
140 bufferlist::iterator pstart = p;
141 size_t start_off = pstart.get_off();
142 vector<pair<pg_t,size_t>> offsets;
143 offsets.resize(n);
144 for (unsigned i=0; i<n; ++i) {
145 pg_t pgid;
146 ::decode(pgid, p);
147 offsets[i].first = pgid;
148 offsets[i].second = p.get_off() - start_off;
149 uint32_t vn;
150 ::decode(vn, p);
151 p.advance(vn * sizeof(int32_t));
152 }
153 size_t len = p.get_off() - start_off;
154 pstart.copy(len, data);
155 if (data.get_num_buffers() > 1) {
156 data.rebuild();
157 }
158 //map.reserve(n);
159 char *start = data.c_str();
160 for (auto i : offsets) {
161 map.insert(map.end(), make_pair(i.first, (int32_t*)(start + i.second)));
162 }
163 }
164 void rebuild() {
165 bufferlist bl;
166 encode(bl);
167 auto p = bl.begin();
168 decode(p);
169 }
170 friend bool operator==(const PGTempMap& l, const PGTempMap& r) {
171 return
172 l.map.size() == r.map.size() &&
173 l.data.contents_equal(r.data);
174 }
175
176 class iterator {
177 map_t::const_iterator it;
178 map_t::const_iterator end;
179 pair<pg_t,vector<int32_t>> current;
180 void init_current() {
181 if (it != end) {
182 current.first = it->first;
183 assert(it->second);
184 current.second.resize(*it->second);
185 int32_t *p = it->second + 1;
186 for (int n = 0; n < *it->second; ++n, ++p) {
187 current.second[n] = *p;
188 }
189 }
190 }
191 public:
192 iterator(map_t::const_iterator p,
193 map_t::const_iterator e)
194 : it(p), end(e) {
195 init_current();
196 }
197
198 const pair<pg_t,vector<int32_t>>& operator*() const {
199 return current;
200 }
201 const pair<pg_t,vector<int32_t>>* operator->() const {
202 return &current;
203 }
204 friend bool operator==(const iterator& l, const iterator& r) {
205 return l.it == r.it;
206 }
207 friend bool operator!=(const iterator& l, const iterator& r) {
208 return l.it != r.it;
209 }
210 iterator& operator++() {
211 ++it;
212 if (it != end)
213 init_current();
214 return *this;
215 }
216 iterator operator++(int) {
217 iterator r = *this;
218 ++it;
219 if (it != end)
220 init_current();
221 return r;
222 }
223 };
224 iterator begin() const {
225 return iterator(map.begin(), map.end());
226 }
227 iterator end() const {
228 return iterator(map.end(), map.end());
229 }
230 iterator find(pg_t pgid) const {
231 return iterator(map.find(pgid), map.end());
232 }
233 size_t size() const {
234 return map.size();
235 }
236 size_t count(pg_t pgid) const {
237 return map.count(pgid);
238 }
239 void erase(pg_t pgid) {
240 map.erase(pgid);
241 }
242 void clear() {
243 map.clear();
244 data.clear();
245 }
246 void set(pg_t pgid, const mempool::osdmap::vector<int32_t>& v) {
247 size_t need = sizeof(int32_t) * (1 + v.size());
248 if (need < data.get_append_buffer_unused_tail_length()) {
249 bufferptr z(data.get_append_buffer_unused_tail_length());
250 z.zero();
251 data.append(z.c_str(), z.length());
252 }
253 ::encode(v, data);
254 map[pgid] = (int32_t*)(data.back().end_c_str()) - (1 + v.size());
255 }
256 mempool::osdmap::vector<int32_t> get(pg_t pgid) {
257 mempool::osdmap::vector<int32_t> v;
258 int32_t *p = map[pgid];
259 size_t n = *p++;
260 v.resize(n);
261 for (size_t i = 0; i < n; ++i, ++p) {
262 v[i] = *p;
263 }
264 return v;
265 }
266 #else
267 // trivial implementation
268 mempool::osdmap::map<pg_t,mempool::osdmap::vector<int32_t> > pg_temp;
269
270 void encode(bufferlist& bl) const {
271 ::encode(pg_temp, bl);
272 }
273 void decode(bufferlist::iterator& p) {
274 ::decode(pg_temp, p);
275 }
276 friend bool operator==(const PGTempMap& l, const PGTempMap& r) {
277 return
278 l.pg_temp.size() == r.pg_temp.size() &&
279 l.pg_temp == r.pg_temp;
280 }
281
282 class iterator {
283 mempool::osdmap::map<pg_t,mempool::osdmap::vector<int32_t> >::const_iterator it;
284 public:
285 iterator(mempool::osdmap::map<pg_t,
286 mempool::osdmap::vector<int32_t> >::const_iterator p)
287 : it(p) {}
288
289 pair<pg_t,const mempool::osdmap::vector<int32_t>&> operator*() const {
290 return *it;
291 }
292 const pair<const pg_t,mempool::osdmap::vector<int32_t>>* operator->() const {
293 return &*it;
294 }
295 friend bool operator==(const iterator& l, const iterator& r) {
296 return l.it == r.it;
297 }
298 friend bool operator!=(const iterator& l, const iterator& r) {
299 return l.it != r.it;
300 }
301 iterator& operator++() {
302 ++it;
303 return *this;
304 }
305 iterator operator++(int) {
306 iterator r = *this;
307 ++it;
308 return r;
309 }
310 };
311 iterator begin() const {
312 return iterator(pg_temp.cbegin());
313 }
314 iterator end() const {
315 return iterator(pg_temp.cend());
316 }
317 iterator find(pg_t pgid) const {
318 return iterator(pg_temp.find(pgid));
319 }
320 size_t size() const {
321 return pg_temp.size();
322 }
323 size_t count(pg_t pgid) const {
324 return pg_temp.count(pgid);
325 }
326 void erase(pg_t pgid) {
327 pg_temp.erase(pgid);
328 }
329 void clear() {
330 pg_temp.clear();
331 }
332 void set(pg_t pgid, const mempool::osdmap::vector<int32_t>& v) {
333 pg_temp[pgid] = v;
334 }
335 const mempool::osdmap::vector<int32_t>& get(pg_t pgid) {
336 return pg_temp.at(pgid);
337 }
338 #endif
339 void dump(Formatter *f) const {
340 for (const auto &pg : *this) {
341 f->open_object_section("osds");
342 f->dump_stream("pgid") << pg.first;
343 f->open_array_section("osds");
344 for (const auto osd : pg.second)
345 f->dump_int("osd", osd);
346 f->close_section();
347 f->close_section();
348 }
349 }
350 };
351 WRITE_CLASS_ENCODER(PGTempMap)
352
353 /** OSDMap
354 */
355 class OSDMap {
356 public:
357 MEMPOOL_CLASS_HELPERS();
358
359 class Incremental {
360 public:
361 MEMPOOL_CLASS_HELPERS();
362
363 /// feature bits we were encoded with. the subsequent OSDMap
364 /// encoding should match.
365 uint64_t encode_features;
366 uuid_d fsid;
367 epoch_t epoch; // new epoch; we are a diff from epoch-1 to epoch
368 utime_t modified;
369 int64_t new_pool_max; //incremented by the OSDMonitor on each pool create
370 int32_t new_flags;
371 int8_t new_require_osd_release = -1;
372
373 // full (rare)
374 bufferlist fullmap; // in lieu of below.
375 bufferlist crush;
376
377 // incremental
378 int32_t new_max_osd;
379 mempool::osdmap::map<int64_t,pg_pool_t> new_pools;
380 mempool::osdmap::map<int64_t,string> new_pool_names;
381 mempool::osdmap::set<int64_t> old_pools;
382 mempool::osdmap::map<string,map<string,string> > new_erasure_code_profiles;
383 mempool::osdmap::vector<string> old_erasure_code_profiles;
384 mempool::osdmap::map<int32_t,entity_addr_t> new_up_client;
385 mempool::osdmap::map<int32_t,entity_addr_t> new_up_cluster;
386 mempool::osdmap::map<int32_t,uint32_t> new_state; // XORed onto previous state.
387 mempool::osdmap::map<int32_t,uint32_t> new_weight;
388 mempool::osdmap::map<pg_t,mempool::osdmap::vector<int32_t> > new_pg_temp; // [] to remove
389 mempool::osdmap::map<pg_t, int32_t> new_primary_temp; // [-1] to remove
390 mempool::osdmap::map<int32_t,uint32_t> new_primary_affinity;
391 mempool::osdmap::map<int32_t,epoch_t> new_up_thru;
392 mempool::osdmap::map<int32_t,pair<epoch_t,epoch_t> > new_last_clean_interval;
393 mempool::osdmap::map<int32_t,epoch_t> new_lost;
394 mempool::osdmap::map<int32_t,uuid_d> new_uuid;
395 mempool::osdmap::map<int32_t,osd_xinfo_t> new_xinfo;
396
397 mempool::osdmap::map<entity_addr_t,utime_t> new_blacklist;
398 mempool::osdmap::vector<entity_addr_t> old_blacklist;
399 mempool::osdmap::map<int32_t, entity_addr_t> new_hb_back_up;
400 mempool::osdmap::map<int32_t, entity_addr_t> new_hb_front_up;
401
402 mempool::osdmap::map<pg_t,mempool::osdmap::vector<int32_t>> new_pg_upmap;
403 mempool::osdmap::map<pg_t,mempool::osdmap::vector<pair<int32_t,int32_t>>> new_pg_upmap_items;
404 mempool::osdmap::set<pg_t> old_pg_upmap, old_pg_upmap_items;
405
406 string cluster_snapshot;
407
408 float new_nearfull_ratio = -1;
409 float new_backfillfull_ratio = -1;
410 float new_full_ratio = -1;
411
412 int8_t new_require_min_compat_client = -1;
413
414 mutable bool have_crc; ///< crc values are defined
415 uint32_t full_crc; ///< crc of the resulting OSDMap
416 mutable uint32_t inc_crc; ///< crc of this incremental
417
418 int get_net_marked_out(const OSDMap *previous) const;
419 int get_net_marked_down(const OSDMap *previous) const;
420 int identify_osd(uuid_d u) const;
421
422 void encode_client_old(bufferlist& bl) const;
423 void encode_classic(bufferlist& bl, uint64_t features) const;
424 void encode(bufferlist& bl, uint64_t features=CEPH_FEATURES_ALL) const;
425 void decode_classic(bufferlist::iterator &p);
426 void decode(bufferlist::iterator &bl);
427 void dump(Formatter *f) const;
428 static void generate_test_instances(list<Incremental*>& o);
429
430 explicit Incremental(epoch_t e=0) :
431 encode_features(0),
432 epoch(e), new_pool_max(-1), new_flags(-1), new_max_osd(-1),
433 have_crc(false), full_crc(0), inc_crc(0) {
434 memset(&fsid, 0, sizeof(fsid));
435 }
436 explicit Incremental(bufferlist &bl) {
437 bufferlist::iterator p = bl.begin();
438 decode(p);
439 }
440 explicit Incremental(bufferlist::iterator &p) {
441 decode(p);
442 }
443
444 pg_pool_t *get_new_pool(int64_t pool, const pg_pool_t *orig) {
445 if (new_pools.count(pool) == 0)
446 new_pools[pool] = *orig;
447 return &new_pools[pool];
448 }
449 bool has_erasure_code_profile(const string &name) const {
450 auto i = new_erasure_code_profiles.find(name);
451 return i != new_erasure_code_profiles.end();
452 }
453 void set_erasure_code_profile(const string &name,
454 const map<string,string>& profile) {
455 new_erasure_code_profiles[name] = profile;
456 }
457
458 /// propage update pools' snap metadata to any of their tiers
459 int propagate_snaps_to_tiers(CephContext *cct, const OSDMap &base);
460
461 /// filter out osds with any pending state changing
462 size_t get_pending_state_osds(vector<int> *osds) {
463 assert(osds);
464 osds->clear();
465
466 for (auto &p : new_state) {
467 osds->push_back(p.first);
468 }
469
470 return osds->size();
471 }
472
473 bool pending_osd_has_state(int osd, unsigned state) {
474 return new_state.count(osd) && (new_state[osd] & state) != 0;
475 }
476
477 void pending_osd_state_set(int osd, unsigned state) {
478 new_state[osd] |= state;
479 }
480
481 // cancel the specified pending osd state if there is any
482 // return ture on success, false otherwise.
483 bool pending_osd_state_clear(int osd, unsigned state) {
484 if (!pending_osd_has_state(osd, state)) {
485 // never has been set or already has been cancelled.
486 return false;
487 }
488
489 new_state[osd] &= ~state;
490 return true;
491 }
492
493 };
494
495 private:
496 uuid_d fsid;
497 epoch_t epoch; // what epoch of the osd cluster descriptor is this
498 utime_t created, modified; // epoch start time
499 int32_t pool_max; // the largest pool num, ever
500
501 uint32_t flags;
502
503 int num_osd; // not saved; see calc_num_osds
504 int num_up_osd; // not saved; see calc_num_osds
505 int num_in_osd; // not saved; see calc_num_osds
506
507 int32_t max_osd;
508 vector<uint32_t> osd_state;
509
510 struct addrs_s {
511 mempool::osdmap::vector<ceph::shared_ptr<entity_addr_t> > client_addr;
512 mempool::osdmap::vector<ceph::shared_ptr<entity_addr_t> > cluster_addr;
513 mempool::osdmap::vector<ceph::shared_ptr<entity_addr_t> > hb_back_addr;
514 mempool::osdmap::vector<ceph::shared_ptr<entity_addr_t> > hb_front_addr;
515 entity_addr_t blank;
516 };
517 ceph::shared_ptr<addrs_s> osd_addrs;
518
519 mempool::osdmap::vector<__u32> osd_weight; // 16.16 fixed point, 0x10000 = "in", 0 = "out"
520 mempool::osdmap::vector<osd_info_t> osd_info;
521 ceph::shared_ptr<PGTempMap> pg_temp; // temp pg mapping (e.g. while we rebuild)
522 ceph::shared_ptr< mempool::osdmap::map<pg_t,int32_t > > primary_temp; // temp primary mapping (e.g. while we rebuild)
523 ceph::shared_ptr< mempool::osdmap::vector<__u32> > osd_primary_affinity; ///< 16.16 fixed point, 0x10000 = baseline
524
525 // remap (post-CRUSH, pre-up)
526 mempool::osdmap::map<pg_t,mempool::osdmap::vector<int32_t>> pg_upmap; ///< remap pg
527 mempool::osdmap::map<pg_t,mempool::osdmap::vector<pair<int32_t,int32_t>>> pg_upmap_items; ///< remap osds in up set
528
529 mempool::osdmap::map<int64_t,pg_pool_t> pools;
530 mempool::osdmap::map<int64_t,string> pool_name;
531 mempool::osdmap::map<string,map<string,string> > erasure_code_profiles;
532 mempool::osdmap::map<string,int64_t> name_pool;
533
534 ceph::shared_ptr< mempool::osdmap::vector<uuid_d> > osd_uuid;
535 mempool::osdmap::vector<osd_xinfo_t> osd_xinfo;
536
537 mempool::osdmap::unordered_map<entity_addr_t,utime_t> blacklist;
538
539 epoch_t cluster_snapshot_epoch;
540 string cluster_snapshot;
541 bool new_blacklist_entries;
542
543 float full_ratio = 0, backfillfull_ratio = 0, nearfull_ratio = 0;
544
545 /// min compat client we want to support
546 uint8_t require_min_compat_client = 0; // CEPH_RELEASE_*
547
548 public:
549 /// require osds to run at least this release
550 uint8_t require_osd_release = 0; // CEPH_RELEASE_*
551
552 private:
553 mutable uint64_t cached_up_osd_features;
554
555 mutable bool crc_defined;
556 mutable uint32_t crc;
557
558 void _calc_up_osd_features();
559
560 public:
561 bool have_crc() const { return crc_defined; }
562 uint32_t get_crc() const { return crc; }
563
564 ceph::shared_ptr<CrushWrapper> crush; // hierarchical map
565 private:
566 uint32_t crush_version = 1;
567
568 friend class OSDMonitor;
569
570 public:
571 OSDMap() : epoch(0),
572 pool_max(-1),
573 flags(0),
574 num_osd(0), num_up_osd(0), num_in_osd(0),
575 max_osd(0),
576 osd_addrs(std::make_shared<addrs_s>()),
577 pg_temp(std::make_shared<PGTempMap>()),
578 primary_temp(std::make_shared<mempool::osdmap::map<pg_t,int32_t>>()),
579 osd_uuid(std::make_shared<mempool::osdmap::vector<uuid_d>>()),
580 cluster_snapshot_epoch(0),
581 new_blacklist_entries(false),
582 cached_up_osd_features(0),
583 crc_defined(false), crc(0),
584 crush(std::make_shared<CrushWrapper>()) {
585 memset(&fsid, 0, sizeof(fsid));
586 }
587
588 // no copying
589 private:
590 OSDMap(const OSDMap& other) = default;
591 OSDMap& operator=(const OSDMap& other) = default;
592 public:
593
594 void deepish_copy_from(const OSDMap& o) {
595 *this = o;
596 primary_temp.reset(new mempool::osdmap::map<pg_t,int32_t>(*o.primary_temp));
597 pg_temp.reset(new PGTempMap(*o.pg_temp));
598 osd_uuid.reset(new mempool::osdmap::vector<uuid_d>(*o.osd_uuid));
599
600 if (o.osd_primary_affinity)
601 osd_primary_affinity.reset(new mempool::osdmap::vector<__u32>(*o.osd_primary_affinity));
602
603 // NOTE: this still references shared entity_addr_t's.
604 osd_addrs.reset(new addrs_s(*o.osd_addrs));
605
606 // NOTE: we do not copy crush. note that apply_incremental will
607 // allocate a new CrushWrapper, though.
608 }
609
610 // map info
611 const uuid_d& get_fsid() const { return fsid; }
612 void set_fsid(uuid_d& f) { fsid = f; }
613
614 epoch_t get_epoch() const { return epoch; }
615 void inc_epoch() { epoch++; }
616
617 void set_epoch(epoch_t e);
618
619 uint32_t get_crush_version() const {
620 return crush_version;
621 }
622
623 /* stamps etc */
624 const utime_t& get_created() const { return created; }
625 const utime_t& get_modified() const { return modified; }
626
627 bool is_blacklisted(const entity_addr_t& a) const;
628 void get_blacklist(list<pair<entity_addr_t,utime_t > > *bl) const;
629 void get_blacklist(std::set<entity_addr_t> *bl) const;
630
631 string get_cluster_snapshot() const {
632 if (cluster_snapshot_epoch == epoch)
633 return cluster_snapshot;
634 return string();
635 }
636
637 float get_full_ratio() const {
638 return full_ratio;
639 }
640 float get_backfillfull_ratio() const {
641 return backfillfull_ratio;
642 }
643 float get_nearfull_ratio() const {
644 return nearfull_ratio;
645 }
646 void count_full_nearfull_osds(int *full, int *backfill, int *nearfull) const;
647 void get_full_osd_util(
648 const mempool::pgmap::unordered_map<int32_t,osd_stat_t> &osd_stat,
649 map<int, float> *full,
650 map<int, float> *backfill,
651 map<int, float> *nearfull) const;
652
653 void get_full_osd_counts(set<int> *full, set<int> *backfill,
654 set<int> *nearfull) const;
655
656
657 /***** cluster state *****/
658 /* osds */
659 int get_max_osd() const { return max_osd; }
660 void set_max_osd(int m);
661
662 unsigned get_num_osds() const {
663 return num_osd;
664 }
665 unsigned get_num_up_osds() const {
666 return num_up_osd;
667 }
668 unsigned get_num_in_osds() const {
669 return num_in_osd;
670 }
671 /// recalculate cached values for get_num{,_up,_in}_osds
672 int calc_num_osds();
673
674 void get_all_osds(set<int32_t>& ls) const;
675 void get_up_osds(set<int32_t>& ls) const;
676 void get_out_osds(set<int32_t>& ls) const;
677 unsigned get_num_pg_temp() const {
678 return pg_temp->size();
679 }
680
681 int get_flags() const { return flags; }
682 bool test_flag(int f) const { return flags & f; }
683 void set_flag(int f) { flags |= f; }
684 void clear_flag(int f) { flags &= ~f; }
685
686 static void calc_state_set(int state, set<string>& st);
687
688 int get_state(int o) const {
689 assert(o < max_osd);
690 return osd_state[o];
691 }
692 int get_state(int o, set<string>& st) const {
693 assert(o < max_osd);
694 unsigned t = osd_state[o];
695 calc_state_set(t, st);
696 return osd_state[o];
697 }
698 void set_state(int o, unsigned s) {
699 assert(o < max_osd);
700 osd_state[o] = s;
701 }
702 void set_weight(int o, unsigned w) {
703 assert(o < max_osd);
704 osd_weight[o] = w;
705 if (w)
706 osd_state[o] |= CEPH_OSD_EXISTS;
707 }
708 unsigned get_weight(int o) const {
709 assert(o < max_osd);
710 return osd_weight[o];
711 }
712 float get_weightf(int o) const {
713 return (float)get_weight(o) / (float)CEPH_OSD_IN;
714 }
715 void adjust_osd_weights(const map<int,double>& weights, Incremental& inc) const;
716
717 void set_primary_affinity(int o, int w) {
718 assert(o < max_osd);
719 if (!osd_primary_affinity)
720 osd_primary_affinity.reset(
721 new mempool::osdmap::vector<__u32>(
722 max_osd, CEPH_OSD_DEFAULT_PRIMARY_AFFINITY));
723 (*osd_primary_affinity)[o] = w;
724 }
725 unsigned get_primary_affinity(int o) const {
726 assert(o < max_osd);
727 if (!osd_primary_affinity)
728 return CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
729 return (*osd_primary_affinity)[o];
730 }
731 float get_primary_affinityf(int o) const {
732 return (float)get_primary_affinity(o) / (float)CEPH_OSD_MAX_PRIMARY_AFFINITY;
733 }
734
735 bool has_erasure_code_profile(const string &name) const {
736 auto i = erasure_code_profiles.find(name);
737 return i != erasure_code_profiles.end();
738 }
739 int get_erasure_code_profile_default(CephContext *cct,
740 map<string,string> &profile_map,
741 ostream *ss);
742 void set_erasure_code_profile(const string &name,
743 const map<string,string>& profile) {
744 erasure_code_profiles[name] = profile;
745 }
746 const map<string,string> &get_erasure_code_profile(
747 const string &name) const {
748 static map<string,string> empty;
749 auto i = erasure_code_profiles.find(name);
750 if (i == erasure_code_profiles.end())
751 return empty;
752 else
753 return i->second;
754 }
755 const mempool::osdmap::map<string,map<string,string> > &get_erasure_code_profiles() const {
756 return erasure_code_profiles;
757 }
758
759 bool exists(int osd) const {
760 //assert(osd >= 0);
761 return osd >= 0 && osd < max_osd && (osd_state[osd] & CEPH_OSD_EXISTS);
762 }
763
764 bool is_destroyed(int osd) const {
765 return exists(osd) && (osd_state[osd] & CEPH_OSD_DESTROYED);
766 }
767
768 bool is_up(int osd) const {
769 return exists(osd) && (osd_state[osd] & CEPH_OSD_UP);
770 }
771
772 bool has_been_up_since(int osd, epoch_t epoch) const {
773 return is_up(osd) && get_up_from(osd) <= epoch;
774 }
775
776 bool is_down(int osd) const {
777 return !is_up(osd);
778 }
779
780 bool is_out(int osd) const {
781 return !exists(osd) || get_weight(osd) == CEPH_OSD_OUT;
782 }
783
784 bool is_in(int osd) const {
785 return !is_out(osd);
786 }
787
788 bool is_noup(int osd) const {
789 return exists(osd) && (osd_state[osd] & CEPH_OSD_NOUP);
790 }
791
792 bool is_nodown(int osd) const {
793 return exists(osd) && (osd_state[osd] & CEPH_OSD_NODOWN);
794 }
795
796 bool is_noin(int osd) const {
797 return exists(osd) && (osd_state[osd] & CEPH_OSD_NOIN);
798 }
799
800 bool is_noout(int osd) const {
801 return exists(osd) && (osd_state[osd] & CEPH_OSD_NOOUT);
802 }
803
804 void get_noup_osds(vector<int> *osds) const {
805 assert(osds);
806 osds->clear();
807
808 for (int i = 0; i < max_osd; i++) {
809 if (is_noup(i)) {
810 osds->push_back(i);
811 }
812 }
813 }
814
815 void get_nodown_osds(vector<int> *osds) const {
816 assert(osds);
817 osds->clear();
818
819 for (int i = 0; i < max_osd; i++) {
820 if (is_nodown(i)) {
821 osds->push_back(i);
822 }
823 }
824 }
825
826 void get_noin_osds(vector<int> *osds) const {
827 assert(osds);
828 osds->clear();
829
830 for (int i = 0; i < max_osd; i++) {
831 if (is_noin(i)) {
832 osds->push_back(i);
833 }
834 }
835 }
836
837 void get_noout_osds(vector<int> *osds) const {
838 assert(osds);
839 osds->clear();
840
841 for (int i = 0; i < max_osd; i++) {
842 if (is_noout(i)) {
843 osds->push_back(i);
844 }
845 }
846 }
847
848 /**
849 * check if an entire crush subtree is down
850 */
851 bool subtree_is_down(int id, set<int> *down_cache) const;
852 bool containing_subtree_is_down(CephContext *cct, int osd, int subtree_type, set<int> *down_cache) const;
853
854 bool subtree_type_is_down(CephContext *cct, int id, int subtree_type, set<int> *down_in_osds, set<int> *up_in_osds,
855 set<int> *subtree_up, unordered_map<int, set<int> > *subtree_type_down) const;
856
857 int identify_osd(const entity_addr_t& addr) const;
858 int identify_osd(const uuid_d& u) const;
859 int identify_osd_on_all_channels(const entity_addr_t& addr) const;
860
861 bool have_addr(const entity_addr_t& addr) const {
862 return identify_osd(addr) >= 0;
863 }
864 int find_osd_on_ip(const entity_addr_t& ip) const;
865 const entity_addr_t &get_addr(int osd) const {
866 assert(exists(osd));
867 return osd_addrs->client_addr[osd] ? *osd_addrs->client_addr[osd] : osd_addrs->blank;
868 }
869 const entity_addr_t &get_cluster_addr(int osd) const {
870 assert(exists(osd));
871 if (!osd_addrs->cluster_addr[osd] || *osd_addrs->cluster_addr[osd] == entity_addr_t())
872 return get_addr(osd);
873 return *osd_addrs->cluster_addr[osd];
874 }
875 const entity_addr_t &get_hb_back_addr(int osd) const {
876 assert(exists(osd));
877 return osd_addrs->hb_back_addr[osd] ? *osd_addrs->hb_back_addr[osd] : osd_addrs->blank;
878 }
879 const entity_addr_t &get_hb_front_addr(int osd) const {
880 assert(exists(osd));
881 return osd_addrs->hb_front_addr[osd] ? *osd_addrs->hb_front_addr[osd] : osd_addrs->blank;
882 }
883 entity_inst_t get_most_recent_inst(int osd) const {
884 assert(exists(osd));
885 return entity_inst_t(entity_name_t::OSD(osd), get_addr(osd));
886 }
887 entity_inst_t get_inst(int osd) const {
888 assert(is_up(osd));
889 return get_most_recent_inst(osd);
890 }
891 entity_inst_t get_cluster_inst(int osd) const {
892 assert(is_up(osd));
893 return entity_inst_t(entity_name_t::OSD(osd), get_cluster_addr(osd));
894 }
895 entity_inst_t get_hb_back_inst(int osd) const {
896 assert(is_up(osd));
897 return entity_inst_t(entity_name_t::OSD(osd), get_hb_back_addr(osd));
898 }
899 entity_inst_t get_hb_front_inst(int osd) const {
900 assert(is_up(osd));
901 return entity_inst_t(entity_name_t::OSD(osd), get_hb_front_addr(osd));
902 }
903
904 const uuid_d& get_uuid(int osd) const {
905 assert(exists(osd));
906 return (*osd_uuid)[osd];
907 }
908
909 const epoch_t& get_up_from(int osd) const {
910 assert(exists(osd));
911 return osd_info[osd].up_from;
912 }
913 const epoch_t& get_up_thru(int osd) const {
914 assert(exists(osd));
915 return osd_info[osd].up_thru;
916 }
917 const epoch_t& get_down_at(int osd) const {
918 assert(exists(osd));
919 return osd_info[osd].down_at;
920 }
921 const osd_info_t& get_info(int osd) const {
922 assert(osd < max_osd);
923 return osd_info[osd];
924 }
925
926 const osd_xinfo_t& get_xinfo(int osd) const {
927 assert(osd < max_osd);
928 return osd_xinfo[osd];
929 }
930
931 int get_next_up_osd_after(int n) const {
932 if (get_max_osd() == 0)
933 return -1;
934 for (int i = n + 1; i != n; ++i) {
935 if (i >= get_max_osd())
936 i = 0;
937 if (i == n)
938 break;
939 if (is_up(i))
940 return i;
941 }
942 return -1;
943 }
944
945 int get_previous_up_osd_before(int n) const {
946 if (get_max_osd() == 0)
947 return -1;
948 for (int i = n - 1; i != n; --i) {
949 if (i < 0)
950 i = get_max_osd() - 1;
951 if (i == n)
952 break;
953 if (is_up(i))
954 return i;
955 }
956 return -1;
957 }
958
959 /**
960 * get feature bits required by the current structure
961 *
962 * @param entity_type [in] what entity type we are asking about
963 * @param mask [out] set of all possible map-related features we could set
964 * @return feature bits used by this map
965 */
966 uint64_t get_features(int entity_type, uint64_t *mask) const;
967
968 /**
969 * get oldest *client* version (firefly, hammer, etc.) that can connect given
970 * the feature bits required (according to get_features()).
971 */
972 uint8_t get_min_compat_client() const;
973
974 /**
975 * get intersection of features supported by up osds
976 */
977 uint64_t get_up_osd_features() const;
978
979 int apply_incremental(const Incremental &inc);
980
981 /// try to re-use/reference addrs in oldmap from newmap
982 static void dedup(const OSDMap *oldmap, OSDMap *newmap);
983
984 static void clean_temps(CephContext *cct, const OSDMap& osdmap,
985 Incremental *pending_inc);
986
987 // serialize, unserialize
988 private:
989 void encode_client_old(bufferlist& bl) const;
990 void encode_classic(bufferlist& bl, uint64_t features) const;
991 void decode_classic(bufferlist::iterator& p);
992 void post_decode();
993 public:
994 void encode(bufferlist& bl, uint64_t features=CEPH_FEATURES_ALL) const;
995 void decode(bufferlist& bl);
996 void decode(bufferlist::iterator& bl);
997
998
999 /**** mapping facilities ****/
1000 int map_to_pg(
1001 int64_t pool,
1002 const string& name,
1003 const string& key,
1004 const string& nspace,
1005 pg_t *pg) const;
1006 int object_locator_to_pg(const object_t& oid, const object_locator_t& loc,
1007 pg_t &pg) const;
1008 pg_t object_locator_to_pg(const object_t& oid,
1009 const object_locator_t& loc) const {
1010 pg_t pg;
1011 int ret = object_locator_to_pg(oid, loc, pg);
1012 assert(ret == 0);
1013 return pg;
1014 }
1015
1016
1017 static object_locator_t file_to_object_locator(const file_layout_t& layout) {
1018 return object_locator_t(layout.pool_id, layout.pool_ns);
1019 }
1020
1021 ceph_object_layout file_to_object_layout(object_t oid,
1022 file_layout_t& layout) const {
1023 return make_object_layout(oid, layout.pool_id, layout.pool_ns);
1024 }
1025
1026 ceph_object_layout make_object_layout(object_t oid, int pg_pool,
1027 string nspace) const;
1028
1029 int get_pg_num(int pg_pool) const
1030 {
1031 const pg_pool_t *pool = get_pg_pool(pg_pool);
1032 assert(NULL != pool);
1033 return pool->get_pg_num();
1034 }
1035
1036 bool pg_exists(pg_t pgid) const {
1037 const pg_pool_t *p = get_pg_pool(pgid.pool());
1038 return p && pgid.ps() < p->get_pg_num();
1039 }
1040
1041 private:
1042 /// pg -> (raw osd list)
1043 void _pg_to_raw_osds(
1044 const pg_pool_t& pool, pg_t pg,
1045 vector<int> *osds,
1046 ps_t *ppps) const;
1047 int _pick_primary(const vector<int>& osds) const;
1048 void _remove_nonexistent_osds(const pg_pool_t& pool, vector<int>& osds) const;
1049
1050 void _apply_primary_affinity(ps_t seed, const pg_pool_t& pool,
1051 vector<int> *osds, int *primary) const;
1052
1053 /// apply pg_upmap[_items] mappings
1054 void _apply_remap(const pg_pool_t& pi, pg_t pg, vector<int> *raw) const;
1055
1056 /// pg -> (up osd list)
1057 void _raw_to_up_osds(const pg_pool_t& pool, const vector<int>& raw,
1058 vector<int> *up) const;
1059
1060
1061 /**
1062 * Get the pg and primary temp, if they are specified.
1063 * @param temp_pg [out] Will be empty or contain the temp PG mapping on return
1064 * @param temp_primary [out] Will be the value in primary_temp, or a value derived
1065 * from the pg_temp (if specified), or -1 if you should use the calculated (up_)primary.
1066 */
1067 void _get_temp_osds(const pg_pool_t& pool, pg_t pg,
1068 vector<int> *temp_pg, int *temp_primary) const;
1069
1070 /**
1071 * map to up and acting. Fills in whatever fields are non-NULL.
1072 */
1073 void _pg_to_up_acting_osds(const pg_t& pg, vector<int> *up, int *up_primary,
1074 vector<int> *acting, int *acting_primary,
1075 bool raw_pg_to_pg = true) const;
1076
1077 public:
1078 /***
1079 * This is suitable only for looking at raw CRUSH outputs. It skips
1080 * applying the temp and up checks and should not be used
1081 * by anybody for data mapping purposes.
1082 * raw and primary must be non-NULL
1083 */
1084 void pg_to_raw_osds(pg_t pg, vector<int> *raw, int *primary) const;
1085 /// map a pg to its acting set. @return acting set size
1086 void pg_to_acting_osds(const pg_t& pg, vector<int> *acting,
1087 int *acting_primary) const {
1088 _pg_to_up_acting_osds(pg, NULL, NULL, acting, acting_primary);
1089 }
1090 void pg_to_acting_osds(pg_t pg, vector<int>& acting) const {
1091 return pg_to_acting_osds(pg, &acting, NULL);
1092 }
1093 /**
1094 * This does not apply temp overrides and should not be used
1095 * by anybody for data mapping purposes. Specify both pointers.
1096 */
1097 void pg_to_raw_up(pg_t pg, vector<int> *up, int *primary) const;
1098 /**
1099 * map a pg to its acting set as well as its up set. You must use
1100 * the acting set for data mapping purposes, but some users will
1101 * also find the up set useful for things like deciding what to
1102 * set as pg_temp.
1103 * Each of these pointers must be non-NULL.
1104 */
1105 void pg_to_up_acting_osds(pg_t pg, vector<int> *up, int *up_primary,
1106 vector<int> *acting, int *acting_primary) const {
1107 _pg_to_up_acting_osds(pg, up, up_primary, acting, acting_primary);
1108 }
1109 void pg_to_up_acting_osds(pg_t pg, vector<int>& up, vector<int>& acting) const {
1110 int up_primary, acting_primary;
1111 pg_to_up_acting_osds(pg, &up, &up_primary, &acting, &acting_primary);
1112 }
1113 bool pg_is_ec(pg_t pg) const {
1114 auto i = pools.find(pg.pool());
1115 assert(i != pools.end());
1116 return i->second.ec_pool();
1117 }
1118 bool get_primary_shard(const pg_t& pgid, spg_t *out) const {
1119 auto i = get_pools().find(pgid.pool());
1120 if (i == get_pools().end()) {
1121 return false;
1122 }
1123 if (!i->second.ec_pool()) {
1124 *out = spg_t(pgid);
1125 return true;
1126 }
1127 int primary;
1128 vector<int> acting;
1129 pg_to_acting_osds(pgid, &acting, &primary);
1130 for (uint8_t i = 0; i < acting.size(); ++i) {
1131 if (acting[i] == primary) {
1132 *out = spg_t(pgid, shard_id_t(i));
1133 return true;
1134 }
1135 }
1136 return false;
1137 }
1138
1139 int64_t lookup_pg_pool_name(const string& name) const {
1140 auto p = name_pool.find(name);
1141 if (p == name_pool.end())
1142 return -ENOENT;
1143 return p->second;
1144 }
1145
1146 int64_t get_pool_max() const {
1147 return pool_max;
1148 }
1149 const mempool::osdmap::map<int64_t,pg_pool_t>& get_pools() const {
1150 return pools;
1151 }
1152 mempool::osdmap::map<int64_t,pg_pool_t>& get_pools() {
1153 return pools;
1154 }
1155 const string& get_pool_name(int64_t p) const {
1156 auto i = pool_name.find(p);
1157 assert(i != pool_name.end());
1158 return i->second;
1159 }
1160 bool have_pg_pool(int64_t p) const {
1161 return pools.count(p);
1162 }
1163 const pg_pool_t* get_pg_pool(int64_t p) const {
1164 auto i = pools.find(p);
1165 if (i != pools.end())
1166 return &i->second;
1167 return NULL;
1168 }
1169 unsigned get_pg_size(pg_t pg) const {
1170 auto p = pools.find(pg.pool());
1171 assert(p != pools.end());
1172 return p->second.get_size();
1173 }
1174 int get_pg_type(pg_t pg) const {
1175 auto p = pools.find(pg.pool());
1176 assert(p != pools.end());
1177 return p->second.get_type();
1178 }
1179
1180
1181 pg_t raw_pg_to_pg(pg_t pg) const {
1182 auto p = pools.find(pg.pool());
1183 assert(p != pools.end());
1184 return p->second.raw_pg_to_pg(pg);
1185 }
1186
1187 // pg -> acting primary osd
1188 int get_pg_acting_primary(pg_t pg) const {
1189 int primary = -1;
1190 _pg_to_up_acting_osds(pg, nullptr, nullptr, nullptr, &primary);
1191 return primary;
1192 }
1193
1194 /*
1195 * check whether an spg_t maps to a particular osd
1196 */
1197 bool is_up_acting_osd_shard(spg_t pg, int osd) const {
1198 vector<int> up, acting;
1199 _pg_to_up_acting_osds(pg.pgid, &up, NULL, &acting, NULL, false);
1200 if (pg.shard == shard_id_t::NO_SHARD) {
1201 if (calc_pg_role(osd, acting, acting.size()) >= 0 ||
1202 calc_pg_role(osd, up, up.size()) >= 0)
1203 return true;
1204 } else {
1205 if (pg.shard < (int)acting.size() && acting[pg.shard] == osd)
1206 return true;
1207 if (pg.shard < (int)up.size() && up[pg.shard] == osd)
1208 return true;
1209 }
1210 return false;
1211 }
1212
1213
1214 /* what replica # is a given osd? 0 primary, -1 for none. */
1215 static int calc_pg_rank(int osd, const vector<int>& acting, int nrep=0);
1216 static int calc_pg_role(int osd, const vector<int>& acting, int nrep=0);
1217 static bool primary_changed(
1218 int oldprimary,
1219 const vector<int> &oldacting,
1220 int newprimary,
1221 const vector<int> &newacting);
1222
1223 /* rank is -1 (stray), 0 (primary), 1,2,3,... (replica) */
1224 int get_pg_acting_rank(pg_t pg, int osd) const {
1225 vector<int> group;
1226 pg_to_acting_osds(pg, group);
1227 return calc_pg_rank(osd, group, group.size());
1228 }
1229 /* role is -1 (stray), 0 (primary), 1 (replica) */
1230 int get_pg_acting_role(const pg_t& pg, int osd) const {
1231 vector<int> group;
1232 pg_to_acting_osds(pg, group);
1233 return calc_pg_role(osd, group, group.size());
1234 }
1235
1236 bool osd_is_valid_op_target(pg_t pg, int osd) const {
1237 int primary;
1238 vector<int> group;
1239 pg_to_acting_osds(pg, &group, &primary);
1240 if (osd == primary)
1241 return true;
1242 if (pg_is_ec(pg))
1243 return false;
1244
1245 return calc_pg_role(osd, group, group.size()) >= 0;
1246 }
1247
1248 int clean_pg_upmaps(
1249 CephContext *cct,
1250 Incremental *pending_inc);
1251
1252 bool try_pg_upmap(
1253 CephContext *cct,
1254 pg_t pg, ///< pg to potentially remap
1255 const set<int>& overfull, ///< osds we'd want to evacuate
1256 const vector<int>& underfull, ///< osds to move to, in order of preference
1257 vector<int> *orig,
1258 vector<int> *out); ///< resulting alternative mapping
1259
1260 int calc_pg_upmaps(
1261 CephContext *cct,
1262 float max_deviation, ///< max deviation from target (value < 1.0)
1263 int max_iterations, ///< max iterations to run
1264 const set<int64_t>& pools, ///< [optional] restrict to pool
1265 Incremental *pending_inc
1266 );
1267
1268 int get_osds_by_bucket_name(const string &name, set<int> *osds) const;
1269
1270 /*
1271 * handy helpers to build simple maps...
1272 */
1273 /**
1274 * Build an OSD map suitable for basic usage. If **num_osd** is >= 0
1275 * it will be initialized with the specified number of OSDs in a
1276 * single host. If **num_osd** is < 0 the layout of the OSD map will
1277 * be built by reading the content of the configuration file.
1278 *
1279 * @param cct [in] in core ceph context
1280 * @param e [in] initial epoch
1281 * @param fsid [in] id of the cluster
1282 * @param num_osd [in] number of OSDs if >= 0 or read from conf if < 0
1283 * @return **0** on success, negative errno on error.
1284 */
1285 int build_simple(CephContext *cct, epoch_t e, uuid_d &fsid,
1286 int num_osd, int pg_bits, int pgp_bits);
1287 static int _build_crush_types(CrushWrapper& crush);
1288 static int build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
1289 int num_osd, ostream *ss);
1290 static int build_simple_crush_map_from_conf(CephContext *cct,
1291 CrushWrapper& crush,
1292 ostream *ss);
1293 static int build_simple_crush_rules(
1294 CephContext *cct, CrushWrapper& crush,
1295 const string& root,
1296 ostream *ss);
1297
1298 bool crush_ruleset_in_use(int ruleset) const;
1299
1300 void clear_temp() {
1301 pg_temp->clear();
1302 primary_temp->clear();
1303 }
1304
1305 private:
1306 void print_osd_line(int cur, ostream *out, Formatter *f) const;
1307 public:
1308 void print(ostream& out) const;
1309 void print_pools(ostream& out) const;
1310 void print_summary(Formatter *f, ostream& out) const;
1311 void print_oneline_summary(ostream& out) const;
1312
1313 enum {
1314 DUMP_IN = 1, // only 'in' osds
1315 DUMP_OUT = 2, // only 'out' osds
1316 DUMP_UP = 4, // only 'up' osds
1317 DUMP_DOWN = 8, // only 'down' osds
1318 };
1319 void print_tree(Formatter *f, ostream *out, unsigned dump_flags=0) const;
1320
1321 int summarize_mapping_stats(
1322 OSDMap *newmap,
1323 const set<int64_t> *pools,
1324 std::string *out,
1325 Formatter *f) const;
1326
1327 string get_flag_string() const;
1328 static string get_flag_string(unsigned flags);
1329 static void dump_erasure_code_profiles(
1330 const mempool::osdmap::map<string,map<string,string> > &profiles,
1331 Formatter *f);
1332 void dump(Formatter *f) const;
1333 static void generate_test_instances(list<OSDMap*>& o);
1334 bool check_new_blacklist_entries() const { return new_blacklist_entries; }
1335 };
1336 WRITE_CLASS_ENCODER_FEATURES(OSDMap)
1337 WRITE_CLASS_ENCODER_FEATURES(OSDMap::Incremental)
1338
1339 typedef ceph::shared_ptr<const OSDMap> OSDMapRef;
1340
1341 inline ostream& operator<<(ostream& out, const OSDMap& m) {
1342 m.print_oneline_summary(out);
1343 return out;
1344 }
1345
1346 class PGStatService;
1347
1348 void print_osd_utilization(const OSDMap& osdmap,
1349 const PGStatService *pgstat,
1350 ostream& out,
1351 Formatter *f,
1352 bool tree);
1353
1354 #endif