From 85e06f9d05f3bf009a0d08a9a298c721ee2fb4f7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 11 Feb 2014 14:01:10 -0800 Subject: [PATCH] osd/ReplicatedPG: redirect reads instead of promoting when full If the cache pool is full, we are processing a read op, and we would otherwise promote, redirect instead. This lets us continue to process the op without blocking or making the cache pool any more full than it is. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 21 ++++++++++++++++----- src/osd/ReplicatedPG.h | 6 ++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index bceaa172596a3..b9b5c5e8e2bf1 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1197,7 +1197,7 @@ void ReplicatedPG::do_op(OpRequestRef op) } if ((m->get_flags() & CEPH_OSD_FLAG_IGNORE_CACHE) == 0 && - maybe_handle_cache(op, obc, r, missing_oid)) + maybe_handle_cache(op, write_ordered, obc, r, missing_oid, false)) return; if (r) { @@ -1264,7 +1264,7 @@ void ReplicatedPG::do_op(OpRequestRef op) // missing the specific snap we need; requeue and wait. wait_for_missing_object(wait_oid, op); } else if (r) { - if (!maybe_handle_cache(op, sobc, r, wait_oid, true)) + if (!maybe_handle_cache(op, write_ordered, sobc, r, wait_oid, true)) osd->reply_op_error(op, r); } else if (sobc->obs.oi.is_whiteout()) { osd->reply_op_error(op, -ENOENT); @@ -1324,7 +1324,7 @@ void ReplicatedPG::do_op(OpRequestRef op) // missing the specific snap we need; requeue and wait. wait_for_missing_object(wait_oid, op); } else if (r) { - if (!maybe_handle_cache(op, sobc, r, wait_oid, true)) + if (!maybe_handle_cache(op, write_ordered, sobc, r, wait_oid, true)) osd->reply_op_error(op, r); } else { dout(10) << " clone_oid " << clone_oid << " obc " << sobc << dendl; @@ -1382,7 +1382,9 @@ void ReplicatedPG::do_op(OpRequestRef op) execute_ctx(ctx); } -bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, +bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, + bool write_ordered, + ObjectContextRef obc, int r, const hobject_t& missing_oid, bool must_promote) { @@ -1415,6 +1417,15 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, if (obc.get() && obc->obs.exists) { return false; } + if (agent_state && + agent_state->evict_mode == TierAgentState::EVICT_MODE_FULL) { + if (!op->may_write() && !op->may_cache() && !write_ordered) { + dout(20) << __func__ << " cache pool full, redirecting read" << dendl; + do_cache_redirect(op, obc); + return true; + } + // FIXME: do something clever with writes. + } if (!must_promote && can_skip_promote(op, obc)) { return false; } @@ -4431,7 +4442,7 @@ int ReplicatedPG::_rollback_to(OpContext *ctx, ceph_osd_op& op) wait_for_missing_object(missing_oid, ctx->op); return ret; } - if (maybe_handle_cache(ctx->op, rollback_to, ret, missing_oid, true)) { + if (maybe_handle_cache(ctx->op, true, rollback_to, ret, missing_oid, true)) { // promoting the rollback src, presumably return -EAGAIN; } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 60faac8d9ab3f..777f309258111 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -910,9 +910,11 @@ protected: * This helper function is called from do_op if the ObjectContext lookup fails. * @returns true if the caching code is handling the Op, false otherwise. */ - inline bool maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, int r, + inline bool maybe_handle_cache(OpRequestRef op, + bool write_ordered, + ObjectContextRef obc, int r, const hobject_t& missing_oid, - bool must_promote = false); + bool must_promote); /** * This helper function tells the client to redirect their request elsewhere. */ -- 2.39.5