]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: trim old hit_set objects on persist
authorSage Weil <sage@inktank.com>
Wed, 4 Dec 2013 17:11:02 +0000 (09:11 -0800)
committerSage Weil <sage@inktank.com>
Fri, 6 Dec 2013 22:37:28 +0000 (14:37 -0800)
Any time we persist a hit_set object, take the opportunity to remove any
old ones that we don't want any more.

Note that this means if the admin decreases the number of objects to track,
we won't remove them until the next time we persist something.  We also
don't clean up if the HitSet tracking is disabled entirely.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 8b8c6ad6e319fa28836b53af4257e39d5c5eed90..bfedd5344e328cde8c1c0c533b04935fed3bbd8b 100644 (file)
@@ -8487,6 +8487,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
     return;
   }
 
@@ -8636,9 +8637,32 @@ void ReplicatedPG::hit_set_persist()
          repop->ctx->mtime)
         );
 
+  hit_set_trim(repop, pool.info.hit_set_count);
+
   simple_repop_submit(repop);
 }
 
+void ReplicatedPG::hit_set_trim(RepGather *repop, unsigned max)
+{
+  for (unsigned num = info.hit_set.history.size(); num > max; --num) {
+    list<pg_hit_set_info_t>::iterator p = info.hit_set.history.begin();
+    assert(p != info.hit_set.history.end());
+    hobject_t oid = get_hit_set_archive_object(p->begin, p->end);
+    dout(20) << __func__ << " removing " << oid << dendl;
+    repop->ctx->op_t.remove(coll, oid);
+    ++repop->ctx->at_version.version;
+    repop->ctx->log.push_back(
+        pg_log_entry_t(pg_log_entry_t::DELETE,
+                      oid,
+                      repop->ctx->at_version,
+                      p->version,
+                      0,
+                      osd_reqid_t(),
+                      repop->ctx->mtime));
+    info.hit_set.history.pop_front();
+  }
+}
+
 
 // ==========================================================================================
 // SCRUB
index 28de6ae5546f2c51441419b76f2385cbdb1bdfc9..a5eee9d2b8769178a05e4231f52391e8ad6d7a41 100644 (file)
@@ -586,6 +586,7 @@ protected:
   void hit_set_create();    ///< create a new HitSet
   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
 
   hobject_t get_hit_set_current_object(utime_t stamp);
   hobject_t get_hit_set_archive_object(utime_t start, utime_t end);