From: Greg Farnum Date: Thu, 16 Jul 2020 03:08:35 +0000 (+0000) Subject: mon: osd: switch crush_bucket_mandatory_member to be CRUSH_ITEM_NONE-based X-Git-Tag: v16.1.0~1053^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=613b2b19b9284894dcddef2c974cd26e41fb3384;p=ceph.git mon: osd: switch crush_bucket_mandatory_member to be CRUSH_ITEM_NONE-based Previously we compared it to zero, but we could technically want to require osd.0 as a member, maybe? In any case we have a "DNE" indicator in CRUSH_ITEM_NONE, so use it. Also, for osd_types.h, declare a pg_pool_t::pg_CRUSH_ITEM_NONE to use, since apparently we can't import crush.h there and hard-coding it is bad. Signed-off-by: Greg Farnum --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index a2b1122d5b87..28f99ec2953a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7936,11 +7936,11 @@ int OSDMonitor::prepare_new_pool(string& name, pi->peering_crush_bucket_count = osdmap.stretch_bucket_count; pi->peering_crush_bucket_target = osdmap.stretch_bucket_count; pi->peering_crush_bucket_barrier = osdmap.stretch_mode_bucket; - pi->peering_crush_mandatory_member = 0; + pi->peering_crush_mandatory_member = CRUSH_ITEM_NONE; if (osdmap.degraded_stretch_mode) { pi->peering_crush_bucket_count = osdmap.degraded_stretch_mode; pi->peering_crush_bucket_target = osdmap.degraded_stretch_mode; - // pi->peering_crush_bucket_mandatory_member = 0; + // pi->peering_crush_bucket_mandatory_member = CRUSH_ITEM_NONE; // TODO: drat, we don't record this ^ anywhere, though given that it // necessarily won't exist elsewhere it likely doesn't matter pi->min_size = pi->min_size / 2; @@ -14315,7 +14315,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay, pool->peering_crush_bucket_count = bucket_count; pool->peering_crush_bucket_target = bucket_count; pool->peering_crush_bucket_barrier = dividing_id; - pool->peering_crush_mandatory_member = 0; + pool->peering_crush_mandatory_member = CRUSH_ITEM_NONE; pool->size = g_conf().get_val("mon_stretch_pool_size"); pool->min_size = g_conf().get_val("mon_stretch_pool_min_size"); } @@ -14472,7 +14472,7 @@ void OSDMonitor::trigger_healthy_stretch_mode() if (pgi.second.peering_crush_bucket_count) { pg_pool_t newp(pgi.second); newp.peering_crush_bucket_count = osdmap.stretch_bucket_count; - newp.peering_crush_mandatory_member = 0; + newp.peering_crush_mandatory_member = CRUSH_ITEM_NONE; newp.min_size = g_conf().get_val("mon_stretch_pool_min_size"); newp.last_force_op_resend = pending_inc.epoch; pending_inc.new_pools[pgi.first] = newp; diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 93b369d8418e..ba3c7d461505 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -2077,7 +2077,7 @@ void PeeringState::calc_replicated_acting_stretch( * expect that this and other users should instead check against * CRUSH_ITEM_NONE. */ - if (pool.info.peering_crush_mandatory_member != 0) { + if (pool.info.peering_crush_mandatory_member != CRUSH_ITEM_NONE) { auto aiter = ancestors.find(pool.info.peering_crush_mandatory_member); if (aiter != ancestors.end() && aiter->second.get_num_selected()) { diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 8b7c3f088f4f..198fe89d7822 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2036,7 +2036,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const if (peering_crush_bucket_barrier != 0 || peering_crush_bucket_target != 0 || peering_crush_bucket_count !=0 || - peering_crush_mandatory_member) { + peering_crush_mandatory_member != CRUSH_ITEM_NONE) { ceph_assert(v >= 30); new_compat = 30; } @@ -2255,7 +2255,7 @@ bool pg_pool_t::stretch_set_can_peer(const set& want, const OSDMap& osdmap, << want; } return false; - } else if (peering_crush_mandatory_member && + } else if (peering_crush_mandatory_member != CRUSH_ITEM_NONE && !ancestors.count(peering_crush_mandatory_member)) { if (out) { *out << __func__ << ": missing mandatory crush bucket member " diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 9dbee932d267..811075fb3eba 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1175,6 +1175,7 @@ struct pg_pool_t { //TYPE_RAID4 = 2, // raid4 (never implemented) TYPE_ERASURE = 3, // erasure-coded }; + static constexpr uint32_t pg_CRUSH_ITEM_NONE = 0x7fffffff; /* can't import crush.h here */ static std::string_view get_type_name(int t) { switch (t) { case TYPE_REPLICATED: return "replicated"; @@ -1387,7 +1388,7 @@ public: // of this bucket type... uint32_t peering_crush_bucket_barrier = 0; // including this one - int32_t peering_crush_mandatory_member = 0; + int32_t peering_crush_mandatory_member = pg_CRUSH_ITEM_NONE; // The per-bucket replica count is calculated with this "target" // instead of the above crush_bucket_count. This means we can maintain a // target size of 4 without attempting to place them all in 1 DC @@ -3492,13 +3493,13 @@ PastIntervals::PriorSet::PriorSet( // so that we know what they do/do not have explicitly before // sending them any new info/logs/whatever. for (unsigned i = 0; i < acting.size(); i++) { - if (acting[i] != 0x7fffffff /* CRUSH_ITEM_NONE, can't import crush.h here */) + if (acting[i] != pg_pool_t::pg_CRUSH_ITEM_NONE) probe.insert(pg_shard_t(acting[i], ec_pool ? shard_id_t(i) : shard_id_t::NO_SHARD)); } // It may be possible to exclude the up nodes, but let's keep them in // there for now. for (unsigned i = 0; i < up.size(); i++) { - if (up[i] != 0x7fffffff /* CRUSH_ITEM_NONE, can't import crush.h here */) + if (up[i] != pg_pool_t::pg_CRUSH_ITEM_NONE) probe.insert(pg_shard_t(up[i], ec_pool ? shard_id_t(i) : shard_id_t::NO_SHARD)); } diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 85e08eab547e..8dcbf8177002 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1781,7 +1781,7 @@ public: uint32_t peering_crush_bucket_count = 0; uint32_t peering_crush_bucket_target = 0; uint32_t peering_crush_bucket_barrier = 0; - int32_t peering_crush_mandatory_member = 0; + int32_t peering_crush_mandatory_member = CRUSH_ITEM_NONE; bool used_replica = false; bool paused = false;