]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Objecter: handle primary other than acting[0]
authorSamuel Just <sam.just@inktank.com>
Wed, 12 Feb 2014 18:48:56 +0000 (10:48 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 18 Feb 2014 04:12:13 +0000 (20:12 -0800)
EC pool particularly might have CRUSH_ITEM_NONE as acting[0] which
is not a valid osd.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osdc/Objecter.cc

index c23f9eedceacb04ed577a45ffde6c0d7a8feb529..6241b170ea19c400d528fdb8978335fa5716d933 100644 (file)
@@ -1454,8 +1454,9 @@ int Objecter::recalc_op_target(Op *op)
     if (ret == -ENOENT)
       return RECALC_OP_TARGET_POOL_DNE;
   }
+  int primary;
   vector<int> 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<int> 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<int> 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;