]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: send requests to primary on cache miss
authorSage Weil <sage@redhat.com>
Mon, 7 Aug 2017 22:42:57 +0000 (18:42 -0400)
committerShinobu Kinjo <shinobu@redhat.com>
Wed, 13 Dec 2017 22:47:37 +0000 (17:47 -0500)
If a client has {BALANCE,LOCALIZE}_READS and sends a request to a
replica, but the object isn't in the cache, send them back to the
primary.  Otherwise we might do something rash (like trigger a
promotion from a replica).

Fixes: http://tracker.ceph.com/issues/20919
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 741a8720996b74434a036b143209111ce5203cbc)

src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index 3dd4eff09893b04f12545410058f70eac0261b7d..8d15fd45909d922d1d62de6095916ee4a7f4f64f 100644 (file)
@@ -2490,6 +2490,11 @@ PrimaryLogPG::cache_result_t PrimaryLogPG::maybe_handle_cache_detail(
     osd->logger->inc(l_osd_op_cache_hit);
     return cache_result_t::NOOP;
   }
+  if (!is_primary()) {
+    dout(20) << __func__ << " cache miss; ask the primary" << dendl;
+    osd->reply_op_error(op, -EAGAIN);
+    return cache_result_t::REPLIED_WITH_EAGAIN;
+  }
 
   if (missing_oid == hobject_t() && obc.get()) {
     missing_oid = obc->obs.oi.soid;
@@ -7002,6 +7007,8 @@ int PrimaryLogPG::_rollback_to(OpContext *ctx, ceph_osd_op& op)
     case cache_result_t::BLOCKED_FULL:
       block_write_on_full_cache(soid, ctx->op);
       return -EAGAIN;
+    case cache_result_t::REPLIED_WITH_EAGAIN:
+      assert(0 == "this can't happen, no rollback on replica");
     default:
       assert(0 == "must promote was set, other values are not valid");
       return -EAGAIN;
index df2a45f5877bbff4625124f7e0a5bbbba3f09e89..c333b27c5b9d03f31e8397560b462d99069773d3 100644 (file)
@@ -1115,6 +1115,7 @@ protected:
     BLOCKED_PROMOTE,
     HANDLED_PROXY,
     HANDLED_REDIRECT,
+    REPLIED_WITH_EAGAIN,
   };
   cache_result_t maybe_handle_cache_detail(OpRequestRef op,
                                           bool write_ordered,