]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: is_replica() -> is_nonprimary()
authorSage Weil <sage@redhat.com>
Mon, 23 Sep 2019 19:46:07 +0000 (14:46 -0500)
committerSage Weil <sage@redhat.com>
Sat, 28 Sep 2019 16:51:18 +0000 (11:51 -0500)
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 <sage@redhat.com>
src/osd/OSD.cc
src/osd/PG.h
src/osd/PeeringState.cc
src/osd/PeeringState.h
src/osd/PrimaryLogPG.cc

index 4d1d519ea11d369e969a7511db265acd4c78fcb8..aaba18a655981f19100e2c3d42fa760f43cf8310 100644 (file)
@@ -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++;
   }
index 1bae4787247c373f5685b5d5dc4139a212dd4f5a..93b9d5d590fd46a59cdbe6c77b74fe352496d37f 100644 (file)
@@ -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();
index 105341698a9d25165d5f6b0900d1a67536f63b2b..e1566deea5cc1c05af34b0d24f14aaa2ae11643f 100644 (file)
@@ -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;
index a32be2a3bf5a948b34f03a8558e3a8e07dc120a3..cb8d08b2362cf796add8fc38d7da23401ca2d7cf 100644 (file)
@@ -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;
   }
index 2947c51f37c6d492fa721507135fee072891444f..6672fca39214c19978b0b3dea601d2db3b33d50c 100644 (file)
@@ -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;
     }