]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: rework build_intersection_set
authormyoungwon oh <ohmyoungwon@gmail.com>
Fri, 22 May 2020 15:46:16 +0000 (11:46 -0400)
committermyoungwon oh <ohmyoungwon@gmail.com>
Tue, 16 Jun 2020 06:01:16 +0000 (15:01 +0900)
Signed-off-by: Myoungwon Oh <ohmyoungwon@gmail.com>
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h
src/osd/osd_types.cc
src/osd/osd_types.h

index 9ff5dd059494361b6fa1df3ac150b17ea0eb2c13..4ff21d767d14b91db313f8320f5ba1a8241a3ad7 100644 (file)
@@ -3459,13 +3459,13 @@ void PrimaryLogPG::cancel_manifest_ops(bool requeue, vector<ceph_tid_t> *tids)
 }
 
 void PrimaryLogPG::dec_refcount_non_intersection(ObjectContextRef obc, const object_info_t& oi, 
-                                                 set<uint64_t> intersection_set)
+                                                 const set<uint64_t>& intersection_set)
 {
   for (auto c : oi.manifest.chunk_map) {
     auto iter = intersection_set.find(c.first);
     if (intersection_set.end() == iter) {
-      dout(10) << __func__ << " need dereference. " << " offset: " <<  c.first 
-             << " length: " << c.second.length << " oid: " << c.second.oid << dendl;
+      dout(10) << __func__ << ": decrement reference on offset " << c.first << " length: " 
+              << c.second.length << " oid: " << c.second.oid << dendl;
       object_locator_t target_oloc(c.second.oid);
       refcount_manifest(obc, obc->obs.oi.soid, target_oloc, c.second.oid, 
                        SnapContext(), refcount_t::DECREMENT_REF, NULL);
@@ -3480,9 +3480,8 @@ void PrimaryLogPG::dec_all_refcount_head_manifest(object_info_t& oi, OpContext*
   ceph_assert(oi.soid.is_head());
   // has snapshot
   if (ssc && ssc->snapset.clones.size() > 0) {
+    ceph_assert(ssc);
     dout(15) << __func__ <<  " has snapset " << dendl;
-    interval_set<uint64_t> &newest_overlap =
-      ssc->snapset.clone_overlap.rbegin()->second;
     set<uint64_t> refs;
     ceph_assert(oi.manifest.is_chunked());
     ceph_assert(!oi.manifest.is_redirect());
@@ -3495,7 +3494,7 @@ void PrimaryLogPG::dec_all_refcount_head_manifest(object_info_t& oi, OpContext*
       return;
     }
     object_info_t& coi = cobc->obs.oi;
-    oi.manifest.build_intersection_set(coi.manifest.chunk_map, refs, &newest_overlap);
+    oi.manifest.build_intersection_set(coi.manifest.chunk_map, refs);
 
     ctx->register_on_commit(
       [oi, ctx, this, refs](){
@@ -4523,6 +4522,7 @@ int PrimaryLogPG::trim_object(
       ctx->delta_stats.num_objects_pinned--;
     if (coi.has_manifest()) {
       set<uint64_t> refs;
+      object_info_t oi;
       for (auto p : snapset.clones) {
        hobject_t clone_oid = coid;
        if (clone_oid.snap == p) {
@@ -4537,11 +4537,16 @@ int PrimaryLogPG::trim_object(
        }
 
        // check if the references is still used
-       object_info_t& oi = cobc->obs.oi;
+       oi = cobc->obs.oi;
        if (oi.has_manifest()) {
-         coi.manifest.build_intersection_set(oi.manifest.chunk_map, refs, NULL);
+         coi.manifest.build_intersection_set(oi.manifest.chunk_map, refs);
        }
       }
+      // head
+      oi = head_obc->obs.oi;
+      if (oi.has_manifest()) {
+       coi.manifest.build_intersection_set(oi.manifest.chunk_map, refs);
+      }
 
       dec_refcount_non_intersection(head_obc, coi, refs);
       ctx->delta_stats.num_objects_manifest--;
@@ -7989,14 +7994,15 @@ inline int PrimaryLogPG::_delete_oid(
   }
   oi.watchers.clear();
 
+  if (oi.has_manifest()) {
+    ctx->delta_stats.num_objects_manifest--;
+    dec_all_refcount_head_manifest(oi, ctx);
+  }
+
   if (whiteout) {
     dout(20) << __func__ << " setting whiteout on " << soid << dendl;
     oi.set_flag(object_info_t::FLAG_WHITEOUT);
     ctx->delta_stats.num_whiteouts++;
-    if (oi.has_manifest()) {
-      ctx->delta_stats.num_objects_manifest--;
-      dec_all_refcount_head_manifest(oi, ctx);
-    }
     t->create(soid);
     osd->logger->inc(l_osd_tier_whiteout);
     return 0;
@@ -8014,10 +8020,6 @@ inline int PrimaryLogPG::_delete_oid(
   if (oi.is_cache_pinned()) {
     ctx->delta_stats.num_objects_pinned--;
   }
-  if (oi.has_manifest()) {
-    ctx->delta_stats.num_objects_manifest--;
-    dec_all_refcount_head_manifest(oi, ctx);
-  }
   obs.exists = false;
   return 0;
 }
index 74cf9f5d4bf6cc9d7b70370c3d5785d0bc4dd9d1..bf3ea0bc39f2e72502747e82df73b4e83d310eec 100644 (file)
@@ -1503,7 +1503,7 @@ protected:
                         hobject_t tgt_soid, SnapContext snapc, refcount_t type, RefCountCallback* cb);
   void dec_all_refcount_head_manifest(object_info_t& oi, OpContext* ctx);
   void dec_refcount_non_intersection(ObjectContextRef obc, const object_info_t& oi, 
-                                    set<uint64_t> intersection_set);
+                                    const set<uint64_t>& intersection_set);
 
   friend struct C_ProxyChunkRead;
   friend class PromoteManifestCallback;
index 3bdd70095c7beab41ee39233352f88bb802e9c3f..969bd566e8c395198da855c58aebfe334fa70fe8 100644 (file)
@@ -5827,6 +5827,13 @@ bool chunk_info_t::operator==(const chunk_info_t& cit) const
   return false;
 }
 
+bool operator==(const std::pair<const long unsigned int, chunk_info_t> & l,
+               const std::pair<const long unsigned int, chunk_info_t> & r) 
+{
+  return l.first == r.first &&
+        l.second == r.second;
+}
+
 ostream& operator<<(ostream& out, const chunk_info_t& ci)
 {
   return out << "(len: " << ci.length << " oid: " << ci.oid
@@ -5836,19 +5843,24 @@ ostream& operator<<(ostream& out, const chunk_info_t& ci)
 
 // -- object_manifest_t --
 
-void object_manifest_t::build_intersection_set(std::map<uint64_t, chunk_info_t>& map, 
-             set<uint64_t>& intersection, interval_set<uint64_t>* check_intersection)
-{
-  for (auto p : chunk_map) {
-    if (check_intersection) {
-      if (check_intersection->intersects(p.first, p.second.length)) {
-       intersection.insert(p.first);   
-       continue;
-      }
-    }
+/**
+ * build_intersection_set
+ *
+ * Returns the set offsets to references common (offset, length, and target match) to
+ * both map and this->chunk_map.
+ *
+ * @param map [in] map of object against which to compare
+ * @param map [in,out] set of target ids common to both maps
+ * @return void
+ */
 
-    for (auto c : map) {
-      if (p.second == c.second) {
+void object_manifest_t::build_intersection_set(const std::map<uint64_t, chunk_info_t>& map,
+                                              std::set<uint64_t>& intersection)
+{
+  for (const auto &p : chunk_map) {
+    auto c = map.find(p.first);
+    if (c != map.cend()) {
+      if (p == *c) {
        intersection.insert(p.first);
       }
     }
index c7814bfd887e01acab1ba513e03096829d7815d1..a97c50ac2b9d1d019eea91c8718167853cbc1442 100644 (file)
@@ -5530,8 +5530,8 @@ struct object_manifest_t {
     redirect_target = hobject_t();
     chunk_map.clear();
   }
-  void build_intersection_set(std::map<uint64_t, chunk_info_t>& map, 
-               set<uint64_t>& intersection, interval_set<uint64_t>* check_intersection);
+  void build_intersection_set(const std::map<uint64_t, chunk_info_t>& map,
+                              std::set<uint64_t>& intersection);
   static void generate_test_instances(std::list<object_manifest_t*>& o);
   void encode(ceph::buffer::list &bl) const;
   void decode(ceph::buffer::list::const_iterator &bl);