]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Objecter: track primary explicitly to detect changing primaries
authorSamuel Just <sam.just@inktank.com>
Sun, 16 Feb 2014 01:33:07 +0000 (17:33 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 18 Feb 2014 04:12:17 +0000 (20:12 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 6241b170ea19c400d528fdb8978335fa5716d933..28243ea4f423edf9be8b82c914eac21e400ac754 100644 (file)
@@ -1374,15 +1374,20 @@ int Objecter::op_cancel(tid_t tid, int r)
   return 0;
 }
 
-bool Objecter::is_pg_changed(vector<int>& o, vector<int>& n, bool any_change)
-{
-  if (o.empty() && n.empty())
+bool Objecter::is_pg_changed(
+  int oldprimary,
+  vector<int>& oldacting,
+  int newprimary,
+  vector<int>& newacting,
+  bool any_change)
+{
+  if (oldacting.empty() && newacting.empty())
     return false;    // both still empty
-  if (o.empty() ^ n.empty())
+  if (oldacting.empty() ^ newacting.empty())
     return true;     // was empty, now not, or vice versa
-  if (o[0] != n[0])
+  if (oldprimary != newprimary)
     return true;     // primary changed
-  if (any_change && o != n)
+  if (any_change && oldacting != newacting)
     return true;
   return false;      // same primary (tho replicas may have changed)
 }
@@ -1466,9 +1471,12 @@ int Objecter::recalc_op_target(Op *op)
     need_resend = true;
   }
 
-  if (op->pgid != pgid || is_pg_changed(op->acting, acting, op->used_replica)) {
+  if (op->pgid != pgid ||
+      is_pg_changed(
+       op->primary, op->acting, primary, acting, op->used_replica)) {
     op->pgid = pgid;
     op->acting = acting;
+    op->primary = primary;
     ldout(cct, 10) << "recalc_op_target tid " << op->tid
             << " pgid " << pgid << " acting " << acting << dendl;
 
@@ -1542,9 +1550,12 @@ bool Objecter::recalc_linger_op_target(LingerOp *linger_op)
   }
   osdmap->pg_to_acting_osds(pgid, &acting, &primary);
 
-  if (pgid != linger_op->pgid || is_pg_changed(linger_op->acting, acting, true)) {
+  if (pgid != linger_op->pgid ||
+      is_pg_changed(
+        linger_op->primary, linger_op->acting, primary, acting, true)) {
     linger_op->pgid = pgid;
     linger_op->acting = acting;
+    linger_op->primary = primary;
     ldout(cct, 10) << "recalc_linger_op_target tid " << linger_op->linger_id
             << " pgid " << pgid << " acting " << acting << dendl;
     
index 732ba8a829976ab12e5118bf3791b6caf846f187..cc75434ffad6f1a4cac5a523a482020756785376 100644 (file)
@@ -1025,6 +1025,7 @@ public:
 
     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
     bool used_replica;
 
     ConnectionRef con;  // for rx buffer only
@@ -1066,6 +1067,7 @@ public:
       session(NULL), session_item(this), incarnation(0),
       base_oid(o), base_oloc(ol),
       precalc_pgid(false),
+      primary(-1),
       used_replica(false), con(NULL),
       snapid(CEPH_NOSNAP),
       outbl(NULL),
@@ -1286,6 +1288,7 @@ public:
 
     pg_t pgid;
     vector<int> acting;
+    int primary;
 
     snapid_t snap;
     SnapContext snapc;
@@ -1306,7 +1309,8 @@ public:
     tid_t register_tid;
     epoch_t map_dne_bound;
 
-    LingerOp() : linger_id(0), snap(CEPH_NOSNAP), flags(0),
+    LingerOp() : linger_id(0), primary(-1),
+                snap(CEPH_NOSNAP), flags(0),
                 poutbl(NULL), pobjver(NULL),
                 registered(false),
                 on_reg_ack(NULL), on_reg_commit(NULL),
@@ -1395,7 +1399,12 @@ public:
   void send_op(Op *op);
   void cancel_linger_op(Op *op);
   void finish_op(Op *op);
-  bool is_pg_changed(vector<int>& a, vector<int>& b, bool any_change=false);
+  bool is_pg_changed(
+    int oldprimary,
+    vector<int>& oldacting,
+    int newprimary,
+    vector<int>& newacting,
+    bool any_change=false);
   enum recalc_op_target_result {
     RECALC_OP_TARGET_NO_ACTION = 0,
     RECALC_OP_TARGET_NEED_RESEND,