Skip to content

Commit f0028be

Browse files
committed
osd: s/assert/ceph_assert/g'
Now that we fallback to RelDebWithInfo [1], C asserts are not compiled in. Replace some of the existing asserts with ceph_assserts instead. [1] ceph#61637 Fixes: https://tracker.ceph.com/issues/71360 Signed-off-by: Matan Breizman <[email protected]>
1 parent 463a0ba commit f0028be

File tree

16 files changed

+68
-68
lines changed

16 files changed

+68
-68
lines changed

src/osd/ECBackend.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ struct ECClassicalOp : ECCommon::RMWPipeline::Op {
14321432
shard_id_map<ObjectStore::Transaction> *transactions,
14331433
DoutPrefixProvider *dpp,
14341434
const OSDMapRef &osdmap) final {
1435-
assert(t);
1435+
ceph_assert(t);
14361436
ECTransaction::generate_transactions(
14371437
t.get(),
14381438
plan,

src/osd/ECBackendL.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ struct ECClassicalOp : ECCommonL::RMWPipeline::Op {
14441444
DoutPrefixProvider *dpp,
14451445
const ceph_release_t require_osd_release) final
14461446
{
1447-
assert(t);
1447+
ceph_assert(t);
14481448
ECTransactionL::generate_transactions(
14491449
t.get(),
14501450
plan,

src/osd/ECUtilL.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class stripe_info_t {
172172
}
173173
std::pair<uint64_t, uint64_t> offset_length_to_data_chunk_indices(
174174
uint64_t off, uint64_t len) const {
175-
assert(chunk_size > 0);
175+
ceph_assert(chunk_size > 0);
176176
const auto first_chunk_idx = (off / chunk_size);
177177
const auto last_chunk_idx = (chunk_size - 1 + off + len) / chunk_size;
178178
return {first_chunk_idx, last_chunk_idx};
@@ -182,7 +182,7 @@ class stripe_info_t {
182182
if (len == 0) {
183183
return true;
184184
}
185-
assert(chunk_size > 0);
185+
ceph_assert(chunk_size > 0);
186186
const auto first_stripe_idx = off / stripe_width;
187187
const auto last_inc_stripe_idx = (off + len - 1) / stripe_width;
188188
return first_stripe_idx == last_inc_stripe_idx;

src/osd/OSD.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ void OSDService::set_ready_to_merge_source(PG *pg, eversion_t version)
19511951
std::lock_guard l(merge_lock);
19521952
dout(10) << __func__ << " " << pg->pg_id << dendl;
19531953
ready_to_merge_source[pg->pg_id.pgid] = version;
1954-
assert(not_ready_to_merge_source.count(pg->pg_id.pgid) == 0);
1954+
ceph_assert(not_ready_to_merge_source.count(pg->pg_id.pgid) == 0);
19551955
_send_ready_to_merge();
19561956
}
19571957

@@ -1966,7 +1966,7 @@ void OSDService::set_ready_to_merge_target(PG *pg,
19661966
make_tuple(version,
19671967
last_epoch_started,
19681968
last_epoch_clean)));
1969-
assert(not_ready_to_merge_target.count(pg->pg_id.pgid) == 0);
1969+
ceph_assert(not_ready_to_merge_target.count(pg->pg_id.pgid) == 0);
19701970
_send_ready_to_merge();
19711971
}
19721972

@@ -1975,7 +1975,7 @@ void OSDService::set_not_ready_to_merge_source(pg_t source)
19751975
std::lock_guard l(merge_lock);
19761976
dout(10) << __func__ << " " << source << dendl;
19771977
not_ready_to_merge_source.insert(source);
1978-
assert(ready_to_merge_source.count(source) == 0);
1978+
ceph_assert(ready_to_merge_source.count(source) == 0);
19791979
_send_ready_to_merge();
19801980
}
19811981

@@ -1984,7 +1984,7 @@ void OSDService::set_not_ready_to_merge_target(pg_t target, pg_t source)
19841984
std::lock_guard l(merge_lock);
19851985
dout(10) << __func__ << " " << target << " source " << source << dendl;
19861986
not_ready_to_merge_target[target] = source;
1987-
assert(ready_to_merge_target.count(target) == 0);
1987+
ceph_assert(ready_to_merge_target.count(target) == 0);
19881988
_send_ready_to_merge();
19891989
}
19901990

@@ -4055,13 +4055,13 @@ int OSD::init()
40554055
for (auto shard : shards) {
40564056
shard->prime_splits(osdmap, &new_children);
40574057
}
4058-
assert(new_children.empty());
4058+
ceph_assert(new_children.empty());
40594059
}
40604060
if (!merge_pgs.empty()) {
40614061
for (auto shard : shards) {
40624062
shard->prime_merges(osdmap, &merge_pgs);
40634063
}
4064-
assert(merge_pgs.empty());
4064+
ceph_assert(merge_pgs.empty());
40654065
}
40664066
}
40674067
}
@@ -5449,7 +5449,7 @@ void OSD::load_pgs()
54495449
}
54505450
{
54515451
uint32_t shard_index = pgid.hash_to_shard(shards.size());
5452-
assert(NULL != shards[shard_index]);
5452+
ceph_assert(NULL != shards[shard_index]);
54535453
store->set_collection_commit_queue(pg->coll, &(shards[shard_index]->context_queue));
54545454
}
54555455

