]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Objecter: fix local reads one more time.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 23 Dec 2011 17:56:42 +0000 (09:56 -0800)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 23 Dec 2011 17:56:42 +0000 (09:56 -0800)
Document it a little since we've gotten it wrong so often.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/osdc/Objecter.cc

index 04816aba00012a17f89583c7838580c8649c0169..36b6bd3bdd27036b5630e1e0bd6db27a0f0b3616 100644 (file)
@@ -965,10 +965,13 @@ int Objecter::recalc_op_target(Op *op)
       } else if (read && (op->flags & CEPH_OSD_FLAG_LOCALIZE_READS)) {
        // look for a local replica
        int i;
-       for (i = acting.size()-1; i >= 0; --i) {
+       /* loop through the OSD replicas and see if any are local to read from.
+        * We don't need to check the primary since we default to it. (Be
+         * careful to preserve that default, which is why we iterate in reverse
+         * order.) */
+       for (i = acting.size()-1; i > 0; --i) {
          if (osdmap->get_addr(acting[i]).is_same_host(messenger->get_myaddr())) {
-           op->used_replica = i; /* only set used_replica if
-                                    local copy is not primary */
+           op->used_replica = true;
            ldout(cct, 10) << " chose local osd." << acting[i] << " of " << acting << dendl;
            break;
          }