]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: implement hit_set_remove_all
authorZhiqiang Wang <zhiqiang.wang@intel.com>
Thu, 18 Jun 2015 01:05:28 +0000 (09:05 +0800)
committerZhiqiang Wang <zhiqiang.wang@intel.com>
Fri, 21 Aug 2015 07:45:04 +0000 (15:45 +0800)
When hit set is not configured on startup or on a change, remove all
previous hitsets.

Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 5a0eda2cc384ccd10e9db2d8bc56587f8dd60d16..548ac8121eedbabb599fed63d99683a12b519f78 100644 (file)
@@ -10568,7 +10568,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;
   }
 
@@ -10580,6 +10580,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<pg_hit_set_info_t>::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);
+
+    // 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<pg_hit_set_info_t>::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);
+    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);
index 1fe4055285b7621f3502823b411c81f3b9710263..1e84d18525bca1ca07241f4f0115a041192fece1 100644 (file)
@@ -956,6 +956,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, utime_t end);