@@ -5518,7 +5518,7 @@ PGRef OSD::handle_pg_create_info(const OSDMapRef& osdmap,
55185518

55195519
{
55205520
uint32_t shard_index = pgid.hash_to_shard(shards.size());
5521-
assert(NULL != shards[shard_index]);
5521+
ceph_assert(NULL != shards[shard_index]);
55225522
store->set_collection_commit_queue(pg->coll, &(shards[shard_index]->context_queue));
55235523
}
55245524

@@ -5673,7 +5673,7 @@ void OSD::_add_heartbeat_peer(int p)
56735673
pair<ConnectionRef,ConnectionRef> cons = service.get_con_osd_hb(p, get_osdmap_epoch());
56745674
if (!cons.first)
56755675
return;
5676-
assert(cons.second);
5676+
ceph_assert(cons.second);
56775677

56785678
hi = &heartbeat_peers[p];
56795679
hi->peer = p;
@@ -7943,7 +7943,7 @@ MPGStats* OSD::collect_pg_stats()
79437943
per_pool_stats = false;
79447944
break;
79457945
} else {
7946-
assert(r >= 0);
7946+
ceph_assert(r >= 0);
79477947
m->pool_stat[p] = st;
79487948
}
79497949
}
@@ -9365,7 +9365,7 @@ void OSD::split_pgs(
93659365

93669366
{
93679367
uint32_t shard_index = i->hash_to_shard(shards.size());
9368-
assert(NULL != shards[shard_index]);
9368+
ceph_assert(NULL != shards[shard_index]);
93699369
store->set_collection_commit_queue(child->coll, &(shards[shard_index]->context_queue));
93709370
}
93719371

src/osd/OSDMap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@ const std::vector<int> OSDMap::pgtemp_undo_primaryfirst(const pg_pool_t& pool,
29052905
std::vector<int> result;
29062906
int primaryshard = 0;
29072907
int nonprimaryshard = pool.size - pool.nonprimary_shards.size();
2908-
assert(acting.size() == pool.size);
2908+
ceph_assert(acting.size() == pool.size);
29092909
for (auto shard = 0; shard < pool.size; shard++) {
29102910
if (pool.is_nonprimary_shard(shard_id_t(shard))) {
29112911
result.emplace_back(acting[nonprimaryshard++]);
@@ -7888,7 +7888,7 @@ void OSDMap::get_random_up_osds_by_subtree(int n, // whoami
78887888
float OSDMap::pool_raw_used_rate(int64_t poolid) const
78897889
{
78907890
const pg_pool_t *pool = get_pg_pool(poolid);
7891-
assert(pool != nullptr);
7891+
ceph_assert(pool != nullptr);
78927892

78937893
switch (pool->get_type()) {
78947894
case pg_pool_t::TYPE_REPLICATED:

src/osd/OSDMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ class OSDMap {
893893
}
894894

895895
bool exists(int osd) const {
896-
//assert(osd >= 0);
896+
//ceph_assert(osd >= 0);
897897
return osd >= 0 && osd < max_osd && (osd_state[osd] & CEPH_OSD_EXISTS);
898898
}
899899

src/osd/PGLog.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ namespace {
11781178
}).then([this] {
11791179
if (info.pgid.is_no_shard()) {
11801180
// replicated pool pg does not persist this key
1181-
assert(on_disk_rollback_info_trimmed_to == eversion_t());
1181+
ceph_assert(on_disk_rollback_info_trimmed_to == eversion_t());
11821182
on_disk_rollback_info_trimmed_to = info.last_update;
11831183
}
11841184
log = PGLog::IndexedLog(

src/osd/PGLog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ struct PGLog : DoutPrefixProvider {
15871587
});
15881588
if (info.pgid.is_no_shard()) {
15891589
// replicated pool pg does not persist this key
1590-
assert(on_disk_rollback_info_trimmed_to == eversion_t());
1590+
ceph_assert(on_disk_rollback_info_trimmed_to == eversion_t());
15911591
on_disk_rollback_info_trimmed_to = info.last_update;
15921592
}
15931593
log = IndexedLog(

src/osd/PeeringState.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ void PeeringState::send_lease()
12471247

12481248
void PeeringState::proc_lease(const pg_lease_t& l)
12491249
{
1250-
assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
1250+
ceph_assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
12511251
if (!is_nonprimary()) {
12521252
psdout(20) << "no-op, !nonprimary" << dendl;
12531253
return;
@@ -1289,7 +1289,7 @@ void PeeringState::proc_lease(const pg_lease_t& l)
12891289

12901290
void PeeringState::proc_lease_ack(int from, const pg_lease_ack_t& a)
12911291
{
1292-
assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
1292+
ceph_assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
12931293
auto now = pl->get_mnow();
12941294
bool was_min = false;
12951295
for (unsigned i = 0; i < acting.size(); ++i) {
@@ -1315,7 +1315,7 @@ void PeeringState::proc_lease_ack(int from, const pg_lease_ack_t& a)
13151315

13161316
void PeeringState::proc_renew_lease()
13171317
{
1318-
assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
1318+
ceph_assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
13191319
renew_lease(pl->get_mnow());
13201320
if (actingset.size() > 1) {
13211321
send_lease();
@@ -1327,7 +1327,7 @@ void PeeringState::proc_renew_lease()
13271327

13281328
void PeeringState::recalc_readable_until()
13291329
{
1330-
assert(is_primary());
1330+
ceph_assert(is_primary());
13311331
ceph::signedspan min = readable_until_ub_sent;
13321332
for (unsigned i = 0; i < acting.size(); ++i) {
13331333
if (acting[i] == pg_whoami.osd || acting[i] == CRUSH_ITEM_NONE) {
@@ -1347,7 +1347,7 @@ void PeeringState::recalc_readable_until()
13471347

13481348
bool PeeringState::check_prior_readable_down_osds(const OSDMapRef& map)
13491349
{
1350-
assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
1350+
ceph_assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
13511351
bool changed = false;
13521352
auto p = prior_readable_down_osds.begin();
13531353
while (p != prior_readable_down_osds.end()) {
@@ -1762,7 +1762,7 @@ PeeringState::select_replicated_primary(
17621762
!primary->second.is_incomplete() &&
17631763
primary->second.last_update >=
17641764
auth_log_shard->second.log_tail) {
1765-
assert(HAVE_FEATURE(osdmap->get_up_osd_features(), SERVER_NAUTILUS));
1765+
ceph_assert(HAVE_FEATURE(osdmap->get_up_osd_features(), SERVER_NAUTILUS));
17661766
auto approx_missing_objects =
17671767
primary->second.stats.stats.sum.num_objects_missing;
17681768
auto auth_version = auth_log_shard->second.last_update.version;
@@ -1961,7 +1961,7 @@ class bucket_candidates_t {
19611961
public:
19621962
void add_osd(osd_ord_t ord, osd_id_t osd) {
19631963
// osds will be added in smallest to largest order
1964-
assert(osds.empty() || osds.back().first <= ord);
1964+
ceph_assert(osds.empty() || osds.back().first <= ord);
19651965
osds.push_back(std::make_pair(ord, osd));
19661966
}
19671967
osd_id_t pop_osd() {
@@ -2295,7 +2295,7 @@ void PeeringState::choose_async_recovery_ec(
22952295
// past the authoritative last_update the same as those equal to it.
22962296
version_t auth_version = auth_info.last_update.version;
22972297
version_t candidate_version = shard_info.last_update.version;
2298-
assert(HAVE_FEATURE(osdmap->get_up_osd_features(), SERVER_NAUTILUS));
2298+
ceph_assert(HAVE_FEATURE(osdmap->get_up_osd_features(), SERVER_NAUTILUS));
22992299
auto approx_missing_objects =
23002300
shard_info.stats.stats.sum.num_objects_missing;
23012301
if (auth_version > candidate_version) {
@@ -2353,7 +2353,7 @@ void PeeringState::choose_async_recovery_replicated(
23532353
// logs plus historical missing objects as the cost of recovery
23542354
version_t auth_version = auth_info.last_update.version;
23552355
version_t candidate_version = shard_info.last_update.version;
2356-
assert(HAVE_FEATURE(osdmap->get_up_osd_features(), SERVER_NAUTILUS));
2356+
ceph_assert(HAVE_FEATURE(osdmap->get_up_osd_features(), SERVER_NAUTILUS));
23572357
auto approx_missing_objects =
23582358
shard_info.stats.stats.sum.num_objects_missing;
23592359
if (auth_version > candidate_version) {
@@ -2886,7 +2886,7 @@ void PeeringState::activate(
28862886
purged.intersection_of(to_trim, info.purged_snaps);
28872887
to_trim.subtract(purged);
28882888

2889-
assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
2889+
ceph_assert(HAVE_FEATURE(upacting_features, SERVER_OCTOPUS));
28902890
renew_lease(pl->get_mnow());
28912891
// do not schedule until we are actually activated
28922892

@@ -4584,7 +4584,7 @@ void PeeringState::recover_got(
45844584
psdout(10) << "last_complete now " << info.last_complete
45854585
<< " log.complete_to at end" << dendl;
45864586
//below is not true in the repair case.
4587-
//assert(missing.num_missing() == 0); // otherwise, complete_to was wrong.
4587+
//ceph_assert(missing.num_missing() == 0); // otherwise, complete_to was wrong.
45884588
ceph_assert(info.last_complete == info.last_update);
45894589
}
45904590

@@ -4774,8 +4774,8 @@ void PeeringState::calc_trim_to()
47744774
}
47754775
psdout(10) << "calc_trim_to " << pg_trim_to << " -> " << new_trim_to << dendl;
47764776
pg_trim_to = new_trim_to;
4777-
assert(pg_trim_to <= pg_log.get_head());
4778-
assert(pg_trim_to <= min_last_complete_ondisk);
4777+
ceph_assert(pg_trim_to <= pg_log.get_head());
4778+
ceph_assert(pg_trim_to <= min_last_complete_ondisk);
47794779
}
47804780
}
47814781

@@ -6584,7 +6584,7 @@ boost::statechart::result PeeringState::Active::react(const AllReplicasActivated
65846584
if (merge_target) {
65856585
pg_t src = pgid;
65866586
src.set_ps(ps->pool.info.get_pg_num_pending());
6587-
assert(src.get_parent() == pgid);
6587+
ceph_assert(src.get_parent() == pgid);
65886588
pl->set_not_ready_to_merge_target(pgid, src);
65896589
} else {
65906590
pl->set_not_ready_to_merge_source(pgid);
@@ -6679,7 +6679,7 @@ void PeeringState::Active::all_activated_and_committed()
66796679
ceph_assert(!ps->acting_recovery_backfill.empty());
66806680
ceph_assert(ps->blocked_by.empty());
66816681

6682-
assert(HAVE_FEATURE(ps->upacting_features, SERVER_OCTOPUS));
6682+
ceph_assert(HAVE_FEATURE(ps->upacting_features, SERVER_OCTOPUS));
66836683
// this is overkill when the activation is quick, but when it is slow it
66846684
// is important, because the lease was renewed by the activate itself but we
66856685
// don't know how long ago that was, and simply scheduling now may leave
@@ -8069,7 +8069,7 @@ std::vector<pg_shard_t> PeeringState::get_replica_recovery_order() const
80698069
continue;
80708070
}
80718071
auto pm = get_peer_missing().find(p);
8072-
assert(pm != get_peer_missing().end());
8072+
ceph_assert(pm != get_peer_missing().end());
80738073
auto nm = pm->second.num_missing();
80748074
if (nm != 0) {
80758075
if (is_async_recovery_target(p)) {

src/osd/PeeringState.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ class PeeringState : public MissingLoc::MappingInfo {
633633
}
634634

635635
PeeringCtxWrapper &get_recovery_ctx() {
636-
assert(state->rctx);
636+
ceph_assert(state->rctx);
637637
return *(state->rctx);
638638
}
639639

@@ -2395,13 +2395,13 @@ class PeeringState : public MissingLoc::MappingInfo {
23952395
return pg_log.get_missing();
23962396
} else {
23972397
auto it = peer_missing.find(peer);
2398-
assert(it != peer_missing.end());
2398+
ceph_assert(it != peer_missing.end());
23992399
return it->second;
24002400
}
24012401
}
24022402
const pg_info_t&get_peer_info(pg_shard_t peer) const {
24032403
auto it = peer_info.find(peer);
2404-
assert(it != peer_info.end());
2404+
ceph_assert(it != peer_info.end());
24052405
return it->second;
24062406
}
24072407
bool has_peer_info(pg_shard_t peer) const {

0 commit comments

Comments
 (0)