From: Igor Fedotov Date: Fri, 24 Jun 2016 12:05:28 +0000 (+0300) Subject: os/bluestore: cleanup _pad_zeros to eliminate redundant length param X-Git-Tag: v11.0.0~30^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b788261b261c56f09d97d2db52ff1a06eb7ce6c6;p=ceph.git os/bluestore: cleanup _pad_zeros to eliminate redundant length param Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index c4acf8e76be0..58a22f0ecaff 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5524,10 +5524,11 @@ void BlueStore::_dump_blob_map(BlobMap &bm, int log_level) } void BlueStore::_pad_zeros( - bufferlist *bl, uint64_t *offset, uint64_t *length, + bufferlist *bl, uint64_t *offset, uint64_t chunk_size) { - dout(30) << __func__ << " 0x" << std::hex << *offset << "~" << *length + auto length = bl->length(); + dout(30) << __func__ << " 0x" << std::hex << *offset << "~" << length << " chunk_size 0x" << chunk_size << std::dec << dendl; dout(40) << "before:\n"; bl->hexdump(*_dout); @@ -5537,51 +5538,52 @@ void BlueStore::_pad_zeros( size_t back_pad = 0; size_t pad_count = 0; if (front_pad) { - size_t front_copy = MIN(chunk_size - front_pad, *length); + 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); + 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); - t.substr_of(old, front_copy, *length - front_copy); + t.substr_of(old, front_copy, length - front_copy); bl->append(z); bl->claim_append(t); *offset -= front_pad; - *length += front_pad + back_pad; + length += front_pad + back_pad; } // back - uint64_t end = *offset + *length; + uint64_t end = *offset + length; unsigned back_copy = end % chunk_size; if (back_copy) { assert(back_pad == 0); back_pad = chunk_size - back_copy; - assert(back_copy <= *length); + assert(back_copy <= length); bufferptr tail(chunk_size); - memcpy(tail.c_str(), bl->get_contiguous(*length - back_copy, back_copy), + memcpy(tail.c_str(), bl->get_contiguous(length - back_copy, back_copy), back_copy); memset(tail.c_str() + back_copy, 0, back_pad); bufferlist old; old.swap(*bl); - bl->substr_of(old, 0, *length - back_copy); + bl->substr_of(old, 0, length - back_copy); bl->append(tail); - *length += back_pad; + 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 << "~" - << *length << std::dec << dendl; + << length << std::dec << dendl; dout(40) << "after:\n"; bl->hexdump(*_dout); *_dout << dendl; if (pad_count) logger->inc(l_bluestore_write_pad_bytes, pad_count); + assert(bl->length() == length); } void BlueStore::_do_write_small( @@ -5775,9 +5777,9 @@ void BlueStore::_do_write_small( b = o->blob_map.new_blob(c->cache); unsigned alloc_len = min_alloc_size; uint64_t b_off = offset % alloc_len; - uint64_t b_len = length; b->bc.write(txc->seq, b_off, bl, wctx->buffered ? 0 : Buffer::FLAG_NOCACHE); - _pad_zeros(&bl, &b_off, &b_len, block_size); + _pad_zeros(&bl, &b_off, block_size); + uint64_t b_len = bl.length(); if (b_off) b->blob.add_unused(0, b_off); if (b_off + b_len < alloc_len) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 66be681da666..0ce5bf54e9dc 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1551,7 +1551,7 @@ private: uint64_t offset, size_t len, bufferlist& bl, uint32_t fadvise_flags); - void _pad_zeros(bufferlist *bl, uint64_t *offset, uint64_t *length, + void _pad_zeros(bufferlist *bl, uint64_t *offset, uint64_t chunk_size); int _do_write(TransContext *txc, CollectionRef &c,