]> 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)
committerKefu Chai <kchai@redhat.com>
Fri, 9 Oct 2015 10:22:45 +0000 (03:22 -0700)
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>
(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
src/osd/ReplicatedPG.h

index ca3d55e63032841230e703d8d143332bf68fffda..4df248476b542f003ed598cb77c67f0f80e62452 100644 (file)
@@ -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<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, 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<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, 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);
index d09dba32a672a141f0345f4fc7f44c2556b16a52..6dbcd191394a3b499d32cc06556f7d388a563f90 100644 (file)
@@ -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,