From 8c630a040eb616d50ced921a5b7e73b1770c9418 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 26 Oct 2017 15:54:27 +0800 Subject: [PATCH] osd/PrimaryLogPG: add_object_context_to_pg_stat - fix stat There might be holes in the extents map, thus it is not always consistent to calc the clone bytes this way. Instead we could switch to its own (simpler and consistent) way to count used bytes for head-object and clone respectively. Signed-off-by: xie xingguo --- src/osd/PrimaryLogPG.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index d7f37292d86..d7c5ab3e961 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -9992,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++; @@ -10010,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 -- 2.47.3