]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make misdirected checks explicit about replicas, flags
authorSage Weil <sage@inktank.com>
Tue, 8 Apr 2014 15:52:43 +0000 (08:52 -0700)
committerSage Weil <sage@inktank.com>
Tue, 8 Apr 2014 16:06:32 +0000 (09:06 -0700)
Only allow read ops to target replicas if the necessary op flags are set.
The previous checks were very sloppy.

Fixes: #8031
Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/PG.cc

index 49503efc0a3c34d4493de7c43f1034cec0a16eaf..4102b5156c84d03de368de2d95370f41bfaa0260 100644 (file)
@@ -4910,16 +4910,26 @@ bool PG::can_discard_op(OpRequestRef op)
   if (OSD::op_is_discardable(m)) {
     dout(20) << " discard " << *m << dendl;
     return true;
-  } else if ((op->may_write() || op->may_cache()) &&
-            (!is_primary() ||
-             !same_for_modify_since(m->get_map_epoch()))) {
-    osd->handle_misdirected_op(this, op);
-    return true;
-  } else if (op->may_read() &&
-            !same_for_read_since(m->get_map_epoch())) {
-    osd->handle_misdirected_op(this, op);
-    return true;
-  } else if (is_replay()) {
+  }
+  if ((m->get_flags() & (CEPH_OSD_FLAG_BALANCE_READS |
+                        CEPH_OSD_FLAG_LOCALIZE_READS)) &&
+      op->may_read() &&
+      !(op->may_write() || op->may_cache())) {
+    // balanced reads; any replica will do
+    if (!((is_primary() || is_replica()) &&
+         same_for_read_since(m->get_map_epoch()))) {
+      osd->handle_misdirected_op(this, op);
+      return true;
+    }
+  } else {
+    // normal case; must be primary
+    if (!(is_primary() &&
+         same_for_modify_since(m->get_map_epoch()))) {
+      osd->handle_misdirected_op(this, op);
+      return true;
+    }
+  }
+  if (is_replay()) {
     if (m->get_version().version > 0) {
       dout(7) << " queueing replay at " << m->get_version()
              << " for " << *m << dendl;