From: Zhiqiang Wang Date: Thu, 18 Dec 2014 05:31:04 +0000 (+0800) Subject: osd/ReplicatedPG: promote on 2nd write X-Git-Tag: v9.1.0~345^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3d5300bde18aa9ccd3bbc1aa3abba982f48298fe;p=ceph.git osd/ReplicatedPG: promote on 2nd write If min_write_recency_for_promote is - 0: Promote when there is a write. - 1: Check if the object is in current hit set. Promote if yes. - else: Check if the object is in current and other in memory hit sets. Promote if yes. Signed-off-by: Zhiqiang Wang Conflicts: src/osd/ReplicatedPG.cc --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 5f8433725157..0bb1c806d5fb 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1853,61 +1853,91 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, return true; } else if (op->may_write() || op->may_cache()) { do_proxy_write(op, missing_oid); + + // Promote too? + switch (pool.info.min_write_recency_for_promote) { + case 0: + promote_object(obc, missing_oid, oloc, OpRequestRef()); + break; + case 1: + // Check if in the current hit set + if (in_hit_set) { + promote_object(obc, missing_oid, oloc, OpRequestRef()); + } + break; + default: + if (in_hit_set) { + promote_object(obc, missing_oid, oloc, OpRequestRef()); + } else { + // 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; + break; + } + } + if (in_other_hit_sets) { + promote_object(obc, missing_oid, oloc, OpRequestRef()); + } + } + break; + } } else { if (can_proxy_read) do_proxy_read(op); else promote_op = op; // for non-proxy case promote_object needs this - } - // Avoid duplicate promotion - if (obc.get() && obc->is_blocked()) { - if (!can_proxy_read) { - wait_for_blocked_object(obc->obs.oi.soid, op); + // Avoid duplicate promotion + if (obc.get() && obc->is_blocked()) { + if (!can_proxy_read) { + wait_for_blocked_object(obc->obs.oi.soid, op); + } + return true; } - return true; - } - // Promote too? - switch (pool.info.min_read_recency_for_promote) { - case 0: - promote_object(obc, missing_oid, oloc, promote_op); - break; - case 1: - // Check if in the current hit set - if (in_hit_set) { - promote_object(obc, missing_oid, oloc, promote_op); - } else if (!can_proxy_read) { - do_cache_redirect(op); - } - break; - default: - if (in_hit_set) { - promote_object(obc, missing_oid, oloc, promote_op); - } else { - // 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 (obc.get()) { - if (obc->obs.oi.soid != hobject_t() && itor->second->contains(obc->obs.oi.soid)) { - in_other_hit_sets = true; - break; - } - } else { - if (missing_oid != hobject_t() && itor->second->contains(missing_oid)) { - in_other_hit_sets = true; - break; + // Promote too? + switch (pool.info.min_read_recency_for_promote) { + case 0: + promote_object(obc, missing_oid, oloc, promote_op); + break; + case 1: + // Check if in the current hit set + if (in_hit_set) { + promote_object(obc, missing_oid, oloc, promote_op); + } else if (!can_proxy_read) { + do_cache_redirect(op); + } + break; + default: + if (in_hit_set) { + promote_object(obc, missing_oid, oloc, promote_op); + } else { + // 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 (obc.get()) { + if (obc->obs.oi.soid != hobject_t() && itor->second->contains(obc->obs.oi.soid)) { + in_other_hit_sets = true; + break; + } + } else { + if (missing_oid != hobject_t() && itor->second->contains(missing_oid)) { + in_other_hit_sets = true; + break; + } } } - } - if (in_other_hit_sets) { - promote_object(obc, missing_oid, oloc, promote_op); - } else if (!can_proxy_read) { - do_cache_redirect(op); - } + if (in_other_hit_sets) { + promote_object(obc, missing_oid, oloc, promote_op); + } else if (!can_proxy_read) { + do_cache_redirect(op); + } + } } - break; } return true; @@ -10704,7 +10734,9 @@ void ReplicatedPG::hit_set_trim(RepGather *repop, unsigned max) void ReplicatedPG::hit_set_in_memory_trim() { unsigned max = pool.info.hit_set_count; - unsigned max_in_memory = pool.info.min_read_recency_for_promote > 0 ? pool.info.min_read_recency_for_promote - 1 : 0; + unsigned max_in_memory_read = pool.info.min_read_recency_for_promote > 0 ? pool.info.min_read_recency_for_promote - 1 : 0; + unsigned max_in_memory_write = pool.info.min_write_recency_for_promote > 0 ? pool.info.min_write_recency_for_promote - 1 : 0; + unsigned max_in_memory = max_in_memory_read >= max_in_memory_write ? max_in_memory_read : max_in_memory_write; if (max_in_memory > max) { max_in_memory = max;