From: Sage Weil Date: Mon, 23 Sep 2019 19:46:07 +0000 (-0500) Subject: osd: is_replica() -> is_nonprimary() X-Git-Tag: v15.1.0~1379^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a04f5c2826814942423d9a7360959850800d7aba;p=ceph-ci.git osd: is_replica() -> is_nonprimary() The 'replica' term does not map well onto EC pools. More importantly, the implementation is often wrong for EC pools, where role may be 0 or 1 for EC pools independent of whether the OSD is the primary or not. Introduce 'nonprimary' to mean an acting osd that is not the primary. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 4d1d519ea11..aaba18a6559 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4107,8 +4107,8 @@ bool OSD::try_finish_pg_delete(PG *pg, unsigned old_pg_num) // update pg count now since we might not get an osdmap any time soon. if (pg->is_primary()) service.logger->dec(l_osd_pg_primary); - else if (pg->is_replica()) - service.logger->dec(l_osd_pg_replica); + else if (pg->is_nonprimary()) + service.logger->dec(l_osd_pg_replica); // misnomver else service.logger->dec(l_osd_pg_stray); @@ -8709,8 +8709,8 @@ bool OSD::advance_pg( // any time soon. if (pg->is_primary()) logger->dec(l_osd_pg_primary); - else if (pg->is_replica()) - logger->dec(l_osd_pg_replica); + else if (pg->is_nonprimary()) + logger->dec(l_osd_pg_replica); // misnomer else logger->dec(l_osd_pg_stray); } @@ -8917,8 +8917,8 @@ void OSD::consume_map() // racy, but we don't want to take pg lock here. if (pg->is_primary()) num_pg_primary++; - else if (pg->is_replica()) - num_pg_replica++; + else if (pg->is_nonprimary()) + num_pg_replica++; // misnomer else num_pg_stray++; } diff --git a/src/osd/PG.h b/src/osd/PG.h index 1bae4787247..93b9d5d590f 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -274,8 +274,8 @@ public: bool is_deleted() const { return recovery_state.is_deleted(); } - bool is_replica() const { - return recovery_state.is_replica(); + bool is_nonprimary() const { + return recovery_state.is_nonprimary(); } bool is_primary() const { return recovery_state.is_primary(); diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 105341698a9..e1566deea5c 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -557,7 +557,7 @@ void PeeringState::start_peering_interval( pg_shard_t old_acting_primary = get_primary(); pg_shard_t old_up_primary = up_primary; bool was_old_primary = is_primary(); - bool was_old_replica = is_replica(); + bool was_old_nonprimary = is_nonprimary(); acting.swap(oldacting); up.swap(oldup); @@ -678,7 +678,7 @@ void PeeringState::start_peering_interval( // reset primary/replica state? if (was_old_primary || is_primary()) { pl->clear_want_pg_temp(); - } else if (was_old_replica || is_replica()) { + } else if (was_old_nonprimary || is_nonprimary()) { pl->clear_want_pg_temp(); } clear_primary_state(); @@ -844,7 +844,7 @@ void PeeringState::init_hb_stamps() hb_stamps[i++] = pl->get_hb_stamps(p); } hb_stamps.resize(i); - } else if (is_replica()) { + } else if (is_nonprimary()) { // we care about just the primary hb_stamps.resize(1); hb_stamps[0] = pl->get_hb_stamps(get_primary().osd); @@ -1134,7 +1134,7 @@ void PeeringState::send_lease() void PeeringState::proc_lease(const pg_lease_t& l) { - if (get_role() < 0) { + if (!is_nonprimary()) { return; } psdout(10) << __func__ << " " << l << dendl; diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index a32be2a3bf5..cb8d08b2362 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -2064,9 +2064,11 @@ public: const PastIntervals& get_past_intervals() const { return past_intervals; } - bool is_replica() const { - return role > 0; + /// acting osd that is not the primary + bool is_nonprimary() const { + return role >= 0 && pg_whoami != primary; } + /// primary osd bool is_primary() const { return pg_whoami == primary; } diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 2947c51f37c..6672fca3921 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1794,7 +1794,7 @@ void PrimaryLogPG::do_op(OpRequestRef& op) op->may_read() && !(op->may_write() || op->may_cache())) { // balanced reads; any replica will do - if (!(is_primary() || is_replica())) { + if (!(is_primary() || is_nonprimary())) { osd->handle_misdirected_op(this, op); return; }