From: Sage Weil Date: Mon, 7 Aug 2017 22:42:57 +0000 (-0400) Subject: osd/PrimaryLogPG: send requests to primary on cache miss X-Git-Tag: v12.2.3~56^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21880df6bf27465637c97e504b5a6dcf2ea31d9f;p=ceph.git osd/PrimaryLogPG: send requests to primary on cache miss 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 (cherry picked from commit 741a8720996b74434a036b143209111ce5203cbc) --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 3dd4eff0989..8d15fd45909 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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; diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index df2a45f5877..c333b27c5b9 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -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,