From: Samuel Just Date: Sun, 16 Feb 2014 01:33:07 +0000 (-0800) Subject: Objecter: track primary explicitly to detect changing primaries X-Git-Tag: v0.78~163^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=11f288e5d582c1c687e372b5448328cb02ff6275;p=ceph.git Objecter: track primary explicitly to detect changing primaries Signed-off-by: Samuel Just --- diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 6241b170ea1..28243ea4f42 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -1374,15 +1374,20 @@ int Objecter::op_cancel(tid_t tid, int r) return 0; } -bool Objecter::is_pg_changed(vector& o, vector& n, bool any_change) -{ - if (o.empty() && n.empty()) +bool Objecter::is_pg_changed( + int oldprimary, + vector& oldacting, + int newprimary, + vector& 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; diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 732ba8a8299..cc75434ffad 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1025,6 +1025,7 @@ public: pg_t pgid; ///< last pg we mapped to vector 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 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& a, vector& b, bool any_change=false); + bool is_pg_changed( + int oldprimary, + vector& oldacting, + int newprimary, + vector& newacting, + bool any_change=false); enum recalc_op_target_result { RECALC_OP_TARGET_NO_ACTION = 0, RECALC_OP_TARGET_NEED_RESEND,