]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueStore: Add perfcounter::l_bluestore_write_pad_bytes.
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 6 Jun 2016 15:44:32 +0000 (23:44 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Mon, 6 Jun 2016 15:44:32 +0000 (23:44 +0800)
For write, sometimes it need padd zero. Use this perfcounter to
record the padding bytes.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 6149752c75bb9d547644cc097b60090532c0f8cb..e7b25ee02b3cc8376297ecc4852e16aaabad46db 100644 (file)
@@ -1057,6 +1057,8 @@ void BlueStore::_init_logger()
   b.add_time_avg(l_bluestore_state_wal_done_lat, "state_wal_done_lat", "Average wal_done state latency");
   b.add_time_avg(l_bluestore_state_finishing_lat, "state_finishing_lat", "Average finishing state latency");
   b.add_time_avg(l_bluestore_state_done_lat, "state_done_lat", "Average done state latency");
+
+  b.add_u64(l_bluestore_write_pad_bytes, "write_pad_bytes", "Sum for write-op padded bytes");
   logger = b.create_perf_counters();
   g_ceph_context->get_perfcounters_collection()->add(logger);
 }
@@ -5404,14 +5406,17 @@ void BlueStore::_pad_zeros(
   // front
   size_t front_pad = *offset % chunk_size;
   size_t back_pad = 0;
+  size_t pad_count = 0;
   if (front_pad) {
     size_t front_copy = MIN(chunk_size - front_pad, *length);
     bufferptr z = buffer::create_page_aligned(chunk_size);
     memset(z.c_str(), 0, front_pad);
+    pad_count += front_pad;
     memcpy(z.c_str() + front_pad, bl->get_contiguous(0, front_copy), front_copy);
     if (front_copy + front_pad < chunk_size) {
       back_pad = chunk_size - (*length + front_pad);
       memset(z.c_str() + front_pad + *length, 0, back_pad);
+      pad_count += back_pad;
     }
     bufferlist old, t;
     old.swap(*bl);
@@ -5438,6 +5443,7 @@ void BlueStore::_pad_zeros(
     bl->substr_of(old, 0, *length - back_copy);
     bl->append(tail);
     *length += back_pad;
+    pad_count += back_pad;
   }
   dout(20) << __func__ << " pad 0x" << std::hex << front_pad << " + 0x"
           << back_pad << " on front/back, now 0x" << *offset << "~"
@@ -5445,6 +5451,8 @@ void BlueStore::_pad_zeros(
   dout(40) << "after:\n";
   bl->hexdump(*_dout);
   *_dout << dendl;
+  if (pad_count)
+    logger->inc(l_bluestore_write_pad_bytes, pad_count);
 }
 
 bool BlueStore::_can_overlay_write(OnodeRef o, uint64_t length)
@@ -5518,9 +5526,11 @@ void BlueStore::_do_write_small(
       z.append_zero(head_pad);
       z.claim_append(padded);
       padded.claim(z);
+      logger->inc(l_bluestore_write_pad_bytes, head_pad);
     }
     if (tail_pad) {
       padded.append_zero(tail_pad);
+      logger->inc(l_bluestore_write_pad_bytes, tail_pad);
     }
     if (head_pad || tail_pad) {
       dout(20) << __func__ << "  can pad head 0x" << std::hex << head_pad
@@ -5575,6 +5585,7 @@ void BlueStore::_do_write_small(
        size_t zlen = head_read - r;
        if (zlen) {
          head_bl.append_zero(zlen);
+         logger->inc(l_bluestore_write_pad_bytes, zlen);
        }
        b_off -= head_read;
        b_len += head_read;
@@ -5591,6 +5602,7 @@ void BlueStore::_do_write_small(
        size_t zlen = tail_read - r;
        if (zlen) {
          padded.append_zero(zlen);
+         logger->inc(l_bluestore_write_pad_bytes, zlen);
        }
       }
     }
@@ -5729,6 +5741,7 @@ int BlueStore::_do_alloc_write(
       if (newlen < final_length) {
        // pad out to min_alloc_size
        compressed_bl.append_zero(newlen - rawlen);
+       logger->inc(l_bluestore_write_pad_bytes, newlen - rawlen);
        dout(20) << __func__ << hex << "  compressed 0x" << b->length
                 << " -> 0x" << rawlen << " => 0x" << newlen
                 << " with " << chdr.type
index 6026d9d66eac20a60cdcae165658187e0ebd1b5b..a9b1351d1f17c80efa44b0dcaf17c6042883585f 100644 (file)
@@ -55,6 +55,7 @@ enum {
   l_bluestore_state_wal_done_lat,
   l_bluestore_state_finishing_lat,
   l_bluestore_state_done_lat,
+  l_bluestore_write_pad_bytes,
   l_bluestore_last
 };