1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
9 * Author: Loic Dachary <loic@dachary.org>
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.
23 * describe properties of the OSD cluster.
24 * disks, disk groups, total # osds,
27 #include "include/types.h"
28 #include "osd_types.h"
30 //#include "include/ceph_features.h"
31 #include "crush/CrushWrapper.h"
37 #include "include/btree_map.h"
39 // forward declaration
42 class health_check_map_t
;
45 * we track up to two intervals during which the osd was alive and
46 * healthy. the most recent is [up_from,up_thru), where up_thru is
47 * the last epoch the osd is known to have _started_. i.e., a lower
48 * bound on the actual osd death. down_at (if it is > up_from) is an
49 * upper bound on the actual osd death.
51 * the second is the last_clean interval [first,last]. in that case,
52 * the last interval is the last epoch known to have been either
53 * _finished_, or during which the osd cleanly shut down. when
54 * possible, we push this forward to the epoch the osd was eventually
57 * the lost_at is used to allow build_prior to proceed without waiting
58 * for an osd to recover. In certain cases, progress may be blocked
59 * because an osd is down that may contain updates (i.e., a pg may have
60 * gone rw during an interval). If the osd can't be brought online, we
61 * can force things to proceed knowing that we _might_ be losing some
62 * acked writes. If the osd comes back to life later, that's fine to,
63 * but those writes will still be lost (the divergent objects will be
67 epoch_t last_clean_begin
; // last interval that ended with a clean osd shutdown
68 epoch_t last_clean_end
;
69 epoch_t up_from
; // epoch osd marked up
70 epoch_t up_thru
; // lower bound on actual osd death (if > up_from)
71 epoch_t down_at
; // upper bound on actual osd death (if > up_from)
72 epoch_t lost_at
; // last epoch we decided data was "lost"
74 osd_info_t() : last_clean_begin(0), last_clean_end(0),
75 up_from(0), up_thru(0), down_at(0), lost_at(0) {}
77 void dump(Formatter
*f
) const;
78 void encode(bufferlist
& bl
) const;
79 void decode(bufferlist::const_iterator
& bl
);
80 static void generate_test_instances(list
<osd_info_t
*>& o
);
82 WRITE_CLASS_ENCODER(osd_info_t
)
84 ostream
& operator<<(ostream
& out
, const osd_info_t
& info
);
87 utime_t down_stamp
; ///< timestamp when we were last marked down
88 float laggy_probability
; ///< encoded as __u32: 0 = definitely not laggy, 0xffffffff definitely laggy
89 __u32 laggy_interval
; ///< average interval between being marked laggy and recovering
90 uint64_t features
; ///< features supported by this osd we should know about
91 __u32 old_weight
; ///< weight prior to being auto marked out
93 osd_xinfo_t() : laggy_probability(0), laggy_interval(0),
94 features(0), old_weight(0) {}
96 void dump(Formatter
*f
) const;
97 void encode(bufferlist
& bl
) const;
98 void decode(bufferlist::const_iterator
& bl
);
99 static void generate_test_instances(list
<osd_xinfo_t
*>& o
);
101 WRITE_CLASS_ENCODER(osd_xinfo_t
)
103 ostream
& operator<<(ostream
& out
, const osd_xinfo_t
& xi
);
109 typedef btree::btree_map
<pg_t
,int32_t*> map_t
;
112 void encode(bufferlist
& bl
) const {
114 uint32_t n
= map
.size();
116 for (auto &p
: map
) {
118 bl
.append((char*)p
.second
, (*p
.second
+ 1) * sizeof(int32_t));
121 void decode(bufferlist::const_iterator
& p
) {
130 size_t start_off
= pstart
.get_off();
131 vector
<pair
<pg_t
,size_t>> offsets
;
133 for (unsigned i
=0; i
<n
; ++i
) {
136 offsets
[i
].first
= pgid
;
137 offsets
[i
].second
= p
.get_off() - start_off
;
140 p
.advance(vn
* sizeof(int32_t));
142 size_t len
= p
.get_off() - start_off
;
143 pstart
.copy(len
, data
);
144 if (data
.get_num_buffers() > 1) {
148 char *start
= data
.c_str();
149 for (auto i
: offsets
) {
150 map
.insert(map
.end(), make_pair(i
.first
, (int32_t*)(start
+ i
.second
)));
156 auto p
= std::cbegin(bl
);
159 friend bool operator==(const PGTempMap
& l
, const PGTempMap
& r
) {
161 l
.map
.size() == r
.map
.size() &&
162 l
.data
.contents_equal(r
.data
);
166 map_t::const_iterator it
;
167 map_t::const_iterator end
;
168 pair
<pg_t
,vector
<int32_t>> current
;
169 void init_current() {
171 current
.first
= it
->first
;
172 ceph_assert(it
->second
);
173 current
.second
.resize(*it
->second
);
174 int32_t *p
= it
->second
+ 1;
175 for (int n
= 0; n
< *it
->second
; ++n
, ++p
) {
176 current
.second
[n
] = *p
;
181 iterator(map_t::const_iterator p
,
182 map_t::const_iterator e
)
187 const pair
<pg_t
,vector
<int32_t>>& operator*() const {
190 const pair
<pg_t
,vector
<int32_t>>* operator->() const {
193 friend bool operator==(const iterator
& l
, const iterator
& r
) {
196 friend bool operator!=(const iterator
& l
, const iterator
& r
) {
199 iterator
& operator++() {
205 iterator
operator++(int) {
213 iterator
begin() const {
214 return iterator(map
.begin(), map
.end());
216 iterator
end() const {
217 return iterator(map
.end(), map
.end());
219 iterator
find(pg_t pgid
) const {
220 return iterator(map
.find(pgid
), map
.end());
222 size_t size() const {
225 size_t count(pg_t pgid
) const {
226 return map
.count(pgid
);
228 void erase(pg_t pgid
) {
235 void set(pg_t pgid
, const mempool::osdmap::vector
<int32_t>& v
) {
237 size_t need
= sizeof(int32_t) * (1 + v
.size());
238 if (need
< data
.get_append_buffer_unused_tail_length()) {
239 bufferptr
z(data
.get_append_buffer_unused_tail_length());
241 data
.append(z
.c_str(), z
.length());
244 map
[pgid
] = (int32_t*)(data
.back().end_c_str()) - (1 + v
.size());
246 mempool::osdmap::vector
<int32_t> get(pg_t pgid
) {
247 mempool::osdmap::vector
<int32_t> v
;
248 int32_t *p
= map
[pgid
];
251 for (size_t i
= 0; i
< n
; ++i
, ++p
) {
257 // trivial implementation
258 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<int32_t> > pg_temp
;
260 void encode(bufferlist
& bl
) const {
263 void decode(bufferlist::const_iterator
& p
) {
266 friend bool operator==(const PGTempMap
& l
, const PGTempMap
& r
) {
268 l
.pg_temp
.size() == r
.pg_temp
.size() &&
269 l
.pg_temp
== r
.pg_temp
;
273 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<int32_t> >::const_iterator it
;
275 iterator(mempool::osdmap::map
<pg_t
,
276 mempool::osdmap::vector
<int32_t> >::const_iterator p
)
279 pair
<pg_t
,const mempool::osdmap::vector
<int32_t>&> operator*() const {
282 const pair
<const pg_t
,mempool::osdmap::vector
<int32_t>>* operator->() const {
285 friend bool operator==(const iterator
& l
, const iterator
& r
) {
288 friend bool operator!=(const iterator
& l
, const iterator
& r
) {
291 iterator
& operator++() {
295 iterator
operator++(int) {
301 iterator
begin() const {
302 return iterator(pg_temp
.cbegin());
304 iterator
end() const {
305 return iterator(pg_temp
.cend());
307 iterator
find(pg_t pgid
) const {
308 return iterator(pg_temp
.find(pgid
));
310 size_t size() const {
311 return pg_temp
.size();
313 size_t count(pg_t pgid
) const {
314 return pg_temp
.count(pgid
);
316 void erase(pg_t pgid
) {
322 void set(pg_t pgid
, const mempool::osdmap::vector
<int32_t>& v
) {
325 const mempool::osdmap::vector
<int32_t>& get(pg_t pgid
) {
326 return pg_temp
.at(pgid
);
329 void dump(Formatter
*f
) const {
330 for (const auto &pg
: *this) {
331 f
->open_object_section("osds");
332 f
->dump_stream("pgid") << pg
.first
;
333 f
->open_array_section("osds");
334 for (const auto osd
: pg
.second
)
335 f
->dump_int("osd", osd
);
341 WRITE_CLASS_ENCODER(PGTempMap
)
347 MEMPOOL_CLASS_HELPERS();
349 typedef interval_set
<
351 mempool::osdmap::flat_map
<snapid_t
,snapid_t
>> snap_interval_set_t
;
355 MEMPOOL_CLASS_HELPERS();
357 /// feature bits we were encoded with. the subsequent OSDMap
358 /// encoding should match.
359 uint64_t encode_features
;
361 epoch_t epoch
; // new epoch; we are a diff from epoch-1 to epoch
363 int64_t new_pool_max
; //incremented by the OSDMonitor on each pool create
365 int8_t new_require_osd_release
= -1;
368 bufferlist fullmap
; // in lieu of below.
373 mempool::osdmap::map
<int64_t,pg_pool_t
> new_pools
;
374 mempool::osdmap::map
<int64_t,string
> new_pool_names
;
375 mempool::osdmap::set
<int64_t> old_pools
;
376 mempool::osdmap::map
<string
,map
<string
,string
> > new_erasure_code_profiles
;
377 mempool::osdmap::vector
<string
> old_erasure_code_profiles
;
378 mempool::osdmap::map
<int32_t,entity_addrvec_t
> new_up_client
;
379 mempool::osdmap::map
<int32_t,entity_addrvec_t
> new_up_cluster
;
380 mempool::osdmap::map
<int32_t,uint32_t> new_state
; // XORed onto previous state.
381 mempool::osdmap::map
<int32_t,uint32_t> new_weight
;
382 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<int32_t> > new_pg_temp
; // [] to remove
383 mempool::osdmap::map
<pg_t
, int32_t> new_primary_temp
; // [-1] to remove
384 mempool::osdmap::map
<int32_t,uint32_t> new_primary_affinity
;
385 mempool::osdmap::map
<int32_t,epoch_t
> new_up_thru
;
386 mempool::osdmap::map
<int32_t,pair
<epoch_t
,epoch_t
> > new_last_clean_interval
;
387 mempool::osdmap::map
<int32_t,epoch_t
> new_lost
;
388 mempool::osdmap::map
<int32_t,uuid_d
> new_uuid
;
389 mempool::osdmap::map
<int32_t,osd_xinfo_t
> new_xinfo
;
391 mempool::osdmap::map
<entity_addr_t
,utime_t
> new_blacklist
;
392 mempool::osdmap::vector
<entity_addr_t
> old_blacklist
;
393 mempool::osdmap::map
<int32_t, entity_addrvec_t
> new_hb_back_up
;
394 mempool::osdmap::map
<int32_t, entity_addrvec_t
> new_hb_front_up
;
396 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<int32_t>> new_pg_upmap
;
397 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<pair
<int32_t,int32_t>>> new_pg_upmap_items
;
398 mempool::osdmap::set
<pg_t
> old_pg_upmap
, old_pg_upmap_items
;
399 mempool::osdmap::map
<int64_t, snap_interval_set_t
> new_removed_snaps
;
400 mempool::osdmap::map
<int64_t, snap_interval_set_t
> new_purged_snaps
;
402 mempool::osdmap::map
<int32_t,uint32_t> new_crush_node_flags
;
403 mempool::osdmap::map
<int32_t,uint32_t> new_device_class_flags
;
405 string cluster_snapshot
;
407 float new_nearfull_ratio
= -1;
408 float new_backfillfull_ratio
= -1;
409 float new_full_ratio
= -1;
411 int8_t new_require_min_compat_client
= -1;
413 utime_t new_last_up_change
, new_last_in_change
;
415 mutable bool have_crc
; ///< crc values are defined
416 uint32_t full_crc
; ///< crc of the resulting OSDMap
417 mutable uint32_t inc_crc
; ///< crc of this incremental
419 int get_net_marked_out(const OSDMap
*previous
) const;
420 int get_net_marked_down(const OSDMap
*previous
) const;
421 int identify_osd(uuid_d u
) const;
423 void encode_client_old(bufferlist
& bl
) const;
424 void encode_classic(bufferlist
& bl
, uint64_t features
) const;
425 void encode(bufferlist
& bl
, uint64_t features
=CEPH_FEATURES_ALL
) const;
426 void decode_classic(bufferlist::const_iterator
&p
);
427 void decode(bufferlist::const_iterator
&bl
);
428 void dump(Formatter
*f
) const;
429 static void generate_test_instances(list
<Incremental
*>& o
);
431 explicit Incremental(epoch_t e
=0) :
433 epoch(e
), new_pool_max(-1), new_flags(-1), new_max_osd(-1),
434 have_crc(false), full_crc(0), inc_crc(0) {
436 explicit Incremental(bufferlist
&bl
) {
437 auto p
= std::cbegin(bl
);
440 explicit Incremental(bufferlist::const_iterator
&p
) {
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
];
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();
453 void set_erasure_code_profile(const string
&name
,
454 const map
<string
,string
>& profile
) {
455 new_erasure_code_profiles
[name
] = profile
;
457 mempool::osdmap::map
<string
,map
<string
,string
>> get_erasure_code_profiles() const {
458 return new_erasure_code_profiles
;
461 /// propagate update pools' snap metadata to any of their tiers
462 int propagate_snaps_to_tiers(CephContext
*cct
, const OSDMap
&base
);
464 /// filter out osds with any pending state changing
465 size_t get_pending_state_osds(vector
<int> *osds
) {
469 for (auto &p
: new_state
) {
470 osds
->push_back(p
.first
);
476 bool pending_osd_has_state(int osd
, unsigned state
) {
477 return new_state
.count(osd
) && (new_state
[osd
] & state
) != 0;
480 bool pending_osd_state_set(int osd
, unsigned state
) {
481 if (pending_osd_has_state(osd
, state
))
483 new_state
[osd
] |= state
;
487 // cancel the specified pending osd state if there is any
488 // return ture on success, false otherwise.
489 bool pending_osd_state_clear(int osd
, unsigned state
) {
490 if (!pending_osd_has_state(osd
, state
)) {
491 // never has been set or already has been cancelled.
495 new_state
[osd
] &= ~state
;
496 if (!new_state
[osd
]) {
498 new_state
.erase(osd
);
507 epoch_t epoch
; // what epoch of the osd cluster descriptor is this
508 utime_t created
, modified
; // epoch start time
509 int32_t pool_max
; // the largest pool num, ever
513 int num_osd
; // not saved; see calc_num_osds
514 int num_up_osd
; // not saved; see calc_num_osds
515 int num_in_osd
; // not saved; see calc_num_osds
518 vector
<uint32_t> osd_state
;
520 mempool::osdmap::map
<int32_t,uint32_t> crush_node_flags
; // crush node -> CEPH_OSD_* flags
521 mempool::osdmap::map
<int32_t,uint32_t> device_class_flags
; // device class -> CEPH_OSD_* flags
523 utime_t last_up_change
, last_in_change
;
525 // These features affect OSDMap[::Incremental] encoding, or the
526 // encoding of some type embedded therein (CrushWrapper, something
527 // from osd_types, etc.).
528 static constexpr uint64_t SIGNIFICANT_FEATURES
=
529 CEPH_FEATUREMASK_PGID64
|
530 CEPH_FEATUREMASK_PGPOOL3
|
531 CEPH_FEATUREMASK_OSDENC
|
532 CEPH_FEATUREMASK_OSDMAP_ENC
|
533 CEPH_FEATUREMASK_OSD_POOLRESEND
|
534 CEPH_FEATUREMASK_NEW_OSDOP_ENCODING
|
535 CEPH_FEATUREMASK_MSG_ADDR2
|
536 CEPH_FEATUREMASK_CRUSH_TUNABLES5
|
537 CEPH_FEATUREMASK_CRUSH_CHOOSE_ARGS
|
538 CEPH_FEATUREMASK_SERVER_LUMINOUS
|
539 CEPH_FEATUREMASK_SERVER_MIMIC
|
540 CEPH_FEATUREMASK_SERVER_NAUTILUS
;
543 mempool::osdmap::vector
<std::shared_ptr
<entity_addrvec_t
> > client_addrs
;
544 mempool::osdmap::vector
<std::shared_ptr
<entity_addrvec_t
> > cluster_addrs
;
545 mempool::osdmap::vector
<std::shared_ptr
<entity_addrvec_t
> > hb_back_addrs
;
546 mempool::osdmap::vector
<std::shared_ptr
<entity_addrvec_t
> > hb_front_addrs
;
548 std::shared_ptr
<addrs_s
> osd_addrs
;
550 entity_addrvec_t _blank_addrvec
;
552 mempool::osdmap::vector
<__u32
> osd_weight
; // 16.16 fixed point, 0x10000 = "in", 0 = "out"
553 mempool::osdmap::vector
<osd_info_t
> osd_info
;
554 std::shared_ptr
<PGTempMap
> pg_temp
; // temp pg mapping (e.g. while we rebuild)
555 std::shared_ptr
< mempool::osdmap::map
<pg_t
,int32_t > > primary_temp
; // temp primary mapping (e.g. while we rebuild)
556 std::shared_ptr
< mempool::osdmap::vector
<__u32
> > osd_primary_affinity
; ///< 16.16 fixed point, 0x10000 = baseline
558 // remap (post-CRUSH, pre-up)
559 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<int32_t>> pg_upmap
; ///< remap pg
560 mempool::osdmap::map
<pg_t
,mempool::osdmap::vector
<pair
<int32_t,int32_t>>> pg_upmap_items
; ///< remap osds in up set
562 mempool::osdmap::map
<int64_t,pg_pool_t
> pools
;
563 mempool::osdmap::map
<int64_t,string
> pool_name
;
564 mempool::osdmap::map
<string
,map
<string
,string
> > erasure_code_profiles
;
565 mempool::osdmap::map
<string
,int64_t> name_pool
;
567 std::shared_ptr
< mempool::osdmap::vector
<uuid_d
> > osd_uuid
;
568 mempool::osdmap::vector
<osd_xinfo_t
> osd_xinfo
;
570 mempool::osdmap::unordered_map
<entity_addr_t
,utime_t
> blacklist
;
572 /// queue of snaps to remove
573 mempool::osdmap::map
<int64_t, snap_interval_set_t
> removed_snaps_queue
;
575 /// removed_snaps additions this epoch
576 mempool::osdmap::map
<int64_t, snap_interval_set_t
> new_removed_snaps
;
578 /// removed_snaps removals this epoch
579 mempool::osdmap::map
<int64_t, snap_interval_set_t
> new_purged_snaps
;
581 epoch_t cluster_snapshot_epoch
;
582 string cluster_snapshot
;
583 bool new_blacklist_entries
;
585 float full_ratio
= 0, backfillfull_ratio
= 0, nearfull_ratio
= 0;
587 /// min compat client we want to support
588 uint8_t require_min_compat_client
= 0; // CEPH_RELEASE_*
591 /// require osds to run at least this release
592 uint8_t require_osd_release
= 0; // CEPH_RELEASE_*
595 mutable uint64_t cached_up_osd_features
;
597 mutable bool crc_defined
;
598 mutable uint32_t crc
;
600 void _calc_up_osd_features();
603 bool have_crc() const { return crc_defined
; }
604 uint32_t get_crc() const { return crc
; }
606 std::shared_ptr
<CrushWrapper
> crush
; // hierarchical map
608 uint32_t crush_version
= 1;
610 friend class OSDMonitor
;
616 num_osd(0), num_up_osd(0), num_in_osd(0),
618 osd_addrs(std::make_shared
<addrs_s
>()),
619 pg_temp(std::make_shared
<PGTempMap
>()),
620 primary_temp(std::make_shared
<mempool::osdmap::map
<pg_t
,int32_t>>()),
621 osd_uuid(std::make_shared
<mempool::osdmap::vector
<uuid_d
>>()),
622 cluster_snapshot_epoch(0),
623 new_blacklist_entries(false),
624 cached_up_osd_features(0),
625 crc_defined(false), crc(0),
626 crush(std::make_shared
<CrushWrapper
>()) {
630 OSDMap(const OSDMap
& other
) = default;
631 OSDMap
& operator=(const OSDMap
& other
) = default;
634 /// return feature mask subset that is relevant to OSDMap encoding
635 static uint64_t get_significant_features(uint64_t features
) {
636 return SIGNIFICANT_FEATURES
& features
;
639 uint64_t get_encoding_features() const;
641 void deepish_copy_from(const OSDMap
& o
) {
643 primary_temp
.reset(new mempool::osdmap::map
<pg_t
,int32_t>(*o
.primary_temp
));
644 pg_temp
.reset(new PGTempMap(*o
.pg_temp
));
645 osd_uuid
.reset(new mempool::osdmap::vector
<uuid_d
>(*o
.osd_uuid
));
647 if (o
.osd_primary_affinity
)
648 osd_primary_affinity
.reset(new mempool::osdmap::vector
<__u32
>(*o
.osd_primary_affinity
));
650 // NOTE: this still references shared entity_addrvec_t's.
651 osd_addrs
.reset(new addrs_s(*o
.osd_addrs
));
653 // NOTE: we do not copy crush. note that apply_incremental will
654 // allocate a new CrushWrapper, though.
658 const uuid_d
& get_fsid() const { return fsid
; }
659 void set_fsid(uuid_d
& f
) { fsid
= f
; }
661 epoch_t
get_epoch() const { return epoch
; }
662 void inc_epoch() { epoch
++; }
664 void set_epoch(epoch_t e
);
666 uint32_t get_crush_version() const {
667 return crush_version
;
671 const utime_t
& get_created() const { return created
; }
672 const utime_t
& get_modified() const { return modified
; }
674 bool is_blacklisted(const entity_addr_t
& a
) const;
675 bool is_blacklisted(const entity_addrvec_t
& a
) const;
676 void get_blacklist(list
<pair
<entity_addr_t
,utime_t
> > *bl
) const;
677 void get_blacklist(std::set
<entity_addr_t
> *bl
) const;
679 string
get_cluster_snapshot() const {
680 if (cluster_snapshot_epoch
== epoch
)
681 return cluster_snapshot
;
685 float get_full_ratio() const {
688 float get_backfillfull_ratio() const {
689 return backfillfull_ratio
;
691 float get_nearfull_ratio() const {
692 return nearfull_ratio
;
694 void get_full_pools(CephContext
*cct
,
696 set
<int64_t> *backfillfull
,
697 set
<int64_t> *nearfull
) const;
698 void get_full_osd_counts(set
<int> *full
, set
<int> *backfill
,
699 set
<int> *nearfull
) const;
702 /***** cluster state *****/
704 int get_max_osd() const { return max_osd
; }
705 void set_max_osd(int m
);
707 unsigned get_num_osds() const {
710 unsigned get_num_up_osds() const {
713 unsigned get_num_in_osds() const {
716 /// recalculate cached values for get_num{,_up,_in}_osds
719 void get_all_osds(set
<int32_t>& ls
) const;
720 void get_up_osds(set
<int32_t>& ls
) const;
721 void get_out_osds(set
<int32_t>& ls
) const;
722 void get_out_existing_osds(std::set
<int32_t>& ls
) const;
723 unsigned get_num_pg_temp() const {
724 return pg_temp
->size();
727 int get_flags() const { return flags
; }
728 bool test_flag(int f
) const { return flags
& f
; }
729 void set_flag(int f
) { flags
|= f
; }
730 void clear_flag(int f
) { flags
&= ~f
; }
732 void get_flag_set(set
<string
> *flagset
) const;
734 static void calc_state_set(int state
, set
<string
>& st
);
736 int get_state(int o
) const {
737 ceph_assert(o
< max_osd
);
740 int get_state(int o
, set
<string
>& st
) const {
741 ceph_assert(o
< max_osd
);
742 unsigned t
= osd_state
[o
];
743 calc_state_set(t
, st
);
746 void set_state(int o
, unsigned s
) {
747 ceph_assert(o
< max_osd
);
750 void set_weight(int o
, unsigned w
) {
751 ceph_assert(o
< max_osd
);
754 osd_state
[o
] |= CEPH_OSD_EXISTS
;
756 unsigned get_weight(int o
) const {
757 ceph_assert(o
< max_osd
);
758 return osd_weight
[o
];
760 float get_weightf(int o
) const {
761 return (float)get_weight(o
) / (float)CEPH_OSD_IN
;
763 void adjust_osd_weights(const map
<int,double>& weights
, Incremental
& inc
) const;
765 void set_primary_affinity(int o
, int w
) {
766 ceph_assert(o
< max_osd
);
767 if (!osd_primary_affinity
)
768 osd_primary_affinity
.reset(
769 new mempool::osdmap::vector
<__u32
>(
770 max_osd
, CEPH_OSD_DEFAULT_PRIMARY_AFFINITY
));
771 (*osd_primary_affinity
)[o
] = w
;
773 unsigned get_primary_affinity(int o
) const {
774 ceph_assert(o
< max_osd
);
775 if (!osd_primary_affinity
)
776 return CEPH_OSD_DEFAULT_PRIMARY_AFFINITY
;
777 return (*osd_primary_affinity
)[o
];
779 float get_primary_affinityf(int o
) const {
780 return (float)get_primary_affinity(o
) / (float)CEPH_OSD_MAX_PRIMARY_AFFINITY
;
783 bool has_erasure_code_profile(const string
&name
) const {
784 auto i
= erasure_code_profiles
.find(name
);
785 return i
!= erasure_code_profiles
.end();
787 int get_erasure_code_profile_default(CephContext
*cct
,
788 map
<string
,string
> &profile_map
,
790 void set_erasure_code_profile(const string
&name
,
791 const map
<string
,string
>& profile
) {
792 erasure_code_profiles
[name
] = profile
;
794 const map
<string
,string
> &get_erasure_code_profile(
795 const string
&name
) const {
796 static map
<string
,string
> empty
;
797 auto i
= erasure_code_profiles
.find(name
);
798 if (i
== erasure_code_profiles
.end())
803 const mempool::osdmap::map
<string
,map
<string
,string
> > &get_erasure_code_profiles() const {
804 return erasure_code_profiles
;
807 bool exists(int osd
) const {
809 return osd
>= 0 && osd
< max_osd
&& (osd_state
[osd
] & CEPH_OSD_EXISTS
);
812 bool is_destroyed(int osd
) const {
813 return exists(osd
) && (osd_state
[osd
] & CEPH_OSD_DESTROYED
);
816 bool is_up(int osd
) const {
817 return exists(osd
) && (osd_state
[osd
] & CEPH_OSD_UP
);
820 bool has_been_up_since(int osd
, epoch_t epoch
) const {
821 return is_up(osd
) && get_up_from(osd
) <= epoch
;
824 bool is_down(int osd
) const {
828 bool is_out(int osd
) const {
829 return !exists(osd
) || get_weight(osd
) == CEPH_OSD_OUT
;
832 bool is_in(int osd
) const {
836 unsigned get_osd_crush_node_flags(int osd
) const;
837 unsigned get_crush_node_flags(int id
) const;
838 unsigned get_device_class_flags(int id
) const;
840 bool is_noup_by_osd(int osd
) const {
841 return exists(osd
) && (osd_state
[osd
] & CEPH_OSD_NOUP
);
844 bool is_nodown_by_osd(int osd
) const {
845 return exists(osd
) && (osd_state
[osd
] & CEPH_OSD_NODOWN
);
848 bool is_noin_by_osd(int osd
) const {
849 return exists(osd
) && (osd_state
[osd
] & CEPH_OSD_NOIN
);
852 bool is_noout_by_osd(int osd
) const {
853 return exists(osd
) && (osd_state
[osd
] & CEPH_OSD_NOOUT
);
856 bool is_noup(int osd
) const {
857 if (test_flag(CEPH_OSDMAP_NOUP
)) // global?
859 if (is_noup_by_osd(osd
)) // by osd?
861 if (get_osd_crush_node_flags(osd
) & CEPH_OSD_NOUP
) // by crush-node?
863 if (auto class_id
= crush
->get_item_class_id(osd
); class_id
>= 0 &&
864 get_device_class_flags(class_id
) & CEPH_OSD_NOUP
) // by device-class?
869 bool is_nodown(int osd
) const {
870 if (test_flag(CEPH_OSDMAP_NODOWN
))
872 if (is_nodown_by_osd(osd
))
874 if (get_osd_crush_node_flags(osd
) & CEPH_OSD_NODOWN
)
876 if (auto class_id
= crush
->get_item_class_id(osd
); class_id
>= 0 &&
877 get_device_class_flags(class_id
) & CEPH_OSD_NODOWN
)
882 bool is_noin(int osd
) const {
883 if (test_flag(CEPH_OSDMAP_NOIN
))
885 if (is_noin_by_osd(osd
))
887 if (get_osd_crush_node_flags(osd
) & CEPH_OSD_NOIN
)
889 if (auto class_id
= crush
->get_item_class_id(osd
); class_id
>= 0 &&
890 get_device_class_flags(class_id
) & CEPH_OSD_NOIN
)
895 bool is_noout(int osd
) const {
896 if (test_flag(CEPH_OSDMAP_NOOUT
))
898 if (is_noout_by_osd(osd
))
900 if (get_osd_crush_node_flags(osd
) & CEPH_OSD_NOOUT
)
902 if (auto class_id
= crush
->get_item_class_id(osd
); class_id
>= 0 &&
903 get_device_class_flags(class_id
) & CEPH_OSD_NOOUT
)
909 * check if an entire crush subtree is down
911 bool subtree_is_down(int id
, set
<int> *down_cache
) const;
912 bool containing_subtree_is_down(CephContext
*cct
, int osd
, int subtree_type
, set
<int> *down_cache
) const;
914 bool subtree_type_is_down(CephContext
*cct
, int id
, int subtree_type
, set
<int> *down_in_osds
, set
<int> *up_in_osds
,
915 set
<int> *subtree_up
, unordered_map
<int, set
<int> > *subtree_type_down
) const;
917 int identify_osd(const entity_addr_t
& addr
) const;
918 int identify_osd(const uuid_d
& u
) const;
919 int identify_osd_on_all_channels(const entity_addr_t
& addr
) const;
921 bool have_addr(const entity_addr_t
& addr
) const {
922 return identify_osd(addr
) >= 0;
924 int find_osd_on_ip(const entity_addr_t
& ip
) const;
926 const entity_addrvec_t
& get_addrs(int osd
) const {
927 ceph_assert(exists(osd
));
928 return osd_addrs
->client_addrs
[osd
] ?
929 *osd_addrs
->client_addrs
[osd
] : _blank_addrvec
;
931 const entity_addrvec_t
& get_most_recent_addrs(int osd
) const {
932 return get_addrs(osd
);
934 const entity_addrvec_t
&get_cluster_addrs(int osd
) const {
935 ceph_assert(exists(osd
));
936 return osd_addrs
->cluster_addrs
[osd
] ?
937 *osd_addrs
->cluster_addrs
[osd
] : _blank_addrvec
;
939 const entity_addrvec_t
&get_hb_back_addrs(int osd
) const {
940 ceph_assert(exists(osd
));
941 return osd_addrs
->hb_back_addrs
[osd
] ?
942 *osd_addrs
->hb_back_addrs
[osd
] : _blank_addrvec
;
944 const entity_addrvec_t
&get_hb_front_addrs(int osd
) const {
945 ceph_assert(exists(osd
));
946 return osd_addrs
->hb_front_addrs
[osd
] ?
947 *osd_addrs
->hb_front_addrs
[osd
] : _blank_addrvec
;
950 const uuid_d
& get_uuid(int osd
) const {
951 ceph_assert(exists(osd
));
952 return (*osd_uuid
)[osd
];
955 const epoch_t
& get_up_from(int osd
) const {
956 ceph_assert(exists(osd
));
957 return osd_info
[osd
].up_from
;
959 const epoch_t
& get_up_thru(int osd
) const {
960 ceph_assert(exists(osd
));
961 return osd_info
[osd
].up_thru
;
963 const epoch_t
& get_down_at(int osd
) const {
964 ceph_assert(exists(osd
));
965 return osd_info
[osd
].down_at
;
967 const osd_info_t
& get_info(int osd
) const {
968 ceph_assert(osd
< max_osd
);
969 return osd_info
[osd
];
972 const osd_xinfo_t
& get_xinfo(int osd
) const {
973 ceph_assert(osd
< max_osd
);
974 return osd_xinfo
[osd
];
977 int get_next_up_osd_after(int n
) const {
978 if (get_max_osd() == 0)
980 for (int i
= n
+ 1; i
!= n
; ++i
) {
981 if (i
>= get_max_osd())
991 int get_previous_up_osd_before(int n
) const {
992 if (get_max_osd() == 0)
994 for (int i
= n
- 1; i
!= n
; --i
) {
996 i
= get_max_osd() - 1;
1006 void get_random_up_osds_by_subtree(int n
, // whoami
1008 int limit
, // how many
1010 set
<int> *want
) const;
1013 * get feature bits required by the current structure
1015 * @param entity_type [in] what entity type we are asking about
1016 * @param mask [out] set of all possible map-related features we could set
1017 * @return feature bits used by this map
1019 uint64_t get_features(int entity_type
, uint64_t *mask
) const;
1022 * get oldest *client* version (firefly, hammer, etc.) that can connect given
1023 * the feature bits required (according to get_features()).
1025 uint8_t get_min_compat_client() const;
1028 * gets the required minimum *client* version that can connect to the cluster.
1030 uint8_t get_require_min_compat_client() const;
1033 * get intersection of features supported by up osds
1035 uint64_t get_up_osd_features() const;
1037 void maybe_remove_pg_upmaps(CephContext
*cct
,
1038 const OSDMap
& oldmap
,
1039 const OSDMap
& nextmap
,
1040 Incremental
*pending_inc
);
1042 int apply_incremental(const Incremental
&inc
);
1044 /// try to re-use/reference addrs in oldmap from newmap
1045 static void dedup(const OSDMap
*oldmap
, OSDMap
*newmap
);
1047 static void clean_temps(CephContext
*cct
,
1048 const OSDMap
& oldmap
,
1049 const OSDMap
& nextmap
,
1050 Incremental
*pending_inc
);
1052 // serialize, unserialize
1054 void encode_client_old(bufferlist
& bl
) const;
1055 void encode_classic(bufferlist
& bl
, uint64_t features
) const;
1056 void decode_classic(bufferlist::const_iterator
& p
);
1059 void encode(bufferlist
& bl
, uint64_t features
=CEPH_FEATURES_ALL
) const;
1060 void decode(bufferlist
& bl
);
1061 void decode(bufferlist::const_iterator
& bl
);
1064 /**** mapping facilities ****/
1069 const string
& nspace
,
1071 int object_locator_to_pg(const object_t
& oid
, const object_locator_t
& loc
,
1073 pg_t
object_locator_to_pg(const object_t
& oid
,
1074 const object_locator_t
& loc
) const {
1076 int ret
= object_locator_to_pg(oid
, loc
, pg
);
1077 ceph_assert(ret
== 0);
1082 static object_locator_t
file_to_object_locator(const file_layout_t
& layout
) {
1083 return object_locator_t(layout
.pool_id
, layout
.pool_ns
);
1086 ceph_object_layout
file_to_object_layout(object_t oid
,
1087 file_layout_t
& layout
) const {
1088 return make_object_layout(oid
, layout
.pool_id
, layout
.pool_ns
);
1091 ceph_object_layout
make_object_layout(object_t oid
, int pg_pool
,
1092 string nspace
) const;
1094 int get_pg_num(int pg_pool
) const
1096 const pg_pool_t
*pool
= get_pg_pool(pg_pool
);
1097 ceph_assert(NULL
!= pool
);
1098 return pool
->get_pg_num();
1101 bool pg_exists(pg_t pgid
) const {
1102 const pg_pool_t
*p
= get_pg_pool(pgid
.pool());
1103 return p
&& pgid
.ps() < p
->get_pg_num();
1106 int get_pg_pool_min_size(pg_t pgid
) const {
1107 if (!pg_exists(pgid
)) {
1110 const pg_pool_t
*p
= get_pg_pool(pgid
.pool());
1112 return p
->get_min_size();
1115 int get_pg_pool_size(pg_t pgid
) const {
1116 if (!pg_exists(pgid
)) {
1119 const pg_pool_t
*p
= get_pg_pool(pgid
.pool());
1121 return p
->get_size();
1124 int get_pg_pool_crush_rule(pg_t pgid
) const {
1125 if (!pg_exists(pgid
)) {
1128 const pg_pool_t
*p
= get_pg_pool(pgid
.pool());
1130 return p
->get_crush_rule();
1134 /// pg -> (raw osd list)
1135 void _pg_to_raw_osds(
1136 const pg_pool_t
& pool
, pg_t pg
,
1139 int _pick_primary(const vector
<int>& osds
) const;
1140 void _remove_nonexistent_osds(const pg_pool_t
& pool
, vector
<int>& osds
) const;
1142 void _apply_primary_affinity(ps_t seed
, const pg_pool_t
& pool
,
1143 vector
<int> *osds
, int *primary
) const;
1145 /// apply pg_upmap[_items] mappings
1146 void _apply_upmap(const pg_pool_t
& pi
, pg_t pg
, vector
<int> *raw
) const;
1148 /// pg -> (up osd list)
1149 void _raw_to_up_osds(const pg_pool_t
& pool
, const vector
<int>& raw
,
1150 vector
<int> *up
) const;
1154 * Get the pg and primary temp, if they are specified.
1155 * @param temp_pg [out] Will be empty or contain the temp PG mapping on return
1156 * @param temp_primary [out] Will be the value in primary_temp, or a value derived
1157 * from the pg_temp (if specified), or -1 if you should use the calculated (up_)primary.
1159 void _get_temp_osds(const pg_pool_t
& pool
, pg_t pg
,
1160 vector
<int> *temp_pg
, int *temp_primary
) const;
1163 * map to up and acting. Fills in whatever fields are non-NULL.
1165 void _pg_to_up_acting_osds(const pg_t
& pg
, vector
<int> *up
, int *up_primary
,
1166 vector
<int> *acting
, int *acting_primary
,
1167 bool raw_pg_to_pg
= true) const;
1171 * This is suitable only for looking at raw CRUSH outputs. It skips
1172 * applying the temp and up checks and should not be used
1173 * by anybody for data mapping purposes.
1174 * raw and primary must be non-NULL
1176 void pg_to_raw_osds(pg_t pg
, vector
<int> *raw
, int *primary
) const;
1177 void pg_to_raw_upmap(pg_t pg
, vector
<int> *raw_upmap
) const;
1178 /// map a pg to its acting set. @return acting set size
1179 void pg_to_acting_osds(const pg_t
& pg
, vector
<int> *acting
,
1180 int *acting_primary
) const {
1181 _pg_to_up_acting_osds(pg
, NULL
, NULL
, acting
, acting_primary
);
1183 void pg_to_acting_osds(pg_t pg
, vector
<int>& acting
) const {
1184 return pg_to_acting_osds(pg
, &acting
, NULL
);
1187 * This does not apply temp overrides and should not be used
1188 * by anybody for data mapping purposes. Specify both pointers.
1190 void pg_to_raw_up(pg_t pg
, vector
<int> *up
, int *primary
) const;
1192 * map a pg to its acting set as well as its up set. You must use
1193 * the acting set for data mapping purposes, but some users will
1194 * also find the up set useful for things like deciding what to
1196 * Each of these pointers must be non-NULL.
1198 void pg_to_up_acting_osds(pg_t pg
, vector
<int> *up
, int *up_primary
,
1199 vector
<int> *acting
, int *acting_primary
) const {
1200 _pg_to_up_acting_osds(pg
, up
, up_primary
, acting
, acting_primary
);
1202 void pg_to_up_acting_osds(pg_t pg
, vector
<int>& up
, vector
<int>& acting
) const {
1203 int up_primary
, acting_primary
;
1204 pg_to_up_acting_osds(pg
, &up
, &up_primary
, &acting
, &acting_primary
);
1206 bool pg_is_ec(pg_t pg
) const {
1207 auto i
= pools
.find(pg
.pool());
1208 ceph_assert(i
!= pools
.end());
1209 return i
->second
.is_erasure();
1211 bool get_primary_shard(const pg_t
& pgid
, spg_t
*out
) const {
1212 auto i
= get_pools().find(pgid
.pool());
1213 if (i
== get_pools().end()) {
1216 if (!i
->second
.is_erasure()) {
1222 pg_to_acting_osds(pgid
, &acting
, &primary
);
1223 for (uint8_t i
= 0; i
< acting
.size(); ++i
) {
1224 if (acting
[i
] == primary
) {
1225 *out
= spg_t(pgid
, shard_id_t(i
));
1231 bool get_primary_shard(const pg_t
& pgid
, int *primary
, spg_t
*out
) const {
1232 auto i
= get_pools().find(pgid
.pool());
1233 if (i
== get_pools().end()) {
1237 pg_to_acting_osds(pgid
, &acting
, primary
);
1238 if (i
->second
.is_erasure()) {
1239 for (uint8_t i
= 0; i
< acting
.size(); ++i
) {
1240 if (acting
[i
] == *primary
) {
1241 *out
= spg_t(pgid
, shard_id_t(i
));
1252 const mempool::osdmap::map
<int64_t,snap_interval_set_t
>&
1253 get_removed_snaps_queue() const {
1254 return removed_snaps_queue
;
1256 const mempool::osdmap::map
<int64_t,snap_interval_set_t
>&
1257 get_new_removed_snaps() const {
1258 return new_removed_snaps
;
1260 const mempool::osdmap::map
<int64_t,snap_interval_set_t
>&
1261 get_new_purged_snaps() const {
1262 return new_purged_snaps
;
1265 int64_t lookup_pg_pool_name(const string
& name
) const {
1266 auto p
= name_pool
.find(name
);
1267 if (p
== name_pool
.end())
1272 int64_t get_pool_max() const {
1275 const mempool::osdmap::map
<int64_t,pg_pool_t
>& get_pools() const {
1278 mempool::osdmap::map
<int64_t,pg_pool_t
>& get_pools() {
1281 void get_pool_ids_by_rule(int rule_id
, set
<int64_t> *pool_ids
) const {
1282 ceph_assert(pool_ids
);
1283 for (auto &p
: pools
) {
1284 if (p
.second
.get_crush_rule() == rule_id
) {
1285 pool_ids
->insert(p
.first
);
1289 void get_pool_ids_by_osd(CephContext
*cct
,
1291 set
<int64_t> *pool_ids
) const;
1292 const string
& get_pool_name(int64_t p
) const {
1293 auto i
= pool_name
.find(p
);
1294 ceph_assert(i
!= pool_name
.end());
1297 const mempool::osdmap::map
<int64_t,string
>& get_pool_names() const {
1300 bool have_pg_pool(int64_t p
) const {
1301 return pools
.count(p
);
1303 const pg_pool_t
* get_pg_pool(int64_t p
) const {
1304 auto i
= pools
.find(p
);
1305 if (i
!= pools
.end())
1309 unsigned get_pg_size(pg_t pg
) const {
1310 auto p
= pools
.find(pg
.pool());
1311 ceph_assert(p
!= pools
.end());
1312 return p
->second
.get_size();
1314 int get_pg_type(pg_t pg
) const {
1315 auto p
= pools
.find(pg
.pool());
1316 ceph_assert(p
!= pools
.end());
1317 return p
->second
.get_type();
1321 pg_t
raw_pg_to_pg(pg_t pg
) const {
1322 auto p
= pools
.find(pg
.pool());
1323 ceph_assert(p
!= pools
.end());
1324 return p
->second
.raw_pg_to_pg(pg
);
1327 // pg -> acting primary osd
1328 int get_pg_acting_primary(pg_t pg
) const {
1330 _pg_to_up_acting_osds(pg
, nullptr, nullptr, nullptr, &primary
);
1335 * check whether an spg_t maps to a particular osd
1337 bool is_up_acting_osd_shard(spg_t pg
, int osd
) const {
1338 vector
<int> up
, acting
;
1339 _pg_to_up_acting_osds(pg
.pgid
, &up
, NULL
, &acting
, NULL
, false);
1340 if (pg
.shard
== shard_id_t::NO_SHARD
) {
1341 if (calc_pg_role(osd
, acting
, acting
.size()) >= 0 ||
1342 calc_pg_role(osd
, up
, up
.size()) >= 0)
1345 if (pg
.shard
< (int)acting
.size() && acting
[pg
.shard
] == osd
)
1347 if (pg
.shard
< (int)up
.size() && up
[pg
.shard
] == osd
)
1354 /* what replica # is a given osd? 0 primary, -1 for none. */
1355 static int calc_pg_rank(int osd
, const vector
<int>& acting
, int nrep
=0);
1356 static int calc_pg_role(int osd
, const vector
<int>& acting
, int nrep
=0);
1357 static bool primary_changed(
1359 const vector
<int> &oldacting
,
1361 const vector
<int> &newacting
);
1363 /* rank is -1 (stray), 0 (primary), 1,2,3,... (replica) */
1364 int get_pg_acting_rank(pg_t pg
, int osd
) const {
1366 pg_to_acting_osds(pg
, group
);
1367 return calc_pg_rank(osd
, group
, group
.size());
1369 /* role is -1 (stray), 0 (primary), 1 (replica) */
1370 int get_pg_acting_role(const pg_t
& pg
, int osd
) const {
1372 pg_to_acting_osds(pg
, group
);
1373 return calc_pg_role(osd
, group
, group
.size());
1376 bool osd_is_valid_op_target(pg_t pg
, int osd
) const {
1379 pg_to_acting_osds(pg
, &group
, &primary
);
1385 return calc_pg_role(osd
, group
, group
.size()) >= 0;
1388 int clean_pg_upmaps(
1390 Incremental
*pending_inc
) const;
1394 pg_t pg
, ///< pg to potentially remap
1395 const set
<int>& overfull
, ///< osds we'd want to evacuate
1396 const vector
<int>& underfull
, ///< osds to move to, in order of preference
1398 vector
<int> *out
); ///< resulting alternative mapping
1402 float max_deviation
, ///< max deviation from target (value < 1.0)
1403 int max_iterations
, ///< max iterations to run
1404 const set
<int64_t>& pools
, ///< [optional] restrict to pool
1405 Incremental
*pending_inc
1408 int get_osds_by_bucket_name(const string
&name
, set
<int> *osds
) const;
1410 bool have_pg_upmaps(pg_t pg
) const {
1411 return pg_upmap
.count(pg
) ||
1412 pg_upmap_items
.count(pg
);
1416 * handy helpers to build simple maps...
1419 * Build an OSD map suitable for basic usage. If **num_osd** is >= 0
1420 * it will be initialized with the specified number of OSDs in a
1421 * single host. If **num_osd** is < 0 the layout of the OSD map will
1422 * be built by reading the content of the configuration file.
1424 * @param cct [in] in core ceph context
1425 * @param e [in] initial epoch
1426 * @param fsid [in] id of the cluster
1427 * @param num_osd [in] number of OSDs if >= 0 or read from conf if < 0
1428 * @return **0** on success, negative errno on error.
1431 int build_simple_optioned(CephContext
*cct
, epoch_t e
, uuid_d
&fsid
,
1432 int num_osd
, int pg_bits
, int pgp_bits
,
1435 int build_simple(CephContext
*cct
, epoch_t e
, uuid_d
&fsid
,
1437 return build_simple_optioned(cct
, e
, fsid
, num_osd
, 0, 0, false);
1439 int build_simple_with_pool(CephContext
*cct
, epoch_t e
, uuid_d
&fsid
,
1440 int num_osd
, int pg_bits
, int pgp_bits
) {
1441 return build_simple_optioned(cct
, e
, fsid
, num_osd
,
1442 pg_bits
, pgp_bits
, true);
1444 static int _build_crush_types(CrushWrapper
& crush
);
1445 static int build_simple_crush_map(CephContext
*cct
, CrushWrapper
& crush
,
1446 int num_osd
, ostream
*ss
);
1447 static int build_simple_crush_map_from_conf(CephContext
*cct
,
1448 CrushWrapper
& crush
,
1450 static int build_simple_crush_rules(
1451 CephContext
*cct
, CrushWrapper
& crush
,
1455 bool crush_rule_in_use(int rule_id
) const;
1457 int validate_crush_rules(CrushWrapper
*crush
, ostream
*ss
) const;
1461 primary_temp
->clear();
1465 void print_osd_line(int cur
, ostream
*out
, Formatter
*f
) const;
1467 void print(ostream
& out
) const;
1468 void print_pools(ostream
& out
) const;
1469 void print_summary(Formatter
*f
, ostream
& out
, const string
& prefix
, bool extra
=false) const;
1470 void print_oneline_summary(ostream
& out
) const;
1473 DUMP_IN
= 1, // only 'in' osds
1474 DUMP_OUT
= 2, // only 'out' osds
1475 DUMP_UP
= 4, // only 'up' osds
1476 DUMP_DOWN
= 8, // only 'down' osds
1477 DUMP_DESTROYED
= 16, // only 'destroyed' osds
1479 void print_tree(Formatter
*f
, ostream
*out
, unsigned dump_flags
=0, string bucket
="") const;
1481 int summarize_mapping_stats(
1483 const set
<int64_t> *pools
,
1485 Formatter
*f
) const;
1487 string
get_flag_string() const;
1488 static string
get_flag_string(unsigned flags
);
1489 static void dump_erasure_code_profiles(
1490 const mempool::osdmap::map
<string
,map
<string
,string
> > &profiles
,
1492 void dump(Formatter
*f
) const;
1493 static void generate_test_instances(list
<OSDMap
*>& o
);
1494 bool check_new_blacklist_entries() const { return new_blacklist_entries
; }
1496 void check_health(health_check_map_t
*checks
) const;
1498 int parse_osd_id_list(const vector
<string
>& ls
,
1502 float pool_raw_used_rate(int64_t poolid
) const;
1505 WRITE_CLASS_ENCODER_FEATURES(OSDMap
)
1506 WRITE_CLASS_ENCODER_FEATURES(OSDMap::Incremental
)
1508 typedef std::shared_ptr
<const OSDMap
> OSDMapRef
;
1510 inline ostream
& operator<<(ostream
& out
, const OSDMap
& m
) {
1511 m
.print_oneline_summary(out
);
1517 void print_osd_utilization(const OSDMap
& osdmap
,
1522 const string
& class_name
,
1523 const string
& item_name
);