From b1ff7396c8e9668c0be1a4023e0ffa292067cf64 Mon Sep 17 00:00:00 2001 From: xinxin shu Date: Thu, 7 May 2015 05:49:18 +0800 Subject: [PATCH] osdc: add epoch_t last_force_resend in Op/LingerOp. 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 Signed-off-by: Sage Weil (cherry picked from commit def4fc4a) --- src/osdc/Objecter.cc | 14 ++++++++++---- src/osdc/Objecter.h | 11 ++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 649c61ce5c5..8ef2b6c95a7 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -1439,7 +1439,7 @@ 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; @@ -1447,9 +1447,15 @@ int Objecter::calc_target(op_target_t *t, bool any_change) 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; @@ -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) @@ -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 diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 2ede888a948..858f077bb85 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1133,6 +1133,8 @@ public: /// 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& op, int f, Context *ac, Context *co, version_t *ov) : session(NULL), session_item(this), incarnation(0), @@ -1146,7 +1148,8 @@ public: 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 */ @@ -1372,6 +1375,7 @@ public: 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), @@ -1381,7 +1385,8 @@ public: 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); @@ -1480,7 +1485,7 @@ public: 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); -- 2.47.3