From: Samuel Just Date: Wed, 12 Feb 2014 18:48:56 +0000 (-0800) Subject: Objecter: handle primary other than acting[0] X-Git-Tag: v0.78~163^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9d8be1b0828689744d5597b3971e1a3d83384154;p=ceph.git Objecter: handle primary other than acting[0] EC pool particularly might have CRUSH_ITEM_NONE as acting[0] which is not a valid osd. Signed-off-by: Samuel Just --- diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index c23f9eedceac..6241b170ea19 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -1454,8 +1454,9 @@ int Objecter::recalc_op_target(Op *op) if (ret == -ENOENT) return RECALC_OP_TARGET_POOL_DNE; } + int primary; vector acting; - osdmap->pg_to_acting_osds(pgid, acting); + osdmap->pg_to_acting_osds(pgid, &acting, &primary); bool need_resend = false; @@ -1473,7 +1474,7 @@ int Objecter::recalc_op_target(Op *op) OSDSession *s = NULL; op->used_replica = false; - if (!acting.empty()) { + if (primary != -1) { int osd; bool read = is_read && !is_write; if (read && (op->flags & CEPH_OSD_FLAG_BALANCE_READS)) { @@ -1507,7 +1508,7 @@ int Objecter::recalc_op_target(Op *op) assert(best >= 0); osd = acting[best]; } else { - osd = acting[0]; + osd = primary; } s = get_session(osd); } @@ -1532,13 +1533,14 @@ int Objecter::recalc_op_target(Op *op) bool Objecter::recalc_linger_op_target(LingerOp *linger_op) { + int primary; vector acting; pg_t pgid; int ret = osdmap->object_locator_to_pg(linger_op->oid, linger_op->oloc, pgid); if (ret == -ENOENT) { return RECALC_OP_TARGET_POOL_DNE; } - osdmap->pg_to_acting_osds(pgid, acting); + osdmap->pg_to_acting_osds(pgid, &acting, &primary); if (pgid != linger_op->pgid || is_pg_changed(linger_op->acting, acting, true)) { linger_op->pgid = pgid; @@ -1546,7 +1548,7 @@ bool Objecter::recalc_linger_op_target(LingerOp *linger_op) ldout(cct, 10) << "recalc_linger_op_target tid " << linger_op->linger_id << " pgid " << pgid << " acting " << acting << dendl; - OSDSession *s = acting.size() ? get_session(acting[0]) : NULL; + OSDSession *s = primary != -1 ? get_session(primary) : NULL; if (linger_op->session != s) { linger_op->session_item.remove_myself(); linger_op->session = s; @@ -2779,10 +2781,11 @@ int Objecter::recalc_command_target(CommandOp *c) c->map_check_error_str = "pool dne"; return RECALC_OP_TARGET_POOL_DNE; } + int primary; vector acting; - osdmap->pg_to_acting_osds(c->target_pg, acting); - if (!acting.empty()) - s = get_session(acting[0]); + osdmap->pg_to_acting_osds(c->target_pg, &acting, &primary); + if (primary != -1) + s = get_session(primary); } if (c->session != s) { ldout(cct, 10) << "recalc_command_target " << c->tid << " now " << c->session << dendl;