From: xie xingguo Date: Sun, 22 Oct 2017 04:31:38 +0000 (+0800) Subject: osd/PrimaryLogPG: fix incorrect extents update on write_full X-Git-Tag: v13.0.1~411^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9da3f6bac1b261939254f1e16b1038bfc3968a27;p=ceph.git osd/PrimaryLogPG: fix incorrect extents update on write_full Two problems: (1) write_full may cause object size to shrink, but current code logical won't be able to handle this properly. (2) update stats in a simpler and consistent way. Signed-off-by: xie xingguo --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 731f135fbb787..4ee0ad1e2b341 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -7199,14 +7199,16 @@ void PrimaryLogPG::write_update_size_and_usage(object_stat_sum_t& delta_stats, o oi.size = new_size; } if (length && oi.has_extents()) { - // count newly write bytes, exclude overwrites - interval_set ne; - ne.insert(offset, length); - interval_set overlap; - overlap.intersection_of(ne, oi.extents); - ne.subtract(overlap); - oi.extents.union_of(ne); - delta_stats.num_bytes += ne.size(); + 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(); } delta_stats.num_wr++; delta_stats.num_wr_kb += SHIFT_ROUND_UP(length, 10);