Skip to content

Commit

Permalink
osdc: add epoch_t last_force_resend in Op/LingerOp.
Browse files Browse the repository at this point in the history
Using this field record the pg_poo_t::last_force_op_resend to avoid op
endless when osd reply with redirect.

Fixes: #11026
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit def4fc4)
  • Loading branch information
xinxin shu committed Jun 8, 2015
1 parent aef0272 commit b1ff739
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/osdc/Objecter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1439,17 +1439,23 @@ int64_t Objecter::get_object_pg_hash_position(int64_t pool, const string& key,
return p->raw_hash_to_pg(p->hash_key(key, ns));
}

int Objecter::calc_target(op_target_t *t, bool any_change)
int Objecter::calc_target(op_target_t *t, epoch_t *last_force_resend, bool any_change)
{
bool is_read = t->flags & CEPH_OSD_FLAG_READ;
bool is_write = t->flags & CEPH_OSD_FLAG_WRITE;

const pg_pool_t *pi = osdmap->get_pg_pool(t->base_oloc.pool);
bool force_resend = false;
bool need_check_tiering = false;

if (pi && osdmap->get_epoch() == pi->last_force_op_resend) {
force_resend = true;
if (last_force_resend && *last_force_resend < pi->last_force_op_resend) {
*last_force_resend = pi->last_force_op_resend;
force_resend = true;
} else if (last_force_resend == 0)
force_resend = true;
}

if (t->target_oid.name.empty() || force_resend) {
t->target_oid = t->base_oid;
need_check_tiering = true;
Expand Down Expand Up @@ -1555,7 +1561,7 @@ int Objecter::calc_target(op_target_t *t, bool any_change)

int Objecter::recalc_op_target(Op *op)
{
int r = calc_target(&op->target);
int r = calc_target(&op->target, &op->last_force_resend);
if (r == RECALC_OP_TARGET_NEED_RESEND) {
OSDSession *s = NULL;
if (op->target.osd >= 0)
Expand All @@ -1576,7 +1582,7 @@ int Objecter::recalc_op_target(Op *op)

bool Objecter::recalc_linger_op_target(LingerOp *linger_op)
{
int r = calc_target(&linger_op->target, true);
int r = calc_target(&linger_op->target, &linger_op->last_force_resend, true);
if (r == RECALC_OP_TARGET_NEED_RESEND) {
ldout(cct, 10) << "recalc_linger_op_target tid " << linger_op->linger_id
<< " pgid " << linger_op->target.pgid
Expand Down
11 changes: 8 additions & 3 deletions src/osdc/Objecter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,8 @@ class Objecter : public md_config_obs_t {
/// true if we should resend this message on failure
bool should_resend;

epoch_t last_force_resend;

Op(const object_t& o, const object_locator_t& ol, vector<OSDOp>& op,
int f, Context *ac, Context *co, version_t *ov) :
session(NULL), session_item(this), incarnation(0),
Expand All @@ -1146,7 +1148,8 @@ class Objecter : public md_config_obs_t {
objver(ov), reply_epoch(NULL),
map_dne_bound(0),
budgeted(false),
should_resend(true) {
should_resend(true),
last_force_resend(0) {
ops.swap(op);

/* initialize out_* to match op vector */
Expand Down Expand Up @@ -1372,6 +1375,7 @@ class Objecter : public md_config_obs_t {

ceph_tid_t register_tid;
epoch_t map_dne_bound;
epoch_t last_force_resend;

LingerOp() : linger_id(0),
target(object_t(), object_locator_t(), 0),
Expand All @@ -1381,7 +1385,8 @@ class Objecter : public md_config_obs_t {
on_reg_ack(NULL), on_reg_commit(NULL),
session(NULL), session_item(this),
register_tid(0),
map_dne_bound(0) {}
map_dne_bound(0),
last_force_resend(0) {}

// no copy!
const LingerOp &operator=(const LingerOp& r);
Expand Down Expand Up @@ -1480,7 +1485,7 @@ class Objecter : public md_config_obs_t {
bool osdmap_full_flag() const;
bool target_should_be_paused(op_target_t *op);

int calc_target(op_target_t *t, bool any_change=false);
int calc_target(op_target_t *t, epoch_t *last_force_resend=0, bool any_change=false);
int recalc_op_target(Op *op);
bool recalc_linger_op_target(LingerOp *op);

Expand Down

0 comments on commit b1ff739

Please sign in to comment.