From: myoungwon oh Date: Fri, 22 May 2020 15:46:16 +0000 (-0400) Subject: osd: rework build_intersection_set X-Git-Tag: v16.1.0~1738^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a9ead9f20acef3e05956cd6fb107be4fee3e55ee;p=ceph.git osd: rework build_intersection_set Signed-off-by: Myoungwon Oh --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 9ff5dd05949..4ff21d767d1 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -3459,13 +3459,13 @@ void PrimaryLogPG::cancel_manifest_ops(bool requeue, vector *tids) } void PrimaryLogPG::dec_refcount_non_intersection(ObjectContextRef obc, const object_info_t& oi, - set intersection_set) + const set& 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 &newest_overlap = - ssc->snapset.clone_overlap.rbegin()->second; set 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 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; } diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 74cf9f5d4bf..bf3ea0bc39f 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -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 intersection_set); + const set& intersection_set); friend struct C_ProxyChunkRead; friend class PromoteManifestCallback; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 3bdd70095c7..969bd566e8c 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -5827,6 +5827,13 @@ bool chunk_info_t::operator==(const chunk_info_t& cit) const return false; } +bool operator==(const std::pair & l, + const std::pair & 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& map, - set& intersection, interval_set* 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& map, + std::set& intersection) +{ + for (const auto &p : chunk_map) { + auto c = map.find(p.first); + if (c != map.cend()) { + if (p == *c) { intersection.insert(p.first); } } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index c7814bfd887..a97c50ac2b9 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -5530,8 +5530,8 @@ struct object_manifest_t { redirect_target = hobject_t(); chunk_map.clear(); } - void build_intersection_set(std::map& map, - set& intersection, interval_set* check_intersection); + void build_intersection_set(const std::map& map, + std::set& intersection); static void generate_test_instances(std::list& o); void encode(ceph::buffer::list &bl) const; void decode(ceph::buffer::list::const_iterator &bl);