From: Jianpeng Ma Date: Mon, 6 Jun 2016 15:44:32 +0000 (+0800) Subject: os/bluestore/BlueStore: Add perfcounter::l_bluestore_write_pad_bytes. X-Git-Tag: v11.0.0~290^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b3f353e2cf6a6131bada854dddfd8fe862e26597;p=ceph.git os/bluestore/BlueStore: Add perfcounter::l_bluestore_write_pad_bytes. For write, sometimes it need padd zero. Use this perfcounter to record the padding bytes. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 6149752c75bb..e7b25ee02b3c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 6026d9d66eac..a9b1351d1f17 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 };