vector<int> old_acting, old_up;
epoch_t same_interval_since;
int primary;
+ int up_primary;
};
void OSD::build_past_intervals_parallel()
continue;
vector<int> acting, up;
+ int up_primary;
int primary;
cur_map->pg_to_up_acting_osds(
- pg->info.pgid.pgid, &up, 0, &acting, &primary);
+ pg->info.pgid.pgid, &up, &up_primary, &acting, &primary);
if (p.same_interval_since == 0) {
dout(10) << __func__ << " epoch " << cur_epoch << " pg " << pg->info.pgid
p.old_up = up;
p.old_acting = acting;
p.primary = primary;
+ p.up_primary = up_primary;
continue;
}
assert(last_map);
p.primary,
primary,
p.old_acting, acting,
+ p.up_primary,
+ up_primary,
p.old_up, up,
p.same_interval_since,
pg->info.history.last_epoch_clean,
OSDMapRef last_map, cur_map;
int primary = -1;
+ int up_primary = -1;
vector<int> acting, up, old_acting, old_up;
cur_map = osd->get_map(cur_epoch);
cur_map->pg_to_up_acting_osds(
- get_pgid().pgid, &up, 0, &acting, &primary);
+ get_pgid().pgid, &up, &up_primary, &acting, &primary);
epoch_t same_interval_since = cur_epoch;
dout(10) << __func__ << " over epochs " << cur_epoch << "-"
<< end_epoch << dendl;
++cur_epoch;
for (; cur_epoch <= end_epoch; ++cur_epoch) {
int old_primary = primary;
+ int old_up_primary = up_primary;
last_map.swap(cur_map);
old_up.swap(up);
old_acting.swap(acting);
pg_t pgid = get_pgid().pgid;
if (cur_map->get_pools().count(pgid.pool()))
pgid = pgid.get_ancestor(cur_map->get_pg_num(pgid.pool()));
- cur_map->pg_to_up_acting_osds(pgid, &up, 0, &acting, &primary);
+ cur_map->pg_to_up_acting_osds(pgid, &up, &up_primary, &acting, &primary);
std::stringstream debug;
bool new_interval = pg_interval_t::check_new_interval(
primary,
old_acting,
acting,
+ old_up_primary,
+ up_primary,
old_up,
up,
same_interval_since,
old_acting_primary.osd,
new_acting_primary,
oldacting, newacting,
+ old_up_primary.osd,
+ new_up_primary,
oldup, newup,
info.history.same_interval_since,
info.history.last_epoch_clean,
}
bool pg_interval_t::check_new_interval(
- int old_primary,
- int new_primary,
+ int old_acting_primary,
+ int new_acting_primary,
const vector<int> &old_acting,
const vector<int> &new_acting,
+ int old_up_primary,
+ int new_up_primary,
const vector<int> &old_up,
const vector<int> &new_up,
epoch_t same_interval_since,
std::ostream *out)
{
// remember past interval
- if (old_primary != new_primary ||
- new_acting != old_acting || new_up != old_up ||
+ // NOTE: a change in the up set primary triggers an interval
+ // change, even though the interval members in the pg_interval_t
+ // do not change.
+ if (old_acting_primary != new_acting_primary ||
+ new_acting != old_acting ||
+ old_up_primary != new_up_primary ||
+ new_up != old_up ||
(!(lastmap->get_pools().count(pool_id))) ||
(lastmap->get_pools().find(pool_id)->second.min_size !=
osdmap->get_pools().find(pool_id)->second.min_size) ||
i.last = osdmap->get_epoch() - 1;
i.acting = old_acting;
i.up = old_up;
- i.primary = old_primary;
+ i.primary = old_acting_primary;
if (!i.acting.empty() && i.primary != -1 &&
i.acting.size() >=
* if an interval was closed out.
*/
static bool check_new_interval(
- int old_primary, ///< [in] primary as of lastmap
- int new_primary, ///< [in] primary as of lastmap
+ int old_acting_primary, ///< [in] primary as of lastmap
+ int new_acting_primary, ///< [in] primary as of lastmap
const vector<int> &old_acting, ///< [in] acting as of lastmap
const vector<int> &new_acting, ///< [in] acting as of osdmap
+ int old_up_primary, ///< [in] up primary of lastmap
+ int new_up_primary, ///< [in] up primary of osdmap
const vector<int> &old_up, ///< [in] up as of lastmap
const vector<int> &new_up, ///< [in] up as of osdmap
epoch_t same_interval_since, ///< [in] as of osdmap
int new_primary = osd_id;
vector<int> new_up;
new_up.push_back(osd_id);
+ int old_up_primary = osd_id;
+ int new_up_primary = osd_id;
vector<int> old_up = new_up;
pg_t pgid;
pgid.set_pool(pool_id);
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
+ old_up,
+ new_up,
+ same_interval_since,
+ last_epoch_clean,
+ osdmap,
+ lastmap,
+ pool_id,
+ pgid,
+ &past_intervals));
+ ASSERT_EQ((unsigned int)1, past_intervals.size());
+ ASSERT_EQ(same_interval_since, past_intervals[same_interval_since].first);
+ ASSERT_EQ(osdmap->get_epoch() - 1, past_intervals[same_interval_since].last);
+ ASSERT_EQ(osd_id, past_intervals[same_interval_since].acting[0]);
+ ASSERT_EQ(osd_id, past_intervals[same_interval_since].up[0]);
+ }
+
+ //
+ // The up primary has changed
+ //
+ {
+ vector<int> new_up;
+ int _new_up_primary = osd_id + 1;
+
+ map<epoch_t, pg_interval_t> past_intervals;
+
+ ASSERT_TRUE(past_intervals.empty());
+ ASSERT_TRUE(pg_interval_t::check_new_interval(old_primary,
+ new_primary,
+ old_acting,
+ new_acting,
+ old_up_primary,
+ _new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,
new_primary,
old_acting,
new_acting,
+ old_up_primary,
+ new_up_primary,
old_up,
new_up,
same_interval_since,