From 313a09b58b6aa6fe8999f4d5da07a04f00c64cd7 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 18 Jun 2015 09:05:28 +0800 Subject: [PATCH] osd: implement hit_set_remove_all When hit set is not configured on startup or on a change, remove all previous hitsets. Signed-off-by: Zhiqiang Wang (cherry picked from commit be28319bf3dc54b4b6f400d83405a29facfe3bd4) Conflicts: src/osd/ReplicatedPG.cc pass the new argument of `p->using_gmt` to get_hit_set_archive_object() --- src/osd/ReplicatedPG.cc | 42 ++++++++++++++++++++++++++++++++++++++++- src/osd/ReplicatedPG.h | 1 + 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index ca3d55e630328..4df248476b542 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -10146,7 +10146,7 @@ void ReplicatedPG::hit_set_setup() !pool.info.hit_set_period || pool.info.hit_set_params.get_type() == HitSet::TYPE_NONE) { hit_set_clear(); - //hit_set_remove_all(); // FIXME: implement me soon + hit_set_remove_all(); return; } @@ -10158,6 +10158,46 @@ void ReplicatedPG::hit_set_setup() hit_set_apply_log(); } +void ReplicatedPG::hit_set_remove_all() +{ + // If any archives are degraded we skip this + for (list::iterator p = info.hit_set.history.begin(); + p != info.hit_set.history.end(); + ++p) { + hobject_t aoid = get_hit_set_archive_object(p->begin, p->end, p->using_gmt); + + // Once we hit a degraded object just skip + if (is_degraded_or_backfilling_object(aoid)) + return; + if (scrubber.write_blocked_by_scrub(aoid)) + return; + } + + if (!info.hit_set.history.empty()) { + list::reverse_iterator p = info.hit_set.history.rbegin(); + assert(p != info.hit_set.history.rend()); + hobject_t oid = get_hit_set_archive_object(p->begin, p->end, p->using_gmt); + assert(!is_degraded_or_backfilling_object(oid)); + ObjectContextRef obc = get_object_context(oid, false); + assert(obc); + + RepGather *repop = simple_repop_create(obc); + OpContext *ctx = repop->ctx; + ctx->at_version = get_next_version(); + ctx->updated_hset_history = info.hit_set; + utime_t now = ceph_clock_now(cct); + ctx->mtime = now; + hit_set_trim(repop, 0); + info.stats.stats.add(ctx->delta_stats); + simple_repop_submit(repop); + } + + info.hit_set = pg_hit_set_history_t(); + if (agent_state) { + agent_state->discard_hit_sets(); + } +} + void ReplicatedPG::hit_set_create() { utime_t now = ceph_clock_now(NULL); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index d09dba32a672a..6dbcd191394a3 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -901,6 +901,7 @@ protected: 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_remove_all(); hobject_t get_hit_set_current_object(utime_t stamp); hobject_t get_hit_set_archive_object(utime_t start, -- 2.39.5