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;
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());
}
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);
{}, /* 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);
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.