From da6d5cfca5b99b1907600c0e7e0e532fe4ad7948 Mon Sep 17 00:00:00 2001 From: Xinze Chi Date: Thu, 11 Jun 2015 10:36:33 +0800 Subject: [PATCH] osd: bug fix hit_set_map size for tier pool Signed-off-by: Xinze Chi --- src/osd/ReplicatedPG.cc | 23 +++++++++++------------ src/osd/ReplicatedPG.h | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 08a29c735af7a..2d9b9b24e4dfd 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2053,7 +2053,10 @@ bool ReplicatedPG::maybe_promote(ObjectContextRef obc, // 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) { + 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(max_in_memory_read, max_in_memory_write); + for (itor = agent_state->hit_set_map.begin(); itor != agent_state->hit_set_map.end() && max_in_memory--; ++itor) { if (obc.get()) { if (obc->obs.oi.soid != hobject_t() && itor->second->contains(obc->obs.oi.soid)) { in_other_hit_sets = true; @@ -10759,7 +10762,11 @@ void ReplicatedPG::hit_set_persist() if (agent_state) { agent_state->add_hit_set(info.hit_set.current_info.begin, hit_set); - hit_set_in_memory_trim(); + uint32_t size = agent_state->hit_set_map.size(); + if (size >= pool.info.hit_set_count) { + size = pool.info.hit_set_count > 0 ? pool.info.hit_set_count - 1: 0; + } + hit_set_in_memory_trim(size); } // hold a ref until it is flushed to disk @@ -10915,16 +10922,8 @@ void ReplicatedPG::hit_set_trim(RepGather *repop, unsigned max) } } -void ReplicatedPG::hit_set_in_memory_trim() +void ReplicatedPG::hit_set_in_memory_trim(uint32_t max_in_memory) { - unsigned max = pool.info.hit_set_count; - 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(max_in_memory_read, max_in_memory_write); - - if (max_in_memory > max) { - max_in_memory = max; - } while (agent_state->hit_set_map.size() > max_in_memory) { agent_state->remove_oldest_hit_set(); } @@ -11130,7 +11129,7 @@ bool ReplicatedPG::agent_work(int start_max, int agent_flush_quota) agent_state->position = next; // Discard old in memory HitSets - hit_set_in_memory_trim(); + hit_set_in_memory_trim(pool.info.hit_set_count); if (need_delay) { assert(agent_state->delaying == false); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index ab24da4199f1c..b848de11c9ba5 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -955,7 +955,7 @@ protected: void hit_set_persist(); ///< persist hit info bool hit_set_apply_log(); ///< apply log entries to update in-memory HitSet void hit_set_trim(RepGather *repop, unsigned max); ///< discard old HitSets - void hit_set_in_memory_trim(); ///< discard old in memory HitSets + void hit_set_in_memory_trim(uint32_t max_in_memory); ///< discard old in memory HitSets void hit_set_remove_all(); hobject_t get_hit_set_current_object(utime_t stamp); -- 2.47.3