]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc: add epoch_t last_force_resend in Op/LingerOp. 4597/head
authorxinxin shu <xinxin.shu@intel.com>
Wed, 6 May 2015 21:49:18 +0000 (05:49 +0800)
committerxinxin shu <xinxin.shu@intel.com>
Mon, 8 Jun 2015 02:48:30 +0000 (10:48 +0800)
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 def4fc4a)

src/osdc/Objecter.cc
src/osdc/Objecter.h

index 649c61ce5c5f404401f0e988ded2bf64e5db4814..8ef2b6c95a7038cea3b18397f46bca945b13d408 100644 (file)
@@ -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
index 2ede888a948cd47443872d6d7a8517793ed8e89d..858f077bb85d80d6f08889ff4668e5460b859761 100644 (file)
@@ -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<OSDOp>& 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);