Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd_types: pg_t: allow is_split to handle checks for splits prior to the most recent #1691

Merged
merged 6 commits into from Apr 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/osd/OSD.cc
Expand Up @@ -2156,6 +2156,7 @@ struct pistate {
vector<int> old_acting, old_up;
epoch_t same_interval_since;
int primary;
int up_primary;
};

void OSD::build_past_intervals_parallel()
Expand Down Expand Up @@ -2207,9 +2208,10 @@ 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
Expand All @@ -2219,6 +2221,7 @@ void OSD::build_past_intervals_parallel()
p.old_up = up;
p.old_acting = acting;
p.primary = primary;
p.up_primary = up_primary;
continue;
}
assert(last_map);
Expand All @@ -2228,6 +2231,8 @@ void OSD::build_past_intervals_parallel()
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,
Expand Down
18 changes: 13 additions & 5 deletions src/osd/PG.cc
Expand Up @@ -638,39 +638,45 @@ void PG::generate_past_intervals()

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);

cur_map = osd->get_map(cur_epoch);
cur_map->pg_to_up_acting_osds(
get_pgid().pgid, &up, 0, &acting, &primary);
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, &up_primary, &acting, &primary);

std::stringstream debug;
bool new_interval = pg_interval_t::check_new_interval(
old_primary,
primary,
old_acting,
acting,
old_up_primary,
up_primary,
old_up,
up,
same_interval_since,
info.history.last_epoch_clean,
cur_map,
last_map,
info.pgid.pool(),
info.pgid.pgid,
pgid.pool(),
pgid,
&past_intervals,
&debug);
if (new_interval) {
Expand Down Expand Up @@ -4684,6 +4690,8 @@ void PG::start_peering_interval(
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,
Expand Down
44 changes: 36 additions & 8 deletions src/osd/osd_types.cc
Expand Up @@ -393,6 +393,15 @@ ostream& operator<<(ostream& out, const spg_t &pg)
return out;
}

pg_t pg_t::get_ancestor(unsigned old_pg_num) const
{
int old_bits = pg_pool_t::calc_bits_of(old_pg_num);
int old_mask = (1 << old_bits) - 1;
pg_t ret = *this;
ret.m_seed = ceph_stable_mod(m_seed, old_pg_num, old_mask);
return ret;
}

bool pg_t::is_split(unsigned old_pg_num, unsigned new_pg_num, set<pg_t> *children) const
{
assert(m_seed < old_pg_num);
Expand Down Expand Up @@ -2093,19 +2102,20 @@ ostream &operator<<(ostream &lhs, const pg_notify_t &notify)

void pg_interval_t::encode(bufferlist& bl) const
{
ENCODE_START(3, 2, bl);
ENCODE_START(4, 2, bl);
::encode(first, bl);
::encode(last, bl);
::encode(up, bl);
::encode(acting, bl);
::encode(maybe_went_rw, bl);
::encode(primary, bl);
::encode(up_primary, bl);
ENCODE_FINISH(bl);
}

void pg_interval_t::decode(bufferlist::iterator& bl)
{
DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
DECODE_START_LEGACY_COMPAT_LEN(4, 2, 2, bl);
::decode(first, bl);
::decode(last, bl);
::decode(up, bl);
Expand All @@ -2117,6 +2127,12 @@ void pg_interval_t::decode(bufferlist::iterator& bl)
if (acting.size())
primary = acting[0];
}
if (struct_v >= 4) {
::decode(up_primary, bl);
} else {
if (up.size())
up_primary = up[0];
}
DECODE_FINISH(bl);
}

Expand All @@ -2132,6 +2148,8 @@ void pg_interval_t::dump(Formatter *f) const
f->open_array_section("acting");
for (vector<int>::const_iterator p = acting.begin(); p != acting.end(); ++p)
f->dump_int("osd", *p);
f->dump_int("primary", primary);
f->dump_int("up_primary", up_primary);
f->close_section();
}

Expand All @@ -2148,10 +2166,12 @@ void pg_interval_t::generate_test_instances(list<pg_interval_t*>& o)
}

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,
Expand All @@ -2164,8 +2184,13 @@ bool pg_interval_t::check_new_interval(
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) ||
Expand All @@ -2176,7 +2201,8 @@ bool pg_interval_t::check_new_interval(
i.last = osdmap->get_epoch() - 1;
i.acting = old_acting;
i.up = old_up;
i.primary = old_primary;
i.primary = old_acting_primary;
i.up_primary = old_up_primary;

if (!i.acting.empty() && i.primary != -1 &&
i.acting.size() >=
Expand Down Expand Up @@ -2234,7 +2260,9 @@ bool pg_interval_t::check_new_interval(

ostream& operator<<(ostream& out, const pg_interval_t& i)
{
out << "interval(" << i.first << "-" << i.last << " " << i.up << "/" << i.acting;
out << "interval(" << i.first << "-" << i.last
<< " up " << i.up << "(" << i.up_primary << ")"
<< " acting " << i.acting << "(" << i.primary << ")";
if (i.maybe_went_rw)
out << " maybe_went_rw";
out << ")";
Expand Down
15 changes: 12 additions & 3 deletions src/osd/osd_types.h
Expand Up @@ -311,6 +311,7 @@ struct pg_t {
}

pg_t get_parent() const;
pg_t get_ancestor(unsigned old_pg_num) const;

int print(char *o, int maxlen) const;
bool parse(const char *s);
Expand Down Expand Up @@ -1682,8 +1683,14 @@ struct pg_interval_t {
epoch_t first, last;
bool maybe_went_rw;
int primary;
int up_primary;

pg_interval_t() : first(0), last(0), maybe_went_rw(false), primary(-1) {}
pg_interval_t()
: first(0), last(0),
maybe_went_rw(false),
primary(-1),
up_primary(-1)
{}

void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& bl);
Expand All @@ -1695,10 +1702,12 @@ struct pg_interval_t {
* 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
Expand Down