]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: fix incorrect extents update on write_full
authorxie xingguo <xie.xingguo@zte.com.cn>
Sun, 22 Oct 2017 04:31:38 +0000 (12:31 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 24 Oct 2017 03:46:23 +0000 (11:46 +0800)
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 <xie.xingguo@zte.com.cn>
src/osd/PrimaryLogPG.cc

index 731f135fbb787d62c1c14756e43cc38a211b0f67..4ee0ad1e2b341b95c5d9204817f2739eb1c3cac2 100644 (file)
@@ -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<uint64_t> ne;
-     ne.insert(offset, length);
-     interval_set<uint64_t> 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);