bool OSDMonitor::can_mark_down(int i)
{
- if (osdmap.test_flag(CEPH_OSDMAP_NODOWN)) {
- dout(5) << __func__ << " NODOWN flag set, will not mark osd." << i
- << " down" << dendl;
- return false;
- }
-
if (osdmap.is_nodown(i)) {
dout(5) << __func__ << " osd." << i << " is marked as nodown, "
<< "will not mark it down" << dendl;
return false;
}
- if (osdmap.get_osd_crush_node_flags(i) & CEPH_OSD_NODOWN) {
- dout(5) << __func__ << " osd." << i
- << " is marked as nodown via a crush node flag, "
- << "will not mark it down" << dendl;
- return false;
- }
-
- if (auto class_id = osdmap.crush->get_item_class_id(i); class_id >= 0 &&
- (osdmap.get_device_class_flags(class_id) & CEPH_OSD_NODOWN)) {
- dout(5) << __func__ << " osd." << i
- << " is marked as nodown via device class, "
- << "will not mark it down" << dendl;
- return false;
- }
-
int num_osds = osdmap.get_num_osds();
if (num_osds == 0) {
dout(5) << __func__ << " no osds" << dendl;
bool OSDMonitor::can_mark_up(int i)
{
- if (osdmap.test_flag(CEPH_OSDMAP_NOUP)) {
- dout(5) << __func__ << " NOUP flag set, will not mark osd." << i
- << " up" << dendl;
- return false;
- }
-
if (osdmap.is_noup(i)) {
dout(5) << __func__ << " osd." << i << " is marked as noup, "
<< "will not mark it up" << dendl;
return false;
}
- if (osdmap.get_osd_crush_node_flags(i) & CEPH_OSD_NOUP) {
- dout(5) << __func__ << " osd." << i
- << " is marked as noup via a crush node flag, "
- << "will not mark it up" << dendl;
- return false;
- }
-
- if (auto class_id = osdmap.crush->get_item_class_id(i); class_id >= 0 &&
- (osdmap.get_device_class_flags(class_id) & CEPH_OSD_NOUP)) {
- dout(5) << __func__ << " osd." << i
- << " is marked as noup via device class, "
- << "will not mark it up" << dendl;
- return false;
- }
-
return true;
}
*/
bool OSDMonitor::can_mark_out(int i)
{
- if (osdmap.test_flag(CEPH_OSDMAP_NOOUT)) {
- dout(5) << __func__ << " NOOUT flag set, will not mark osds out" << dendl;
- return false;
- }
-
if (osdmap.is_noout(i)) {
dout(5) << __func__ << " osd." << i << " is marked as noout, "
<< "will not mark it out" << dendl;
return false;
}
- if (osdmap.get_osd_crush_node_flags(i) & CEPH_OSD_NOOUT) {
- dout(5) << __func__ << " osd." << i
- << " is marked as noout via a crush node flag, "
- << "will not mark it out" << dendl;
- return false;
- }
-
- if (auto class_id = osdmap.crush->get_item_class_id(i); class_id >= 0 &&
- (osdmap.get_device_class_flags(class_id) & CEPH_OSD_NOOUT)) {
- dout(5) << __func__ << " osd." << i
- << " is marked as noout via device class, "
- << "will not mark it out" << dendl;
- return false;
- }
-
int num_osds = osdmap.get_num_osds();
if (num_osds == 0) {
dout(5) << __func__ << " no osds" << dendl;
bool OSDMonitor::can_mark_in(int i)
{
- if (osdmap.test_flag(CEPH_OSDMAP_NOIN)) {
- dout(5) << __func__ << " NOIN flag set, will not mark osd." << i
- << " in" << dendl;
- return false;
- }
-
if (osdmap.is_noin(i)) {
dout(5) << __func__ << " osd." << i << " is marked as noin, "
<< "will not mark it in" << dendl;
return false;
}
- if (osdmap.get_osd_crush_node_flags(i) & CEPH_OSD_NOIN) {
- dout(5) << __func__ << " osd." << i
- << " is marked as noin via a crush node flag, "
- << "will not mark it in" << dendl;
- return false;
- }
-
- if (auto class_id = osdmap.crush->get_item_class_id(i); class_id >= 0 &&
- (osdmap.get_device_class_flags(class_id) & CEPH_OSD_NOIN)) {
- dout(5) << __func__ << " osd." << i
- << " is marked as noin via device class, "
- << "will not mark it in" << dendl;
- return false;
- }
-
return true;
}
}
if (do_set) {
if (flags & CEPH_OSD_NOUP) {
- any |= osdmap.is_noup(osd) ?
+ any |= osdmap.is_noup_by_osd(osd) ?
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NOUP) :
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NOUP);
}
if (flags & CEPH_OSD_NODOWN) {
- any |= osdmap.is_nodown(osd) ?
+ any |= osdmap.is_nodown_by_osd(osd) ?
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NODOWN) :
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NODOWN);
}
if (flags & CEPH_OSD_NOIN) {
- any |= osdmap.is_noin(osd) ?
+ any |= osdmap.is_noin_by_osd(osd) ?
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NOIN) :
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NOIN);
}
if (flags & CEPH_OSD_NOOUT) {
- any |= osdmap.is_noout(osd) ?
+ any |= osdmap.is_noout_by_osd(osd) ?
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NOOUT) :
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NOOUT);
}
} else {
if (flags & CEPH_OSD_NOUP) {
- any |= osdmap.is_noup(osd) ?
+ any |= osdmap.is_noup_by_osd(osd) ?
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NOUP) :
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NOUP);
}
if (flags & CEPH_OSD_NODOWN) {
- any |= osdmap.is_nodown(osd) ?
+ any |= osdmap.is_nodown_by_osd(osd) ?
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NODOWN) :
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NODOWN);
}
if (flags & CEPH_OSD_NOIN) {
- any |= osdmap.is_noin(osd) ?
+ any |= osdmap.is_noin_by_osd(osd) ?
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NOIN) :
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NOIN);
}
if (flags & CEPH_OSD_NOOUT) {
- any |= osdmap.is_noout(osd) ?
+ any |= osdmap.is_noout_by_osd(osd) ?
pending_inc.pending_osd_state_set(osd, CEPH_OSD_NOOUT) :
pending_inc.pending_osd_state_clear(osd, CEPH_OSD_NOOUT);
}
unsigned get_crush_node_flags(int id) const;
unsigned get_device_class_flags(int id) const;
- bool is_noup(int osd) const {
+ bool is_noup_by_osd(int osd) const {
return exists(osd) && (osd_state[osd] & CEPH_OSD_NOUP);
}
- bool is_nodown(int osd) const {
+ bool is_nodown_by_osd(int osd) const {
return exists(osd) && (osd_state[osd] & CEPH_OSD_NODOWN);
}
- bool is_noin(int osd) const {
+ bool is_noin_by_osd(int osd) const {
return exists(osd) && (osd_state[osd] & CEPH_OSD_NOIN);
}
- bool is_noout(int osd) const {
+ bool is_noout_by_osd(int osd) const {
return exists(osd) && (osd_state[osd] & CEPH_OSD_NOOUT);
}
- void get_noup_osds(std::vector<int> *osds) const {
- ceph_assert(osds);
- osds->clear();
-
- for (int i = 0; i < max_osd; i++) {
- if (is_noup(i)) {
- osds->push_back(i);
- }
- }
+ bool is_noup(int osd) const {
+ if (test_flag(CEPH_OSDMAP_NOUP)) // global?
+ return true;
+ if (is_noup_by_osd(osd)) // by osd?
+ return true;
+ if (get_osd_crush_node_flags(osd) & CEPH_OSD_NOUP) // by crush-node?
+ return true;
+ if (auto class_id = crush->get_item_class_id(osd); class_id >= 0 &&
+ get_device_class_flags(class_id) & CEPH_OSD_NOUP) // by device-class?
+ return true;
+ return false;
}
- void get_nodown_osds(std::vector<int> *osds) const {
- ceph_assert(osds);
- osds->clear();
-
- for (int i = 0; i < max_osd; i++) {
- if (is_nodown(i)) {
- osds->push_back(i);
- }
- }
+ bool is_nodown(int osd) const {
+ if (test_flag(CEPH_OSDMAP_NODOWN))
+ return true;
+ if (is_nodown_by_osd(osd))
+ return true;
+ if (get_osd_crush_node_flags(osd) & CEPH_OSD_NODOWN)
+ return true;
+ if (auto class_id = crush->get_item_class_id(osd); class_id >= 0 &&
+ get_device_class_flags(class_id) & CEPH_OSD_NODOWN)
+ return true;
+ return false;
}
- void get_noin_osds(std::vector<int> *osds) const {
- ceph_assert(osds);
- osds->clear();
-
- for (int i = 0; i < max_osd; i++) {
- if (is_noin(i)) {
- osds->push_back(i);
- }
- }
+ bool is_noin(int osd) const {
+ if (test_flag(CEPH_OSDMAP_NOIN))
+ return true;
+ if (is_noin_by_osd(osd))
+ return true;
+ if (get_osd_crush_node_flags(osd) & CEPH_OSD_NOIN)
+ return true;
+ if (auto class_id = crush->get_item_class_id(osd); class_id >= 0 &&
+ get_device_class_flags(class_id) & CEPH_OSD_NOIN)
+ return true;
+ return false;
}
- void get_noout_osds(std::vector<int> *osds) const {
- ceph_assert(osds);
- osds->clear();
-
- for (int i = 0; i < max_osd; i++) {
- if (is_noout(i)) {
- osds->push_back(i);
- }
- }
+ bool is_noout(int osd) const {
+ if (test_flag(CEPH_OSDMAP_NOOUT))
+ return true;
+ if (is_noout_by_osd(osd))
+ return true;
+ if (get_osd_crush_node_flags(osd) & CEPH_OSD_NOOUT)
+ return true;
+ if (auto class_id = crush->get_item_class_id(osd); class_id >= 0 &&
+ get_device_class_flags(class_id) & CEPH_OSD_NOOUT)
+ return true;
+ return false;
}
/**