diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index b95112c838c..9de1b3cee91 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -7205,17 +7205,21 @@ void PrimaryLogPG::write_update_size_and_usage(object_stat_sum_t& delta_stats, o } oi.size = new_size; } - if (length && oi.has_extents()) { - delta_stats.num_bytes -= oi.extents.size(); - if (write_full) { - // oi.size may shrink - oi.extents.clear(); - assert(offset == 0); - oi.extents.insert(0, length); - } else { - oi.extents.union_of(ch); // deduplicated - } - delta_stats.num_bytes += oi.extents.size(); + if (oi.has_extents()) { + delta_stats.num_bytes -= oi.extents.size(); + if (write_full) { + // oi.size may shrink + oi.extents.clear(); + assert(offset == 0); + if (length) { + oi.extents.insert(0, length); + } + } else { + if (length) { + oi.extents.union_of(ch); // deduplicated + } + } + delta_stats.num_bytes += oi.extents.size(); } delta_stats.num_wr++; delta_stats.num_wr_kb += SHIFT_ROUND_UP(length, 10); @@ -9988,8 +9992,6 @@ void PrimaryLogPG::add_object_context_to_pg_stat(ObjectContextRef obc, pg_stat_t assert(!oi.soid.is_snapdir()); object_stat_sum_t stat; - stat.num_bytes += oi.has_extents() ? - oi.extents.size() : oi.size; stat.num_objects++; if (oi.is_dirty()) stat.num_objects_dirty++; @@ -10006,12 +10008,10 @@ void PrimaryLogPG::add_object_context_to_pg_stat(ObjectContextRef obc, pg_stat_t if (!obc->ssc) obc->ssc = get_snapset_context(oi.soid, false); assert(obc->ssc); - - // subtract off clone overlap - auto it = obc->ssc->snapset.clone_overlap.find(oi.soid.snap); - if (it != obc->ssc->snapset.clone_overlap.end()) { - stat.num_bytes -= it->second.size(); - } + stat.num_bytes += obc->ssc->snapset.get_clone_bytes(oi.soid.snap); + } else { + stat.num_bytes += oi.has_extents() ? + oi.extents.size() : oi.size; } // add it in diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 7f252b54557..6b9414115dc 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -5122,16 +5122,7 @@ ostream& operator<<(ostream& out, const object_info_t& oi) if (oi.has_manifest()) out << " " << oi.manifest; if (oi.has_extents()) { - out << " extents ["; - for (interval_set::const_iterator p = oi.extents.begin(); - p != oi.extents.end();) { - out << p.get_start() << "~" << p.get_len(); - ++p; - if (p != oi.extents.end()) { - out << ", "; - } - } - out << "]"; + out << " extents " << oi.extents; } out << ")"; return out;