From: Sage Weil Date: Wed, 25 Nov 2015 19:39:08 +0000 (-0500) Subject: osd/ReplicatedPG: fix promotion recency logic X-Git-Tag: v0.94.6~14^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5cefcb975771f0c2efb7dfc77ce14a93a4ee7f1b;p=ceph.git osd/ReplicatedPG: fix promotion recency logic Recency is defined as how many of the last N hitsets an object must appear in in order to be promoted. The previous logic did nothing of the sort... it checked for the object in any one of the last N hitsets, which led to way to many promotions and killed any chance of the cache performing properly. While we are here, we can simplify the code to drop the max_in_* fields (no longer necessary). Note that we may still want a notion of 'temperature' that does tolerate the object missing in one of the recent hitsets.. but that would be different than recency, and should probably be modeled after the eviction temperature model. Backport: infernalis, hammer Reported-by: Nick Fisk Signed-off-by: Sage Weil (cherry picked from commit 180c8743addc5ae2f1db9c58cd2996ca6e7ac18b) Conflicts: src/osd/ReplicatedPG.cc code section was moved to ReplicatedPG::maybe_promote in master. Signed-off-by: Robert LeBlanc --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index b255b9fa6aaa..bfaa16bb9b40 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1856,23 +1856,27 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, } break; default: - if (in_hit_set) { - promote_object(obc, missing_oid, oloc, promote_op); - } else { + unsigned count = (int)in_hit_set; + if (count) { // Check if in other hit sets - map::iterator itor; - bool in_other_hit_sets = false; - for (itor = agent_state->hit_set_map.begin(); itor != agent_state->hit_set_map.end(); ++itor) { - if (itor->second->contains(missing_oid)) { - in_other_hit_sets = true; + const hobject_t& oid = obc.get() ? obc->obs.oi.soid : missing_oid; + for (map::iterator itor = agent_state->hit_set_map.begin(); + itor != agent_state->hit_set_map.end(); + ++itor) { + if (!itor->second->contains(oid)) { + break; + } + ++count; + if (count >= pool.info.min_read_recency_for_promote) { break; } } - if (in_other_hit_sets) { - promote_object(obc, missing_oid, oloc, promote_op); - } else if (!can_proxy_read) { - do_cache_redirect(op); - } + } + if (count >= pool.info.min_read_recency_for_promote) { + promote_object(obc, missing_oid, oloc, promote_op); + } else { + // not promoting + return false; } break; }