]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: PeeringState: implement an acting_set_writeable() function 40049/head
authorGreg Farnum <gfarnum@redhat.com>
Fri, 12 Mar 2021 22:41:03 +0000 (22:41 +0000)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 12 Mar 2021 22:41:03 +0000 (22:41 +0000)
Use it instead of direct checks against min_size and stretch_set_can_peer()
when deciding whether to go STATE_ACTIVE/STATE_PEERED or do updates
to things like last_epoch_started.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/osd/PeeringState.cc
src/osd/PeeringState.h

index e0f13adb56f90128291010d6d6ae2b9ec342b9da..c022ebb5e537446e29a75ff8784b653da83b58ce 100644 (file)
@@ -2654,8 +2654,7 @@ void PeeringState::activate(
 
   if (is_primary()) {
     // only update primary last_epoch_started if we will go active
-    if ((acting.size() >= pool.info.min_size) &&
-        pool.info.stretch_set_can_peer(acting, *get_osdmap(), NULL)) {
+    if (acting_set_writeable()) {
       ceph_assert(cct->_conf->osd_find_best_info_ignore_history_les ||
             info.last_epoch_started <= activation_epoch);
       info.last_epoch_started = activation_epoch;
@@ -2956,8 +2955,7 @@ void PeeringState::activate(
     state_set(PG_STATE_ACTIVATING);
     pl->on_activate(std::move(to_trim));
   }
-  if ((acting.size() >= pool.info.min_size) &&
-      pool.info.stretch_set_can_peer(acting, *get_osdmap(), NULL)) {
+  if (acting_set_writeable()) {
     PGLog::LogEntryHandlerRef rollbacker{pl->get_log_handler(t)};
     pg_log.roll_forward(rollbacker.get());
   }
@@ -6222,9 +6220,7 @@ boost::statechart::result PeeringState::Active::react(const AllReplicasActivated
        pl->set_not_ready_to_merge_source(pgid);
       }
     }
-  } else if ((ps->acting.size() < ps->pool.info.min_size) ||
-            !ps->pool.info.stretch_set_can_peer(ps->acting,
-                                                *ps->get_osdmap(), NULL)) {
+  } else if (!ps->acting_set_writeable()) {
     ps->state_set(PG_STATE_PEERED);
   } else {
     ps->state_set(PG_STATE_ACTIVE);
@@ -6382,9 +6378,7 @@ boost::statechart::result PeeringState::ReplicaActive::react(
     {}, /* lease */
     ps->get_lease_ack());
 
-  if ((ps->acting.size() >= ps->pool.info.min_size) &&
-      ps->pool.info.stretch_set_can_peer(ps->acting,
-                                        *ps->get_osdmap(), NULL)) {
+  if (ps->acting_set_writeable()) {
     ps->state_set(PG_STATE_ACTIVE);
   } else {
     ps->state_set(PG_STATE_PEERED);
index 2cae797d62d10f4434fd456583dce4b750089d03..01145a03287f90351244d5aff438d70c3f09f96c 100644 (file)
@@ -2312,6 +2312,16 @@ public:
       hoid, get_min_last_complete_ondisk());
   }
 
+  /**
+   * Returns whether the current acting set is able to go active
+   * and serve writes. It needs to satisfy min_size and any
+   * applicable stretch cluster constraints.
+   */
+  bool acting_set_writeable() {
+    return (acting.size() >= pool.info.min_size) &&
+      (pool.info.stretch_set_can_peer(acting, *get_osdmap(), NULL));
+  }
+
   /**
    * Returns whether all peers which might have unfound objects have been
    * queried or marked lost.