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

objecter: resend linger ops on split #5062

Merged
merged 2 commits into from Jul 21, 2015
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
73 changes: 64 additions & 9 deletions src/osd/osd_types.cc
Expand Up @@ -2196,6 +2196,57 @@ void pg_interval_t::generate_test_instances(list<pg_interval_t*>& o)
o.back()->maybe_went_rw = true;
}

bool pg_interval_t::is_new_interval(
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,
int old_min_size,
int new_min_size,
unsigned old_pg_num,
unsigned new_pg_num,
pg_t pgid) {
return old_acting_primary != new_acting_primary ||
new_acting != old_acting ||
old_up_primary != new_up_primary ||
new_up != old_up ||
old_min_size != new_min_size ||
pgid.is_split(old_pg_num, new_pg_num, 0);
}

bool pg_interval_t::is_new_interval(
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,
OSDMapRef osdmap,
OSDMapRef lastmap,
int64_t pool_id,
pg_t pgid) {
return !(lastmap->get_pools().count(pgid.pool())) ||
is_new_interval(old_acting_primary,
new_acting_primary,
old_acting,
new_acting,
old_up_primary,
new_up_primary,
old_up,
new_up,
lastmap->get_pools().find(pgid.pool())->second.min_size,
osdmap->get_pools().find(pgid.pool())->second.min_size,
lastmap->get_pg_num(pgid.pool()),
osdmap->get_pg_num(pgid.pool()),
pgid);
}

bool pg_interval_t::check_new_interval(
int old_acting_primary,
int new_acting_primary,
Expand All @@ -2218,15 +2269,19 @@ bool pg_interval_t::check_new_interval(
// 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) ||
pgid.is_split(lastmap->get_pg_num(pgid.pool()),
osdmap->get_pg_num(pgid.pool()), 0)) {
if (is_new_interval(
old_acting_primary,
new_acting_primary,
old_acting,
new_acting,
old_up_primary,
new_up_primary,
old_up,
new_up,
osdmap,
lastmap,
pool_id,
pgid)) {
pg_interval_t& i = (*past_intervals)[same_interval_since];
i.first = same_interval_since;
i.last = osdmap->get_epoch() - 1;
Expand Down
39 changes: 38 additions & 1 deletion src/osd/osd_types.h
Expand Up @@ -1752,13 +1752,50 @@ struct pg_interval_t {
void dump(Formatter *f) const;
static void generate_test_instances(list<pg_interval_t*>& o);

/**
* Determines whether there is an interval change
*/
static bool is_new_interval(
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,
int old_min_size,
int new_min_size,
unsigned old_pg_num,
unsigned new_pg_num,
pg_t pgid
);

/**
* Determines whether there is an interval change
*/
static bool is_new_interval(
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
ceph::shared_ptr<const OSDMap> osdmap, ///< [in] current map
ceph::shared_ptr<const OSDMap> lastmap, ///< [in] last map
int64_t poolid, ///< [in] pool for pg
pg_t pgid ///< [in] pgid for pg
);

/**
* Integrates a new map into *past_intervals, returns true
* if an interval was closed out.
*/
static bool check_new_interval(
int old_acting_primary, ///< [in] primary as of lastmap
int new_acting_primary, ///< [in] primary as of lastmap
int new_acting_primary, ///< [in] primary as of osdmap
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
Expand Down
43 changes: 34 additions & 9 deletions src/osdc/Objecter.cc
Expand Up @@ -1483,9 +1483,29 @@ int Objecter::calc_target(op_target_t *t, bool any_change)
if (ret == -ENOENT)
return RECALC_OP_TARGET_POOL_DNE;
}
int primary;
vector<int> acting;
osdmap->pg_to_acting_osds(pgid, &acting, &primary);

int min_size = pi->min_size;
unsigned pg_num = pi->get_pg_num();
int up_primary, acting_primary;
vector<int> up, acting;
osdmap->pg_to_up_acting_osds(pgid, &up, &up_primary,
&acting, &acting_primary);
if (any_change && pg_interval_t::is_new_interval(
t->acting_primary,
acting_primary,
t->acting,
acting,
t->up_primary,
up_primary,
t->up,
up,
t->min_size,
min_size,
t->pg_num,
pg_num,
pi->raw_pg_to_pg(pgid))) {
force_resend = true;
}

bool need_resend = false;

Expand All @@ -1497,15 +1517,20 @@ int Objecter::calc_target(op_target_t *t, bool any_change)

if (t->pgid != pgid ||
is_pg_changed(
t->primary, t->acting, primary, acting, t->used_replica || any_change) ||
t->acting_primary, t->acting, acting_primary, acting,
t->used_replica || any_change) ||
force_resend) {
t->pgid = pgid;
t->acting = acting;
t->primary = primary;
ldout(cct, 10) << __func__ << " pgid " << pgid
<< " acting " << acting << dendl;
t->acting_primary = acting_primary;
t->up_primary = up_primary;
t->up = up;
t->min_size = min_size;
t->pg_num = pg_num;
ldout(cct, 10) << __func__ << " "
<< " pgid " << pgid << " acting " << acting << dendl;
t->used_replica = false;
if (primary == -1) {
if (acting_primary == -1) {
t->osd = -1;
} else {
int osd;
Expand Down Expand Up @@ -1541,7 +1566,7 @@ int Objecter::calc_target(op_target_t *t, bool any_change)
assert(best >= 0);
osd = acting[best];
} else {
osd = primary;
osd = acting_primary;
}
t->osd = osd;
}
Expand Down
13 changes: 10 additions & 3 deletions src/osdc/Objecter.h
Expand Up @@ -1072,8 +1072,12 @@ class Objecter : public md_config_obs_t {
pg_t base_pgid; ///< explciti pg target, if any

pg_t pgid; ///< last pg we mapped to
vector<int> acting; ///< acting for last pg we mapped to
int primary; ///< primary for last pg we mapped to
unsigned pg_num; ///< last pg_num we mapped to
vector<int> up; ///< set of up osds for last pg we mapped to
vector<int> acting; ///< set of acting osds for last pg we mapped to
int up_primary; ///< primary for last pg we mapped to based on the up set
int acting_primary; ///< primary for last pg we mapped to based on the acting set
int min_size; ///< the min size of the pool when were were last mapped

bool used_replica;
bool paused;
Expand All @@ -1085,7 +1089,10 @@ class Objecter : public md_config_obs_t {
base_oid(oid),
base_oloc(oloc),
precalc_pgid(false),
primary(-1),
pg_num(0),
up_primary(-1),
acting_primary(-1),
min_size(-1),
used_replica(false),
paused(false),
osd(-1)
Expand Down