]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: cleanup _pad_zeros to eliminate redundant length param
authorIgor Fedotov <ifedotov@mirantis.com>
Fri, 24 Jun 2016 12:05:28 +0000 (15:05 +0300)
committerSage Weil <sage@redhat.com>
Mon, 27 Jun 2016 15:05:30 +0000 (08:05 -0700)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index c4acf8e76be03dd1ff1ec16f626c18d18263536d..58a22f0ecaff168db6b564cb0446118d4a958fcd 100644 (file)
@@ -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)
index 66be681da666c8300f6cfc32e1d6513c9b42b96f..0ce5bf54e9dc4aabf441ccc9bf4e9e1e66689427 100644 (file)
@@ -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,